fix douban api

This commit is contained in:
jxxghp
2024-04-27 21:17:32 +08:00
parent 1718758d1c
commit 6a71bed821
4 changed files with 41 additions and 52 deletions

View File

@ -1,5 +1,5 @@
from pathlib import Path
from typing import List, Any, Union
from typing import List, Any
from fastapi import APIRouter, Depends
@ -64,20 +64,22 @@ def recognize_file2(path: str,
@router.get("/search", summary="搜索媒体/人物信息", response_model=List[dict])
def search_by_title(title: str,
type: str = "media",
page: int = 1,
count: int = 8,
_: schemas.TokenPayload = Depends(verify_token)) -> Any:
def search(title: str,
type: str = "media",
page: int = 1,
count: int = 8,
_: schemas.TokenPayload = Depends(verify_token)) -> Any:
"""
模糊搜索媒体/人物信息列表 media媒体信息person人物信息
"""
_, medias = MediaChain().search(title=title, stype=type)
if medias:
if type == "media":
if type == "media":
_, medias = MediaChain().search(title=title)
if medias:
return [media.to_dict() for media in medias[(page - 1) * count: page * count]]
else:
return medias[(page - 1) * count: page * count]
else:
persons = MediaChain().search_persons(name=title)
if persons:
return persons[(page - 1) * count: page * count]
return []