diff --git a/endpoints/lyric_search.py b/endpoints/lyric_search.py index 1dbf71b..5cc8b45 100644 --- a/endpoints/lyric_search.py +++ b/endpoints/lyric_search.py @@ -170,19 +170,19 @@ class LyricSearch(FastAPI): async def lyric_search_handler(self, data: ValidLyricRequest): """ - Search for lyrics (testing) + Search for lyrics - **a**: artist - **s**: song - - **t**: track (artist and song combined) [used only if a & s are not used] [unused] + - **t**: track (artist and song combined) [used only if a & s are not used] - **extra**: include extra details in response [optional, default: false] [unused] - **lrc**: Request LRCs? - **sub**: text to search within lyrics, if found lyrics will begin at found verse [optional, default: none] - **src**: the script/utility which initiated the request - - **excluded_sources**: sources to exclude + - **excluded_sources**: sources to exclude [optional, default: none] """ - if not data.a or not data.s or not data.src: + if (not data.a or not data.s) and not data.t or not data.src: raise HTTPException(detail="Invalid request", status_code=500) if data.src.upper() not in self.acceptable_request_sources: @@ -193,9 +193,13 @@ class LyricSearch(FastAPI): 'errorText': f'Unknown request source: {data.src}', } - search_artist: Optional[str] = data.a - search_song: Optional[str] = data.s - + if not data.t: + search_artist: str = data.a + search_song: str = data.s + else: + t_split = data.t.split(" - ", maxsplit=1) + search_artist: str = t_split[0] + search_song: str = t_split[1] if search_artist and search_song: