feat: Add load_playlist method to PlayerService and update task handlers for playlist management

This commit is contained in:
JSC
2025-08-28 22:50:57 +02:00
parent 03abed6d39
commit 6e74d9b940
2 changed files with 34 additions and 9 deletions

View File

@@ -429,6 +429,26 @@ class PlayerService:
await self._broadcast_state()
async def load_playlist(self, playlist_id: int) -> None:
"""Load a specific playlist by ID."""
session = self.db_session_factory()
try:
playlist_repo = PlaylistRepository(session)
playlist = await playlist_repo.get_by_id(playlist_id)
if playlist and playlist.id:
sounds = await playlist_repo.get_playlist_sounds(playlist.id)
await self._handle_playlist_reload(playlist, sounds)
logger.info(
"Loaded playlist: %s (%s sounds)",
playlist.name,
len(sounds),
)
else:
logger.warning("Playlist not found: %s", playlist_id)
finally:
await session.close()
await self._broadcast_state()
async def _handle_playlist_reload(
self,
current_playlist: Playlist,