Skip to content
Snippets Groups Projects
Verified Commit 2b96eeeb authored by David Trattnig's avatar David Trattnig Committed by Ole Binder
Browse files

refactor: Init timeslots with virtual state

parent a169d7e6
No related branches found
No related tags found
1 merge request!46Steering playout schema and virtual timeslot integration
...@@ -174,32 +174,44 @@ class ApiFetcher(threading.Thread): ...@@ -174,32 +174,44 @@ class ApiFetcher(threading.Thread):
id=api_ts.show.id, id=api_ts.show.id,
name=api_ts.show.name, name=api_ts.show.name,
) )
episode = Episode(id=ep.id, title=ep.title) if (ep := api_ts.episode) and ep else None episode = None
memo = None
if api_ts.timeslot:
memo = api_ts.timeslot.memo
if (ep := api_ts.episode) and ep:
episode = Episode(id=ep.id, title=ep.title, memo=memo)
# TODO resolve timeslot referenced by `repetition_id` # TODO resolve timeslot referenced by `repetition_id`
timeslot = Timeslot( timeslot = Timeslot(
id=api_ts.id, id=api_ts.id,
virtual=False if api_ts.timeslot_id else True,
repetition_id=api_ts.timeslot.repetition_of_id if api_ts.timeslot else None, repetition_id=api_ts.timeslot.repetition_of_id if api_ts.timeslot else None,
start=api_ts.start.timestamp(), start=api_ts.start.timestamp(),
end=api_ts.end.timestamp(), end=api_ts.end.timestamp(),
show=show, show=show,
episode=episode, episode=episode,
) )
# Fetch playlists for timeslot
playlist_timeslot = None # Virtual timeslot do not have media-sources assigned,
playlist_schedule = None # therefore no playlists need to be fetched.
playlist_show = None if not timeslot.is_virtual():
if (ts := api_ts.timeslot) and ts and (plid := ts.playlist_id) and plid: # Fetch playlists for timeslot
playlist_timeslot = self.fetch_playlist(plid) playlist_timeslot = None
if (sc := api_ts.schedule) and sc and (plid := sc.default_playlist_id) and plid: playlist_schedule = None
playlist_schedule = self.fetch_playlist(plid) playlist_show = None
if (sh := api_ts.show) and sh and (plid := sh.default_playlist_id):
playlist_show = self.fetch_playlist(plid) if (ts := api_ts.timeslot) and ts and (plid := ts.playlist_id) and plid:
playlist_timeslot = self.fetch_playlist(plid)
timeslot.set_playlists(playlist_timeslot, playlist_schedule, playlist_show) if (sc := api_ts.schedule) and sc and (plid := sc.default_playlist_id) and plid:
self.expand_item_duration(playlist_timeslot) playlist_schedule = self.fetch_playlist(plid)
self.expand_item_duration(playlist_schedule) if (sh := api_ts.show) and sh and (plid := sh.default_playlist_id):
self.expand_item_duration(playlist_show) playlist_show = self.fetch_playlist(plid)
timeslot.set_playlists(playlist_timeslot, playlist_schedule, playlist_show)
self.expand_item_duration(playlist_timeslot)
self.expand_item_duration(playlist_schedule)
self.expand_item_duration(playlist_show)
timeslots.append(timeslot) timeslots.append(timeslot)
return timeslots return timeslots
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment