This commit is contained in:
jxxghp
2024-04-26 20:29:04 +08:00
parent 9daff87f2f
commit c303ab0765
5 changed files with 11 additions and 31 deletions

View File

@ -1,5 +1,5 @@
from pathlib import Path
from typing import List, Any
from typing import List, Any, Union
from fastapi import APIRouter, Depends
@ -63,7 +63,7 @@ def recognize_file2(path: str,
return recognize_file(path)
@router.get("/search", summary="搜索媒体/人物信息", response_model=List[schemas.MediaInfo])
@router.get("/search", summary="搜索媒体/人物信息", response_model=List[dict])
def search_by_title(title: str,
type: str = "media",
page: int = 1,
@ -74,7 +74,10 @@ def search_by_title(title: str,
"""
_, medias = MediaChain().search(title=title, stype=type)
if medias:
return [media.to_dict() for media in medias[(page - 1) * count: page * count]]
if type == "media":
return [media.to_dict() for media in medias[(page - 1) * count: page * count]]
else:
return medias[(page - 1) * count: page * count]
return []