fix #3670
This commit is contained in:
jxxghp
2025-01-07 14:20:31 +08:00
parent b5d58b8a9e
commit 23650657cd
17 changed files with 25 additions and 23 deletions
+1 -1
View File
@@ -62,7 +62,7 @@ class ChainBase(metaclass=ABCMeta):
"""
try:
with open(settings.TEMP_PATH / filename, 'wb') as f:
pickle.dump(cache, f)
pickle.dump(cache, f) # noqa
except Exception as err:
logger.error(f"保存缓存 {filename} 出错:{str(err)}")
finally:
+2 -2
View File
@@ -96,7 +96,7 @@ class SiteChain(ChainBase):
))
return userdata
def refresh_userdatas(self) -> Dict[str, SiteUserData]:
def refresh_userdatas(self) -> Optional[Dict[str, SiteUserData]]:
"""
刷新所有站点的用户数据
"""
@@ -105,7 +105,7 @@ class SiteChain(ChainBase):
result = {}
for site in sites:
if global_vars.is_system_stopped:
return
return None
if site.get("is_active"):
userdata = self.refresh_userdata(site)
if userdata:
+8 -5
View File
@@ -6,6 +6,8 @@ import time
from datetime import datetime
from typing import Dict, List, Optional, Union, Tuple
from cachetools import TTLCache
from app.chain import ChainBase
from app.chain.download import DownloadChain
from app.chain.media import MediaChain
@@ -508,7 +510,7 @@ class SubscribeChain(ChainBase, metaclass=Singleton):
return
# 记录重新识别过的种子
_recognize_cached = []
_recognize_cached = TTLCache(maxsize=1024, ttl=6 * 3600)
with self._rlock:
logger.debug(f"match lock acquired at {datetime.now()}")
@@ -572,14 +574,15 @@ class SubscribeChain(ChainBase, metaclass=Singleton):
# 有自定义识别词时,需要判断是否需要重新识别
if subscribe.custom_words:
custom_words_list = subscribe.custom_words.split("\n")
_, apply_words = WordsMatcher().prepare(torrent_info.title,
custom_words=subscribe.custom_words.split("\n"))
custom_words=custom_words_list)
if apply_words:
logger.info(
f'{torrent_info.site_name} - {torrent_info.title} 因订阅存在自定义识别词,重新识别元数据...')
# 重新识别元数据
torrent_meta = MetaInfo(title=torrent_info.title, subtitle=torrent_info.description,
custom_words=subscribe.custom_words)
custom_words=custom_words_list)
# 媒体信息需要重新识别
torrent_mediainfo = None
@@ -588,8 +591,8 @@ class SubscribeChain(ChainBase, metaclass=Singleton):
or (not torrent_mediainfo.tmdb_id and not torrent_mediainfo.douban_id):
# 避免重复处理
_cache_key = f"{torrent_meta.org_string}_{torrent_info.description}"
if _cache_key not in _recognize_cached:
_recognize_cached.append(_cache_key)
if not _recognize_cached.get(_cache_key):
_recognize_cached[_cache_key] = True
# 重新识别媒体信息
torrent_mediainfo = self.recognize_media(meta=torrent_meta)
if torrent_mediainfo: