This commit is contained in:
jxxghp
2023-08-06 08:56:40 +08:00
parent 1f922a1e39
commit bb49078751
3 changed files with 9 additions and 6 deletions

View File

@ -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]

View File

@ -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 []

View File

@ -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')),