docstring stuff
This commit is contained in:
parent
88fcd0f3c6
commit
70c738ac4b
@ -10,7 +10,15 @@ from fastapi import FastAPI, Form, HTTPException
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class ValidRequest(BaseModel):
|
||||
class ValidLyricRequest(BaseModel):
|
||||
"""
|
||||
- **a**: artist
|
||||
- **s**: song
|
||||
- **t**: track (artist and song combined) [used only if a & s are not used]
|
||||
- **extra**: include extra details in response [optional, default: false]
|
||||
- **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
|
||||
"""
|
||||
a: str | None = None
|
||||
s: str | None = None
|
||||
t: str | None = None
|
||||
@ -46,7 +54,18 @@ class LyricSearch(FastAPI):
|
||||
|
||||
app.add_api_route(self.endpoint_name, self.search_handler, methods=["POST"])
|
||||
|
||||
async def search_handler(self, data: ValidRequest):
|
||||
async def search_handler(self, data: ValidLyricRequest):
|
||||
"""
|
||||
Search for lyrics
|
||||
|
||||
- **a**: artist
|
||||
- **s**: song
|
||||
- **t**: track (artist and song combined) [used only if a & s are not used]
|
||||
- **extra**: include extra details in response [optional, default: false]
|
||||
- **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
|
||||
"""
|
||||
|
||||
print(f"HI, DATA:\n{data}")
|
||||
src = data.src.upper()
|
||||
if not(src in self.acceptable_request_sources):
|
||||
@ -82,11 +101,9 @@ class LyricSearch(FastAPI):
|
||||
searchSong = urllib.parse.unquote(searchSong)
|
||||
|
||||
if searchText is None:
|
||||
searchObject = self.lyrics_engine.create_query_object("%s : %s" % (searchArtist, searchSong),
|
||||
method_order=self.search_method_order)
|
||||
searchObject = self.lyrics_engine.create_query_object("%s : %s" % (searchArtist, searchSong))
|
||||
if subSearch:
|
||||
searchObject = self.lyrics_engine.create_query_object("%s : %s : %s" % (searchArtist, searchSong, subSearch),
|
||||
method_order=self.search_method_order)
|
||||
searchObject = self.lyrics_engine.create_query_object("%s : %s : %s" % (searchArtist, searchSong, subSearch))
|
||||
|
||||
searchWorker = await self.lyrics_engine.lyrics_worker(searching=searchObject,
|
||||
method_order=self.search_method_order,
|
||||
|
Loading…
x
Reference in New Issue
Block a user