mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 04:53:01 +00:00
calculate playlist duration
- use python's `sum()` method to add durations instead of for loop
This commit is contained in:
committed by
Mungai Geoffrey
parent
5bc0eaf8e6
commit
b318c0d324
@@ -84,7 +84,12 @@ def get_playlist(playlistid: str):
|
||||
playlist = models.Playlist(p)
|
||||
|
||||
tracks = playlistlib.create_playlist_tracks(playlist.pretracks)
|
||||
return {"info": serializer.Playlist(playlist), "tracks": tracks}
|
||||
|
||||
duration = sum([t.length for t in tracks])
|
||||
playlist = serializer.Playlist(playlist)
|
||||
playlist.duration = duration
|
||||
|
||||
return {"info": playlist, "tracks": tracks}
|
||||
|
||||
|
||||
@playlist_bp.route("/playlist/<playlistid>/update", methods=["PUT"])
|
||||
|
||||
Reference in New Issue
Block a user