This commit is contained in:
@@ -69,6 +69,7 @@ class PlaylistService:
|
||||
name: str,
|
||||
description: str | None = None,
|
||||
genre: str | None = None,
|
||||
*,
|
||||
is_main: bool = False,
|
||||
is_current: bool = False,
|
||||
is_deletable: bool = True,
|
||||
@@ -104,6 +105,7 @@ class PlaylistService:
|
||||
self,
|
||||
playlist_id: int,
|
||||
user_id: int,
|
||||
*,
|
||||
name: str | None = None,
|
||||
description: str | None = None,
|
||||
genre: str | None = None,
|
||||
@@ -179,7 +181,11 @@ class PlaylistService:
|
||||
return await self.playlist_repo.get_playlist_sounds(playlist_id)
|
||||
|
||||
async def add_sound_to_playlist(
|
||||
self, playlist_id: int, sound_id: int, user_id: int, position: int | None = None,
|
||||
self,
|
||||
playlist_id: int,
|
||||
sound_id: int,
|
||||
user_id: int,
|
||||
position: int | None = None,
|
||||
) -> None:
|
||||
"""Add a sound to a playlist."""
|
||||
# Verify playlist exists
|
||||
@@ -202,11 +208,17 @@ class PlaylistService:
|
||||
|
||||
await self.playlist_repo.add_sound_to_playlist(playlist_id, sound_id, position)
|
||||
logger.info(
|
||||
"Added sound %s to playlist %s for user %s", sound_id, playlist_id, user_id,
|
||||
"Added sound %s to playlist %s for user %s",
|
||||
sound_id,
|
||||
playlist_id,
|
||||
user_id,
|
||||
)
|
||||
|
||||
async def remove_sound_from_playlist(
|
||||
self, playlist_id: int, sound_id: int, user_id: int,
|
||||
self,
|
||||
playlist_id: int,
|
||||
sound_id: int,
|
||||
user_id: int,
|
||||
) -> None:
|
||||
"""Remove a sound from a playlist."""
|
||||
# Verify playlist exists
|
||||
@@ -228,7 +240,10 @@ class PlaylistService:
|
||||
)
|
||||
|
||||
async def reorder_playlist_sounds(
|
||||
self, playlist_id: int, user_id: int, sound_positions: list[tuple[int, int]],
|
||||
self,
|
||||
playlist_id: int,
|
||||
user_id: int,
|
||||
sound_positions: list[tuple[int, int]],
|
||||
) -> None:
|
||||
"""Reorder sounds in a playlist."""
|
||||
# Verify playlist exists
|
||||
@@ -262,7 +277,8 @@ class PlaylistService:
|
||||
await self._unset_current_playlist(user_id)
|
||||
await self._set_main_as_current(user_id)
|
||||
logger.info(
|
||||
"Unset current playlist and set main as current for user %s", user_id,
|
||||
"Unset current playlist and set main as current for user %s",
|
||||
user_id,
|
||||
)
|
||||
|
||||
async def get_playlist_stats(self, playlist_id: int) -> dict[str, Any]:
|
||||
@@ -286,11 +302,13 @@ class PlaylistService:
|
||||
main_playlist = await self.get_main_playlist()
|
||||
|
||||
if main_playlist.id is None:
|
||||
raise ValueError("Main playlist has no ID")
|
||||
msg = "Main playlist has no ID, cannot add sound"
|
||||
raise ValueError(msg)
|
||||
|
||||
# Check if sound is already in main playlist
|
||||
if not await self.playlist_repo.is_sound_in_playlist(
|
||||
main_playlist.id, sound_id,
|
||||
main_playlist.id,
|
||||
sound_id,
|
||||
):
|
||||
await self.playlist_repo.add_sound_to_playlist(main_playlist.id, sound_id)
|
||||
logger.info(
|
||||
|
||||
Reference in New Issue
Block a user