feat: Add load_playlist method to PlayerService and update task handlers for playlist management
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user