fix search
This commit is contained in:
parent
46b5f3ba3b
commit
a99cd77b68
@ -2,7 +2,7 @@ from typing import Optional, List
|
|||||||
|
|
||||||
from app.chain import _ChainBase
|
from app.chain import _ChainBase
|
||||||
from app.chain.common import CommonChain
|
from app.chain.common import CommonChain
|
||||||
from app.core import Context, MetaInfo, MediaInfo, TorrentInfo
|
from app.core import Context, MetaInfo, MediaInfo, TorrentInfo, settings
|
||||||
from app.core.meta import MetaBase
|
from app.core.meta import MetaBase
|
||||||
from app.helper.sites import SitesHelper
|
from app.helper.sites import SitesHelper
|
||||||
from app.log import logger
|
from app.log import logger
|
||||||
@ -26,13 +26,22 @@ class SearchChain(_ChainBase):
|
|||||||
:param mediainfo: 媒体信息
|
:param mediainfo: 媒体信息
|
||||||
:param keyword: 搜索关键词
|
:param keyword: 搜索关键词
|
||||||
"""
|
"""
|
||||||
# 执行搜索
|
|
||||||
logger.info(f'开始搜索资源,关键词:{keyword or mediainfo.title} ...')
|
logger.info(f'开始搜索资源,关键词:{keyword or mediainfo.title} ...')
|
||||||
|
# 未开启的站点不搜索
|
||||||
|
indexer_sites = []
|
||||||
|
for indexer in self.siteshelper.get_indexers():
|
||||||
|
if settings.INDEXER_SITES \
|
||||||
|
and any([s in indexer.get("domain") for s in settings.INDEXER_SITES.split(',')]):
|
||||||
|
indexer_sites.append(indexer)
|
||||||
|
if not indexer_sites:
|
||||||
|
logger.warn('未开启任何有效站点,无法搜索资源')
|
||||||
|
return []
|
||||||
|
# 执行搜索
|
||||||
torrents: List[TorrentInfo] = self.run_module(
|
torrents: List[TorrentInfo] = self.run_module(
|
||||||
'search_torrents',
|
'search_torrents',
|
||||||
mediainfo=mediainfo,
|
mediainfo=mediainfo,
|
||||||
keyword=keyword,
|
keyword=keyword,
|
||||||
sites=self.siteshelper.get_indexers()
|
sites=indexer_sites
|
||||||
)
|
)
|
||||||
if not torrents:
|
if not torrents:
|
||||||
logger.warn(f'{keyword or mediainfo.title} 未搜索到资源')
|
logger.warn(f'{keyword or mediainfo.title} 未搜索到资源')
|
||||||
|
@ -3,7 +3,7 @@ from typing import Dict, List, Optional
|
|||||||
from app.chain import _ChainBase
|
from app.chain import _ChainBase
|
||||||
from app.chain.common import CommonChain
|
from app.chain.common import CommonChain
|
||||||
from app.chain.search import SearchChain
|
from app.chain.search import SearchChain
|
||||||
from app.core import MetaInfo, TorrentInfo, Context, MediaInfo
|
from app.core import MetaInfo, TorrentInfo, Context, MediaInfo, settings
|
||||||
from app.db.subscribes import Subscribes
|
from app.db.subscribes import Subscribes
|
||||||
from app.helper.sites import SitesHelper
|
from app.helper.sites import SitesHelper
|
||||||
from app.log import logger
|
from app.log import logger
|
||||||
@ -122,6 +122,10 @@ class SubscribeChain(_ChainBase):
|
|||||||
indexers = self.siteshelper.get_indexers()
|
indexers = self.siteshelper.get_indexers()
|
||||||
# 遍历站点缓存资源
|
# 遍历站点缓存资源
|
||||||
for indexer in indexers:
|
for indexer in indexers:
|
||||||
|
# 未开启的站点不搜索
|
||||||
|
if settings.INDEXER_SITES \
|
||||||
|
and not any([s in indexer.get("domain") for s in settings.INDEXER_SITES.split(',')]):
|
||||||
|
continue
|
||||||
logger.info(f'开始刷新站点资源,站点:{indexer.get("name")} ...')
|
logger.info(f'开始刷新站点资源,站点:{indexer.get("name")} ...')
|
||||||
domain = StringUtils.get_url_domain(indexer.get("domain"))
|
domain = StringUtils.get_url_domain(indexer.get("domain"))
|
||||||
torrents: List[TorrentInfo] = self.run_module("refresh_torrents", sites=[indexer])
|
torrents: List[TorrentInfo] = self.run_module("refresh_torrents", sites=[indexer])
|
||||||
|
@ -53,7 +53,7 @@ class IndexerModule(_ModuleBase):
|
|||||||
results += result
|
results += result
|
||||||
# 计算耗时
|
# 计算耗时
|
||||||
end_time = datetime.now()
|
end_time = datetime.now()
|
||||||
logger.info(f"所有站点搜索完成,有效资源数:{len(results)},总耗时 {(end_time - start_time).seconds} 秒")
|
logger.info(f"站点搜索完成,有效资源数:{len(results)},总耗时 {(end_time - start_time).seconds} 秒")
|
||||||
# 返回
|
# 返回
|
||||||
return results
|
return results
|
||||||
|
|
||||||
@ -74,10 +74,6 @@ class IndexerModule(_ModuleBase):
|
|||||||
else:
|
else:
|
||||||
search_word = None
|
search_word = None
|
||||||
|
|
||||||
# 未开启的站点不搜索
|
|
||||||
if settings.INDEXER_SITES and not any([s in site.get("domain") for s in settings.INDEXER_SITES.split(',')]):
|
|
||||||
return []
|
|
||||||
|
|
||||||
if search_word \
|
if search_word \
|
||||||
and site.get('language') == "en" \
|
and site.get('language') == "en" \
|
||||||
and StringUtils.is_chinese(search_word):
|
and StringUtils.is_chinese(search_word):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user