add "single" label if album is a single

This commit is contained in:
geoffrey45
2022-06-09 12:52:14 +03:00
parent e48dca4672
commit c1834778f1
5 changed files with 57 additions and 46 deletions
+10 -2
View File
@@ -36,7 +36,7 @@ def get_albums():
@album_bp.route("/album/tracks", methods=["POST"])
def get_album_tracks():
def get_album():
"""Returns all the tracks in the given album."""
data = request.get_json()
@@ -46,11 +46,19 @@ def get_album_tracks():
songs = trackslib.get_album_tracks(album, artist)
albumhash = helpers.create_album_hash(album, artist)
index = albumslib.find_album(api.ALBUMS, albumhash)
album = api.ALBUMS[index]
album: models.Album = api.ALBUMS[index]
album.count = len(songs)
album.duration = albumslib.get_album_duration(songs)
if (
album.count == 1
and songs[0].title == album.title
and songs[0].tracknumber == 1
and songs[0].disknumber == 1
):
album.is_single = True
return {"songs": songs, "info": album}