Skip to content
Snippets Groups Projects
Commit 84592ce0 authored by David Trattnig's avatar David Trattnig
Browse files

refactor: add update playlist method

parent 20399adc
No related branches found
No related tags found
1 merge request!35ORM-less scheduling
......@@ -34,6 +34,7 @@ import enum
from typing import NamedTuple
from aura_engine import resources
from aura_engine.base.lang import synchronized
from aura_engine.base.utils import SimpleUtil as SU
from aura_engine.core.channels import GenericChannel
......@@ -146,6 +147,7 @@ class Playlist:
"""
return self.shuffle
@synchronized
def add(self, item: PlaylistItem) -> None:
"""
Add an item to the playlist.
......@@ -165,6 +167,25 @@ class Playlist:
item.set_playlist(self)
self.items.append(item)
@synchronized
def update_playlist(self, playlist: Playlist):
"""
Update the playlist data with the one passed.
It is important to avoid overwriting any local references, as they might be already in use
of scheduling threads.
Args:
playlist (Playlist): Playlist with fresh data.
"""
self.id = playlist.id
self.desc = playlist.desc
self.shuffle = playlist.shuffle
self.items = playlist.get_items()
item: PlaylistItem
for item in self.get_items():
item.set_playlist(self)
def __str__(self) -> str:
"""
String representation.
......@@ -311,7 +332,7 @@ class Timeslot:
self.playlist = Playlists(timeslot=pl_timeslot, schedule=pl_schedule, show=pl_show)
def get_current_playlist(self):
def get_current_playlist(self) -> Playlist:
"""
Retrieve the playlist to be scheduled.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment