add notifier to lyric_search for unknown request src, add timeout for widget/radio endpoint
This commit is contained in:
parent
417d8b00f0
commit
2df8250ba2
@ -13,6 +13,7 @@ import aiosqlite as sqlite3
|
||||
from fastapi import FastAPI, HTTPException
|
||||
from pydantic import BaseModel
|
||||
from lyric_search_new.sources import aggregate
|
||||
from lyric_search_new import notifier
|
||||
|
||||
|
||||
class ValidLyricRequest(BaseModel):
|
||||
@ -92,6 +93,7 @@ class LyricSearch(FastAPI):
|
||||
self.constants = constants
|
||||
self.glob_state = glob_state
|
||||
self.cache_utils = CacheUtils()
|
||||
self.notifier = notifier.DiscordNotifier()
|
||||
self.lyrics_engine = importlib.import_module("lyrics_engine").LyricsEngine()
|
||||
|
||||
self.endpoint_name = "lyric_search"
|
||||
@ -184,9 +186,11 @@ class LyricSearch(FastAPI):
|
||||
raise HTTPException(detail="Invalid request", status_code=500)
|
||||
|
||||
if data.src.upper() not in self.acceptable_request_sources:
|
||||
await self.notifier.send(f"ERROR @ {__file__.rsplit("/", maxsplit=1)[-1]}",
|
||||
f"Unknown request source: {data.src}")
|
||||
return {
|
||||
'err': True,
|
||||
'errorText': f'Unknown request source: {data.src.upper()}',
|
||||
'errorText': f'Unknown request source: {data.src}',
|
||||
}
|
||||
|
||||
search_artist: Optional[str] = data.a
|
||||
|
@ -57,7 +57,7 @@ class Misc(FastAPI):
|
||||
#TODO: change URL below to dynamically populate based on listener
|
||||
async with ClientSession() as session:
|
||||
async with await session.post("http://127.0.0.1:52111/xc/", json=json_payload,
|
||||
headers=headers) as request:
|
||||
headers=headers, timeout=ClientTimeout(connect=3, sock_read=2)) as request:
|
||||
request.raise_for_status()
|
||||
request_json = await request.json()
|
||||
request_json = request_json.get('response')
|
||||
|
Loading…
x
Reference in New Issue
Block a user