Commit 8d9c9884 authored by David Trattnig's avatar David Trattnig
Browse files

Assign next timeslot. Docs. #43 #44

parent 7473fd8a
......@@ -64,6 +64,11 @@ class TrackServiceHandler():
def on_queue(self, entries):
"""
Items have been queued. They are stored to the local playlog, allowing later
matching and retrieval to augment meta-information.
Args:
entries ([PlaylistEntry]): The entries which got queued
"""
for entry in entries:
self.playlog.add(entry)
......@@ -100,6 +105,7 @@ class TrackServiceHandler():
self.store_clock_info(data)
def on_metadata(self, meta):
"""
Some metadata update was sent from Liquidsoap.
......@@ -138,7 +144,6 @@ class TrackServiceHandler():
self.store_trackservice(data)
self.store_clock_info(data)
def store_trackservice(self, data):
......@@ -163,8 +168,8 @@ class TrackServiceHandler():
"""
current_playlist = self.engine.scheduler.get_active_playlist()
(past_timeslot, current_timeslot, next_timeslot) = self.playlog.get_timeslots()
next_timeslot = self.engine.scheduler.get_next_schedules(1)
if next_timeslot: next_timeslot = next_timeslot[0]
# next_timeslot = self.engine.scheduler.get_next_timeslots(1)
# if next_timeslot: next_timeslot = next_timeslot[0]
data = dict()
data["engine_source"] = self.config.get("api_engine_number")
......@@ -239,13 +244,21 @@ class Playlog:
def set_timeslot(self, timeslot):
"""
Sets the current timeslot and proper default values if no timeslot is available.
Any previous timeslot is stored to `self.previous_timeslot` and the following one
to `self.next_timeslot`.
This method is protect by overwritting by multiple calls with the same timeslot.
Args:
timeslot (Timeslot): The current timeslot
"""
if timeslot and self.previous_timeslot:
if self.previous_timeslot.get("schedule_start") == timeslot.schedule_start:
return # Avoid overwrite by multiple calls in a row
data = {}
next_timeslot = self.engine.scheduler.get_next_schedules(1)
next_timeslot = self.engine.scheduler.get_next_timeslots(1)
if next_timeslot: next_timeslot = next_timeslot[0]
if timeslot:
......@@ -281,7 +294,7 @@ class Playlog:
data["schedule_end"] = datetime.now() + timedelta(hours=1)
if self.next_timeslot:
if next_timeslot:
ns = {}
self.assign_fallback_playlist(ns, next_timeslot)
ns["schedule_id"] = next_timeslot.schedule_id
......@@ -298,6 +311,11 @@ class Playlog:
def assign_fallback_playlist(self, data, timeslot):
"""
Assigns fallback info to the given timeslot.
Args:
data ({}): The dictionary holding the (virtual) timeslot
timeslot (Timeslot): The actual timeslot object to retrieve fallback info from
"""
fallback_type = None
playlist = None
......@@ -318,6 +336,10 @@ class Playlog:
def get_timeslots(self):
"""
Retrieves all available timeslots for the past, future and the current one.
Returns:
({}, {}, {})
"""
return (self.previous_timeslot, self.current_timeslot, self.next_timeslot)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment