This commit is contained in:
jxxghp
2024-06-02 21:09:15 +08:00
parent 45945bd025
commit c05223846f
4 changed files with 26 additions and 8 deletions

View File

@ -85,7 +85,7 @@ def search_by_id(mediaid: str,
return schemas.Response(success=True, data=[torrent.to_dict() for torrent in torrents])
@router.get("/title", summary="模糊搜索资源", response_model=List[schemas.TorrentInfo])
@router.get("/title", summary="模糊搜索资源", response_model=schemas.Response)
async def search_by_title(keyword: str = None,
page: int = 0,
site: int = None,
@ -94,4 +94,6 @@ async def search_by_title(keyword: str = None,
根据名称模糊搜索站点资源,支持分页,关键词为空是返回首页资源
"""
torrents = SearchChain().search_by_title(title=keyword, page=page, site=site)
return [torrent.to_dict() for torrent in torrents]
if not torrents:
return schemas.Response(success=False, message="未搜索到任何资源")
return schemas.Response(success=True, data=[torrent.to_dict() for torrent in torrents])