This commit is contained in:
2025-01-14 18:37:49 -05:00
parent 06581c1fce
commit 598478f804
6 changed files with 59 additions and 30 deletions

View File

@@ -72,15 +72,12 @@ class AI(FastAPI):
}
}]
}
logging.critical("Request: %s", data)
async with ClientSession() as session:
async with session.post(data.hook, json=hook_data,
timeout=ClientTimeout(connect=5, sock_read=5), headers={
'content-type': 'application/json; charset=utf-8',}) as request:
logging.debug("Returned: %s",
await request.json())
await request.raise_for_status()
request.raise_for_status()
return True
except:
traceback.print_exc()

View File

@@ -7,7 +7,6 @@ import logging
import urllib.parse
import regex
import aiohttp
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
from lyric_search_new.sources import aggregate
@@ -22,6 +21,7 @@ class ValidLyricRequest(BaseModel):
- **lrc**: Request LRCs?
- **sub**: text to search within lyrics, if found lyrics will begin at found verse [optional]
- **src**: the script/utility which initiated the request
- **excluded_sources**: sources to exclude (new only)
"""
a: str | None = None
@@ -31,6 +31,7 @@ class ValidLyricRequest(BaseModel):
extra: bool | None = False
lrc: bool | None = False
src: str
excluded_sources: list | None = None
class Config: # pylint: disable=missing-class-docstring too-few-public-methods
schema_extra = {
@@ -116,12 +117,14 @@ class LyricSearch(FastAPI):
- **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]
- **excluded_sources**: sources to exclude
"""
if not data.a or not data.s:
raise HTTPException(detail="Invalid request", status_code=500)
aggregate_search = aggregate.Aggregate(exclude_methods=None)
excluded_sources = data.excluded_sources
aggregate_search = aggregate.Aggregate(exclude_methods=excluded_sources)
result = await aggregate_search.search(data.a, data.s)
if not result:
return {