mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-04 23:17:20 +08:00
fix 订阅匹配缓存问题
This commit is contained in:
+7
-11
@@ -6,8 +6,6 @@ import time
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Dict, List, Optional, Union, Tuple
|
from typing import Dict, List, Optional, Union, Tuple
|
||||||
|
|
||||||
from cachetools import TTLCache
|
|
||||||
|
|
||||||
from app.chain import ChainBase
|
from app.chain import ChainBase
|
||||||
from app.chain.download import DownloadChain
|
from app.chain.download import DownloadChain
|
||||||
from app.chain.media import MediaChain
|
from app.chain.media import MediaChain
|
||||||
@@ -509,9 +507,6 @@ class SubscribeChain(ChainBase, metaclass=Singleton):
|
|||||||
logger.warn('没有缓存资源,无法匹配订阅')
|
logger.warn('没有缓存资源,无法匹配订阅')
|
||||||
return
|
return
|
||||||
|
|
||||||
# 记录重新识别过的种子
|
|
||||||
_recognize_cached = TTLCache(maxsize=1024, ttl=6 * 3600)
|
|
||||||
|
|
||||||
with self._rlock:
|
with self._rlock:
|
||||||
logger.debug(f"match lock acquired at {datetime.now()}")
|
logger.debug(f"match lock acquired at {datetime.now()}")
|
||||||
# 所有订阅
|
# 所有订阅
|
||||||
@@ -552,6 +547,12 @@ class SubscribeChain(ChainBase, metaclass=Singleton):
|
|||||||
if exist_flag:
|
if exist_flag:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# 订阅识别词
|
||||||
|
if subscribe.custom_words:
|
||||||
|
custom_words_list = subscribe.custom_words.split("\n")
|
||||||
|
else:
|
||||||
|
custom_words_list = None
|
||||||
|
|
||||||
# 遍历缓存种子
|
# 遍历缓存种子
|
||||||
_match_context = []
|
_match_context = []
|
||||||
for domain, contexts in torrents.items():
|
for domain, contexts in torrents.items():
|
||||||
@@ -573,8 +574,7 @@ class SubscribeChain(ChainBase, metaclass=Singleton):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# 有自定义识别词时,需要判断是否需要重新识别
|
# 有自定义识别词时,需要判断是否需要重新识别
|
||||||
if subscribe.custom_words:
|
if custom_words_list:
|
||||||
custom_words_list = subscribe.custom_words.split("\n")
|
|
||||||
_, apply_words = WordsMatcher().prepare(torrent_info.title,
|
_, apply_words = WordsMatcher().prepare(torrent_info.title,
|
||||||
custom_words=custom_words_list)
|
custom_words=custom_words_list)
|
||||||
if apply_words:
|
if apply_words:
|
||||||
@@ -589,10 +589,6 @@ class SubscribeChain(ChainBase, metaclass=Singleton):
|
|||||||
# 先判断是否有没识别的种子,否则重新识别
|
# 先判断是否有没识别的种子,否则重新识别
|
||||||
if not torrent_mediainfo \
|
if not torrent_mediainfo \
|
||||||
or (not torrent_mediainfo.tmdb_id and not torrent_mediainfo.douban_id):
|
or (not torrent_mediainfo.tmdb_id and not torrent_mediainfo.douban_id):
|
||||||
# 避免重复处理
|
|
||||||
_cache_key = f"{torrent_meta.org_string}_{torrent_info.description}"
|
|
||||||
if not _recognize_cached.get(_cache_key):
|
|
||||||
_recognize_cached[_cache_key] = True
|
|
||||||
# 重新识别媒体信息
|
# 重新识别媒体信息
|
||||||
torrent_mediainfo = self.recognize_media(meta=torrent_meta)
|
torrent_mediainfo = self.recognize_media(meta=torrent_meta)
|
||||||
if torrent_mediainfo:
|
if torrent_mediainfo:
|
||||||
|
|||||||
Reference in New Issue
Block a user