rewrite pending; for now, additional support for multi-station

This commit is contained in:
2025-07-19 21:57:21 -04:00
parent 85182b7d8c
commit 9ce16ba923
5 changed files with 76 additions and 57 deletions

View File

@@ -71,10 +71,12 @@ class LyricSearch(FastAPI):
)
for endpoint, handler in self.endpoints.items():
rate_limit: tuple[int, int] = (2, 3) # Default; (Times, Seconds)
rate_limit: tuple[int, int] = (2, 3) # Default; (Times, Seconds)
_schema_include = endpoint in ["lyric/search"]
if endpoint == "typeahead/lyrics": # More permissive rate limiting for typeahead
if (
endpoint == "typeahead/lyrics"
): # More permissive rate limiting for typeahead
rate_limit = (20, 2)
(times, seconds) = rate_limit
@@ -83,9 +85,10 @@ class LyricSearch(FastAPI):
handler,
methods=["POST"],
include_in_schema=_schema_include,
dependencies=[Depends(RateLimiter(times=times, seconds=seconds))] if not endpoint == "typeahead/lyrics" else None
dependencies=[Depends(RateLimiter(times=times, seconds=seconds))]
if not endpoint == "typeahead/lyrics"
else None,
)
async def typeahead_handler(self, data: ValidTypeAheadRequest) -> JSONResponse:
"""