beep boop

This commit is contained in:
codey 2025-01-29 16:03:33 -05:00
parent ca02c9a731
commit 5c8fefb605
2 changed files with 18 additions and 12 deletions

View File

@ -47,15 +47,15 @@ allow_headers=["*"])
Blacklisted routes Blacklisted routes
""" """
@app.get("/") @app.get("/", include_in_schema=False)
def disallow_get(): def disallow_get():
return util.get_blocked_response() return util.get_blocked_response()
@app.head("/") @app.head("/", include_in_schema=False)
def base_head(): def base_head():
return return
@app.get("/{path}") @app.get("/{path}", include_in_schema=False)
def disallow_get_any(request: Request, var: Any = None): # pylint: disable=unused-argument def disallow_get_any(request: Request, var: Any = None): # pylint: disable=unused-argument
path = request.path_params['path'] path = request.path_params['path']
if not ( if not (
@ -68,7 +68,7 @@ def disallow_get_any(request: Request, var: Any = None): # pylint: disable=unuse
logging.info("OK, %s", logging.info("OK, %s",
path) path)
@app.post("/") @app.post("/", include_in_schema=False)
def disallow_base_post(): def disallow_base_post():
return util.get_blocked_response() return util.get_blocked_response()

View File

@ -37,17 +37,21 @@ class ValidLyricRequest(BaseModel):
src: str src: str
excluded_sources: list | None = None excluded_sources: list | None = None
class Config: # pylint: disable=missing-class-docstring too-few-public-methods model_config = {
schema_extra = { "json_schema_extra": {
"example": { "examples": [
{
"a": "eminem", "a": "eminem",
"s": "rap god", "s": "rap god",
"src": "WEB", "src": "WEB",
"extra": True, "extra": True,
"lrc": False, "lrc": False,
"excluded_sources": [],
}]
} }
} }
class ValidTypeAheadRequest(BaseModel): class ValidTypeAheadRequest(BaseModel):
""" """
- **query**: query string - **query**: query string
@ -118,7 +122,8 @@ class LyricSearch(FastAPI):
self.lrc_regex = regex.compile(r'\[([0-9]{2}:[0-9]{2})\.[0-9]{1,3}\](\s(.*)){0,}') self.lrc_regex = regex.compile(r'\[([0-9]{2}:[0-9]{2})\.[0-9]{1,3}\](\s(.*)){0,}')
for endpoint, handler in self.endpoints.items(): for endpoint, handler in self.endpoints.items():
app.add_api_route(f"/{endpoint}", handler, methods=["POST", "GET"]) _schema_include = endpoint in ["lyric_search"]
app.add_api_route(f"/{endpoint}", handler, methods=["POST"], include_in_schema=_schema_include)
# async def lyric_cache_list_handler(self): # async def lyric_cache_list_handler(self):
# """ # """
@ -172,7 +177,7 @@ class LyricSearch(FastAPI):
- **a**: artist - **a**: artist
- **s**: song - **s**: song
- **t**: track (artist and song combined) [used only if a & s are not used] - **t**: track (artist and song combined) [used only if a & s are not used]
- **extra**: include extra details in response [optional, default: false] [unused] - **extra**: include extra details in response [optional, default: false]
- **lrc**: Request LRCs? - **lrc**: Request LRCs?
- **sub**: text to search within lyrics, if found lyrics will begin at found verse [optional, default: none] - **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 - **src**: the script/utility which initiated the request
@ -252,6 +257,7 @@ class LyricSearch(FastAPI):
REMOVE BELOW AFTER TESTING IS DONE REMOVE BELOW AFTER TESTING IS DONE
""" """
# if not data.extra: if not data.extra:
# result.pop('src') result.pop('src')
return result return result