From c201473dbd994bdd7535057066495af8b44e36af Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Thu, 30 Aug 2012 12:02:26 -0400 Subject: [PATCH] CC-4311: On Air button gets greyed out few seconds after show starts -fixed --- python_apps/api_clients/api_client.cfg | 2 +- python_apps/api_clients/api_client.py | 4 +-- python_apps/pypo/pyponotify.py | 36 +++++++------------------- 3 files changed, 12 insertions(+), 30 deletions(-) diff --git a/python_apps/api_clients/api_client.cfg b/python_apps/api_clients/api_client.cfg index 4a4c351b6..fdd7c3b1b 100644 --- a/python_apps/api_clients/api_client.cfg +++ b/python_apps/api_clients/api_client.cfg @@ -96,7 +96,7 @@ get_media_url = 'get-media/file/%%file%%/api_key/%%api_key%%' update_item_url = 'notify-schedule-group-play/api_key/%%api_key%%/schedule_id/%%schedule_id%%' # Update whether an audio clip is currently playing. -update_start_playing_url = 'notify-media-item-start-play/api_key/%%api_key%%/media_id/%%media_id%%/schedule_id/%%schedule_id%%' +update_start_playing_url = 'notify-media-item-start-play/api_key/%%api_key%%/media_id/%%media_id%%/' # URL to tell Airtime we want to get stream setting get_stream_setting = 'get-stream-setting/format/json/api_key/%%api_key%%/' diff --git a/python_apps/api_clients/api_client.py b/python_apps/api_clients/api_client.py index 25862281a..7fb2de631 100644 --- a/python_apps/api_clients/api_client.py +++ b/python_apps/api_clients/api_client.py @@ -250,14 +250,12 @@ class AirtimeApiClient(): currently playing *song*. We get passed a JSON string which we handed to liquidsoap in get_liquidsoap_data(). """ - def notify_media_item_start_playing(self, data, media_id): + def notify_media_item_start_playing(self, media_id): logger = self.logger response = '' try: - schedule_id = data url = "http://%s:%s/%s/%s" % (self.config["base_url"], str(self.config["base_port"]), self.config["api_base"], self.config["update_start_playing_url"]) url = url.replace("%%media_id%%", str(media_id)) - url = url.replace("%%schedule_id%%", str(schedule_id)) logger.debug(url) url = url.replace("%%api_key%%", self.config["api_key"]) diff --git a/python_apps/pypo/pyponotify.py b/python_apps/pypo/pyponotify.py index bd401fdf3..446da8d49 100644 --- a/python_apps/pypo/pyponotify.py +++ b/python_apps/pypo/pyponotify.py @@ -67,27 +67,21 @@ except Exception, e: class Notify: def __init__(self): - self.api_client = api_client.AirtimeApiClient() + self.api_client = api_client.AirtimeApiClient(logger=logger) def notify_liquidsoap_started(self): - logger = logging.getLogger("notify") logger.debug("Notifying server that Liquidsoap has started") self.api_client.notify_liquidsoap_started() - def notify_media_start_playing(self, data, media_id): - logger = logging.getLogger("notify") - + def notify_media_start_playing(self, media_id): logger.debug('#################################################') logger.debug('# Calling server to update about what\'s playing #') logger.debug('#################################################') - logger.debug('data = ' + str(data)) - response = self.api_client.notify_media_item_start_playing(data, media_id) + response = self.api_client.notify_media_item_start_playing(media_id) logger.debug("Response: " + json.dumps(response)) # @pram time: time that LS started def notify_liquidsoap_status(self, msg, stream_id, time): - logger = logging.getLogger("notify") - logger.debug('#################################################') logger.debug('# Calling server to update liquidsoap status #') logger.debug('#################################################') @@ -96,8 +90,6 @@ class Notify: logger.debug("Response: " + json.dumps(response)) def notify_source_status(self, source_name, status): - logger = logging.getLogger("notify") - logger.debug('#################################################') logger.debug('# Calling server to update source status #') logger.debug('#################################################') @@ -106,7 +98,6 @@ class Notify: logger.debug("Response: " + json.dumps(response)) def notify_webstream_data(self, data, media_id): - logger = logging.getLogger("notify") logger.debug('#################################################') logger.debug('# Calling server to update webstream data #') logger.debug('#################################################') @@ -121,7 +112,6 @@ if __name__ == '__main__': print '#########################################' # initialize - logger = logging.getLogger("notify") if options.error and options.stream_id: try: n = Notify() @@ -146,23 +136,17 @@ if __name__ == '__main__': n.notify_webstream_data(options.webstream, options.media_id) except Exception, e: print e + elif options.media_id: + + try: + n = Notify() + n.notify_media_start_playing(options.media_id) + except Exception, e: + print e elif options.liquidsoap_started: try: n = Notify() n.notify_liquidsoap_started() except Exception, e: print e - else: - if not options.data: - print "NOTICE: 'data' command-line argument not given." - sys.exit() - if not options.media_id: - print "NOTICE: 'media_id' command-line argument not given." - sys.exit() - - try: - n = Notify() - n.notify_media_start_playing(options.data, options.media_id) - except Exception, e: - print e