From 03a07ac7bfca120206c4797649dbd066905d2ee0 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Mon, 18 Sep 2023 17:05:08 +0800 Subject: [PATCH] =?UTF-8?q?fix=20RSS=E6=A8=A1=E5=BC=8F=E6=8C=87=E5=AE=9A?= =?UTF-8?q?=E8=AE=A2=E9=98=85=E7=AB=99=E7=82=B9=E6=97=B6=E4=B8=8D=E5=88=B7?= =?UTF-8?q?=E6=96=B0=E8=AE=A2=E9=98=85=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/endpoints/site.py | 6 +++--- app/chain/search.py | 11 ++++++----- app/chain/torrents.py | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/api/endpoints/site.py b/app/api/endpoints/site.py index 3e078af2..92316cc4 100644 --- a/app/api/endpoints/site.py +++ b/app/api/endpoints/site.py @@ -234,14 +234,14 @@ def read_rss_sites(db: Session = Depends(get_db)) -> List[dict]: 获取站点列表 """ # 选中的rss站点 - rss_sites = SystemConfigOper().get(SystemConfigKey.RssSites) + selected_sites = SystemConfigOper().get(SystemConfigKey.RssSites) or [] # 所有站点 all_site = Site.list_order_by_pri(db) - if not rss_sites or not all_site: + if not selected_sites or not all_site: return [] # 选中的rss站点 - rss_sites = [site for site in all_site if site and site.id in rss_sites] + rss_sites = [site for site in all_site if site and site.id in selected_sites] return rss_sites diff --git a/app/chain/search.py b/app/chain/search.py index b4c86552..2c390dbc 100644 --- a/app/chain/search.py +++ b/app/chain/search.py @@ -247,14 +247,14 @@ class SearchChain(ChainBase): """ # 未开启的站点不搜索 indexer_sites = [] + # 配置的索引站点 - if sites: - config_indexers = [str(sid) for sid in sites] - else: - config_indexers = [str(sid) for sid in self.systemconfig.get(SystemConfigKey.IndexerSites) or []] + if not sites: + sites = self.systemconfig.get(SystemConfigKey.IndexerSites) or [] + for indexer in self.siteshelper.get_indexers(): # 检查站点索引开关 - if not config_indexers or str(indexer.get("id")) in config_indexers: + if not sites or indexer.get("id") in sites: # 站点流控 state, msg = self.siteshelper.check(indexer.get("domain")) if state: @@ -264,6 +264,7 @@ class SearchChain(ChainBase): if not indexer_sites: logger.warn('未开启任何有效站点,无法搜索资源') return [] + # 开始进度 self.progress.start(ProgressKey.Search) # 开始计时 diff --git a/app/chain/torrents.py b/app/chain/torrents.py index b92b9cf6..c86bdf53 100644 --- a/app/chain/torrents.py +++ b/app/chain/torrents.py @@ -129,7 +129,7 @@ class TorrentsChain(ChainBase, metaclass=Singleton): # 刷新站点 if not sites: - sites = [str(sid) for sid in (self.systemconfig.get(SystemConfigKey.RssSites) or [])] + sites = self.systemconfig.get(SystemConfigKey.RssSites) or [] # 读取缓存 torrents_cache = self.get_torrents() @@ -139,7 +139,7 @@ class TorrentsChain(ChainBase, metaclass=Singleton): # 遍历站点缓存资源 for indexer in indexers: # 未开启的站点不刷新 - if sites and str(indexer.get("id")) not in sites: + if sites and indexer.get("id") not in sites: continue domain = StringUtils.get_url_domain(indexer.get("domain")) if stype == "spider":