changes
This commit is contained in:
@ -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 {
|
||||
|
Reference in New Issue
Block a user