diff --git a/python_apps/pypo/pypopush.py b/python_apps/pypo/pypopush.py index 0b66e7a08..6e8592c68 100644 --- a/python_apps/pypo/pypopush.py +++ b/python_apps/pypo/pypopush.py @@ -57,6 +57,7 @@ class PypoPush(Thread): next_media_item_chain = None media_schedule = None time_until_next_play = None + chains = None while True: try: @@ -65,10 +66,11 @@ class PypoPush(Thread): else: media_schedule = self.queue.get(block=True, timeout=time_until_next_play) + chains = self.get_all_chains(media_schedule) + #We get to the following lines only if a schedule was received. liquidsoap_queue_approx = self.get_queue_items_from_liquidsoap() - chains = self.get_all_chains(media_schedule) current_event_chain = self.get_current_chain(chains) if len(current_event_chain) > 0 and len(liquidsoap_queue_approx) == 0: #Something is scheduled but Liquidsoap is not playing anything! @@ -79,8 +81,10 @@ class PypoPush(Thread): else: media_chain = filter(lambda item: (item["type"] == "file"), current_event_chain) self.handle_new_media_schedule(media_schedule, liquidsoap_queue_approx, media_chain) - chains = self.get_all_chains(media_schedule) + + #chains = self.get_all_chains(media_schedule) next_media_item_chain = self.get_next_schedule_chain(chains) + self.logger.debug("Next schedule chain: %s", next_media_item_chain) if next_media_item_chain is not None: tnow = datetime.utcnow() @@ -93,11 +97,9 @@ class PypoPush(Thread): except Empty, e: #We only get here when a new chain of tracks are ready to be played. self.push_to_liquidsoap(next_media_item_chain) + + chains.remove(next_media_item_chain) - #TODO - time.sleep(2) - - chains = self.get_all_chains(media_schedule) next_media_item_chain = self.get_next_schedule_chain(chains) if next_media_item_chain is not None: tnow = datetime.utcnow()