mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 20:43:04 +00:00
create albums from pre-albums instead of individual tracks
This commit is contained in:
+14
-7
@@ -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"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user