diff --git a/app/api/endpoints/search.py b/app/api/endpoints/search.py index 01f0cab3..f613f4d1 100644 --- a/app/api/endpoints/search.py +++ b/app/api/endpoints/search.py @@ -46,13 +46,13 @@ def search_by_tmdbid(mediaid: str, return [torrent.to_dict() for torrent in torrents] -@router.get("/title/{keyword}", summary="模糊搜索资源", response_model=List[schemas.Context]) -async def search_by_title(keyword: str, +@router.get("/title", summary="模糊搜索资源", response_model=List[schemas.TorrentInfo]) +async def search_by_title(keyword: str = None, page: int = 1, site: int = None, _: schemas.TokenPayload = Depends(verify_token)) -> Any: """ - 根据名称模糊搜索站点资源 + 根据名称模糊搜索站点资源,支持分页,关键词为空是返回首页资源 """ torrents = SearchChain().search_by_title(title=keyword, page=page, site=site) - return [Context(torrent_info=torrent).to_dict() for torrent in torrents] + return [torrent.to_dict() for torrent in torrents] diff --git a/app/chain/search.py b/app/chain/search.py index 99ba8833..67211a9b 100644 --- a/app/chain/search.py +++ b/app/chain/search.py @@ -53,7 +53,10 @@ class SearchChain(ChainBase): :param page: 页码 :param site: 站点ID """ - logger.info(f'开始搜索资源,关键词:{title} ...') + if title: + logger.info(f'开始搜索资源,关键词:{title} ...') + else: + logger.info(f'开始浏览资源,站点:{site} ...') # 搜索 return self.__search_all_sites(keyword=title, sites=[site] if site else None, page=page) or [] diff --git a/app/modules/indexer/tnode.py b/app/modules/indexer/tnode.py index 90ef6237..e2d98201 100644 --- a/app/modules/indexer/tnode.py +++ b/app/modules/indexer/tnode.py @@ -83,7 +83,7 @@ class TNodeSpider: results = res.json().get('data', {}).get("torrents") or [] for result in results: torrent = { - 'id': self._indexerid, + 'site': self._indexerid, 'title': result.get('title'), 'description': result.get('subtitle'), 'enclosure': self._downloadurl % (self._domain, result.get('id')),