mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-04-05 03:38:36 +08:00
fix torrent
This commit is contained in:
@@ -1130,7 +1130,7 @@ class TTLCache(CacheProxy):
|
||||
使用项目的缓存后端实现,支持 Redis 和内存缓存
|
||||
"""
|
||||
|
||||
def __init__(self, maxsize: int = 128, ttl: int = 600, region: Optional[str] = None):
|
||||
def __init__(self, maxsize: int = 1024, ttl: int = 600, region: Optional[str] = None):
|
||||
"""
|
||||
初始化 TTL 缓存
|
||||
|
||||
@@ -1138,10 +1138,7 @@ class TTLCache(CacheProxy):
|
||||
:param ttl: 缓存的存活时间,单位秒
|
||||
:param region: 缓存的区,为 None 时使用默认区
|
||||
"""
|
||||
self.maxsize = maxsize
|
||||
self.ttl = ttl
|
||||
cache_backend = Cache(maxsize=maxsize, ttl=ttl)
|
||||
super().__init__(cache_backend, region or DEFAULT_CACHE_REGION, ttl)
|
||||
super().__init__(Cache(maxsize=maxsize, ttl=ttl), region or DEFAULT_CACHE_REGION, ttl)
|
||||
|
||||
|
||||
class LRUCache(CacheProxy):
|
||||
@@ -1157,6 +1154,4 @@ class LRUCache(CacheProxy):
|
||||
:param maxsize: 缓存的最大条目数
|
||||
:param region: 缓存的区,为 None 时使用默认区
|
||||
"""
|
||||
self.maxsize = maxsize
|
||||
cache_backend = Cache(maxsize=maxsize)
|
||||
super().__init__(cache_backend, region or DEFAULT_CACHE_REGION)
|
||||
super().__init__(Cache(maxsize=maxsize), region or DEFAULT_CACHE_REGION)
|
||||
|
||||
@@ -7,6 +7,7 @@ from urllib.parse import unquote
|
||||
from torrentool.api import Torrent
|
||||
|
||||
from app.core.cache import FileCache
|
||||
from app.core.cache import TTLCache
|
||||
from app.core.config import settings
|
||||
from app.core.context import Context, TorrentInfo, MediaInfo
|
||||
from app.core.meta import MetaBase
|
||||
@@ -25,7 +26,7 @@ class TorrentHelper:
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self._invalid_torrents = []
|
||||
self._invalid_torrents = TTLCache(maxsize=128, ttl=3600 * 24)
|
||||
|
||||
def download_torrent(self, url: str,
|
||||
cookie: Optional[str] = None,
|
||||
@@ -351,7 +352,7 @@ class TorrentHelper:
|
||||
添加无效种子
|
||||
"""
|
||||
if url not in self._invalid_torrents:
|
||||
self._invalid_torrents.append(url)
|
||||
self._invalid_torrents[url] = True
|
||||
|
||||
@staticmethod
|
||||
def match_torrent(mediainfo: MediaInfo, torrent_meta: MetaBase, torrent: TorrentInfo) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user