This commit is contained in:
2025-01-15 20:17:49 -05:00
parent b2bb724826
commit c09f72803e
7 changed files with 128 additions and 25 deletions

View File

@ -1,6 +1,8 @@
#!/usr/bin/env python3.12
# pylint: disable=bare-except
import importlib
import traceback
from fastapi import FastAPI
from pydantic import BaseModel
@ -182,19 +184,25 @@ class LastFM(FastAPI):
/get_track_info/
Get track info from Last.FM given an artist/track
"""
artist = data.a
track = data.t
if not artist or not track:
try:
artist = data.a
track = data.t
if not artist or not track:
return {
'err': True,
'errorText': 'Invalid request'
}
track_info_result = await self.lastfm.get_track_info(artist=artist, track=track)
assert not "err" in track_info_result.keys()
return {
'success': True,
'result': track_info_result
}
except:
traceback.print_exc()
return {
'err': True,
'errorText': 'Invalid request'
}
track_info_result = await self.lastfm.get_track_info(artist=artist, track=track)
assert not "err" in track_info_result.keys()
return {
'success': True,
'result': track_info_result
}
'errorText': 'General error',
}