@ -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',
|
||||
}
|
||||
|
Reference in New Issue
Block a user