mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +00:00
implement getting all playlist tracks
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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]
|
||||
)
|
||||
@@ -71,4 +74,4 @@ class PlaylistStore:
|
||||
if playlist.trackhashes.index(track["trackhash"]) == track["index"]:
|
||||
playlist.trackhashes.remove(track["trackhash"])
|
||||
|
||||
playlist.rebuild_images()
|
||||
playlist.rebuild_images()
|
||||
|
||||
Reference in New Issue
Block a user