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
|
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
|
a: str | None = None
|
||||||
s: str | None = None
|
s: str | None = None
|
||||||
t: 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"])
|
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}")
|
print(f"HI, DATA:\n{data}")
|
||||||
src = data.src.upper()
|
src = data.src.upper()
|
||||||
if not(src in self.acceptable_request_sources):
|
if not(src in self.acceptable_request_sources):
|
||||||
@ -82,11 +101,9 @@ class LyricSearch(FastAPI):
|
|||||||
searchSong = urllib.parse.unquote(searchSong)
|
searchSong = urllib.parse.unquote(searchSong)
|
||||||
|
|
||||||
if searchText is None:
|
if searchText is None:
|
||||||
searchObject = self.lyrics_engine.create_query_object("%s : %s" % (searchArtist, searchSong),
|
searchObject = self.lyrics_engine.create_query_object("%s : %s" % (searchArtist, searchSong))
|
||||||
method_order=self.search_method_order)
|
|
||||||
if subSearch:
|
if subSearch:
|
||||||
searchObject = self.lyrics_engine.create_query_object("%s : %s : %s" % (searchArtist, searchSong, subSearch),
|
searchObject = self.lyrics_engine.create_query_object("%s : %s : %s" % (searchArtist, searchSong, subSearch))
|
||||||
method_order=self.search_method_order)
|
|
||||||
|
|
||||||
searchWorker = await self.lyrics_engine.lyrics_worker(searching=searchObject,
|
searchWorker = await self.lyrics_engine.lyrics_worker(searching=searchObject,
|
||||||
method_order=self.search_method_order,
|
method_order=self.search_method_order,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user