try catch breaking parts of lyrics plugin

This commit is contained in:
mungai-njoroge
2023-11-07 01:41:06 +03:00
parent 836bbe4dc5
commit de5b2a53b1
4 changed files with 43 additions and 25 deletions
+1 -1
View File
@@ -33,7 +33,7 @@ def send_lyrics():
lyrics, is_synced, copyright = get_lyrics_from_tags(filepath)
if not lyrics:
return {"error": "No lyrics found"}, 404
return {"error": "No lyrics found"}
return {"lyrics": lyrics, "synced": is_synced, "copyright": copyright}, 200
+7 -4
View File
@@ -1,4 +1,5 @@
from flask import Blueprint, request
from app.plugins.lyrics import Lyrics
from app.utils.hashing import create_hash
@@ -19,7 +20,7 @@ def search_lyrics():
data = finder.search_lyrics_by_title_and_artist(title, artist)
if not data:
return {"downloaded": False, "all": []}, 404
return {"downloaded": False}
perfect_match = data[0]
@@ -31,9 +32,11 @@ def search_lyrics():
i_album
) == create_hash(album):
perfect_match = track
break
else:
track["saved"] = False
track_id = perfect_match["track_id"]
downloaded = finder.download_lyrics_to_path_by_id(track_id, filepath)
downloaded = finder.download_lyrics(track_id, filepath)
return {"downloaded": downloaded, "all": data}, 200
return {"downloaded": downloaded}, 200