create albums from pre-albums instead of individual tracks

This commit is contained in:
geoffrey45
2022-04-25 11:59:36 +03:00
parent c6e3bd9f94
commit 6527b3abc5
6 changed files with 106 additions and 45 deletions
+14 -7
View File
@@ -15,11 +15,17 @@ def send_track_file(trackid):
Returns an audio file that matches the passed id to the client.
"""
try:
filepath = [
file["filepath"] for file in api.DB_TRACKS
if file["_id"]["$oid"] == trackid
][0]
except (FileNotFoundError, IndexError) as e:
files = []
for f in api.DB_TRACKS:
try:
if f["_id"]["$oid"] == trackid:
files.append(f["filepath"])
except KeyError:
# Bug: some albums are not found although they exist in `api.ALBUMS`. It has something to do with the bisection method used or sorting. Not sure yet.
pass
filepath = files[0]
except IndexError:
return "File not found", 404
return send_file(filepath, mimetype="audio/mp3")
@@ -31,5 +37,6 @@ def get_sample_track():
Returns a sample track object.
"""
return instances.tracks_instance.get_song_by_album("Legends Never Die",
"Juice WRLD")
return instances.tracks_instance.get_song_by_album(
"Legends Never Die", "Juice WRLD"
)