This commit is contained in:
2025-01-13 20:47:39 -05:00
parent 945a3d9bf6
commit 86946f0316
8 changed files with 292 additions and 19 deletions

View File

@ -9,7 +9,8 @@ import regex
import aiohttp
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
from pydantic import BaseModel
from lyric_search_new.sources import aggregate
class ValidLyricRequest(BaseModel):
@ -65,7 +66,8 @@ class LyricSearch(FastAPI):
self.endpoints = {
"lyric_search": self.lyric_search_handler,
"lyric_cache_list": self.lyric_cache_list_handler,
"lyric_search_history": self.lyric_search_log_handler
"lyric_search_history": self.lyric_search_log_handler,
"lyric_search_test": self.new_test,
}
self.acceptable_request_sources = [
@ -102,7 +104,28 @@ class LyricSearch(FastAPI):
'err': False,
'history': last_10k_sings
}
async def new_test(self, data: ValidLyricRequest):
"""
Search for lyrics (testing)
- **a**: artist
- **s**: song
- **t**: track (artist and song combined) [used only if a & s are not used] [unused]
- **extra**: include extra details in response [optional, default: false] [unused]
- **lrc**: Request LRCs? [unused]
- **sub**: text to search within lyrics, if found lyrics will begin at found verse [optional, default: none] [unused]
- **src**: the script/utility which initiated the request [unused]
"""
if not data.a or not data.s:
raise HTTPException(detail="Invalid request", status_code=500)
aggregate_search = aggregate.Aggregate()
result = await aggregate_search.search(data.a, data.s)
return result.dict()
async def lyric_search_handler(self, data: ValidLyricRequest):
"""