implement getting all playlist tracks

This commit is contained in:
cwilvx
2024-07-19 23:46:28 +03:00
parent 8f592a4636
commit 5d32536758
2 changed files with 8 additions and 2 deletions
+3
View File
@@ -205,6 +205,9 @@ def get_playlist(path: PlaylistIDPath, query: GetPlaylistQuery):
return {"msg": "Playlist not found"}, 404
playlist = entry.playlist
if query.limit == -1:
query.limit = None
tracks = PlaylistStore.get_playlist_tracks(playlistid, query.start, query.limit)
duration = sum(t.duration for t in tracks)
+4 -1
View File
@@ -32,7 +32,7 @@ class PlaylistStore:
print(cls.playlistmap)
@classmethod
def get_playlist_tracks(cls, playlist_id: str, start: int, limit: int):
def get_playlist_tracks(cls, playlist_id: str, start: int, limit: int | None):
"""
Returns the trackhashes for a playlist.
"""
@@ -41,6 +41,9 @@ class PlaylistStore:
if entry is None:
return []
if limit is None:
return TrackStore.get_tracks_by_trackhashes(entry.trackhashes[start:])
return TrackStore.get_tracks_by_trackhashes(
entry.trackhashes[start : start + limit]
)