fix api
This commit is contained in:
@ -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 []
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user