mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-08-29 03:56:43 +08:00
refactor: migrate torrent helper configuration
This commit is contained in:
@@ -8,7 +8,7 @@ from urllib.parse import unquote
|
||||
from torrentool.api import Torrent
|
||||
|
||||
from app.runtime.cache import TTLCache, FileCache
|
||||
from app.runtime.config import settings
|
||||
from app.application.configuration import get_chain_runtime_config_snapshot
|
||||
from app.domain.context import Context, TorrentInfo, MediaInfo
|
||||
from app.domain.meta.metabase import MetaBase
|
||||
from app.domain.meta.metamusic import audio_quality_tier, normalize_audio_format, parse_audio_quality
|
||||
@@ -126,11 +126,12 @@ class TorrentHelper:
|
||||
except Exception as err:
|
||||
logger.error(f"处理缓存的种子文件 {cache_path} 时出错: {err},将重新下载")
|
||||
# 下载种子文件
|
||||
config = get_chain_runtime_config_snapshot()
|
||||
req = RequestUtils(
|
||||
ua=ua,
|
||||
cookies=cookie,
|
||||
referer=referer,
|
||||
proxies=settings.PROXY if proxy else None
|
||||
proxies=config.proxy if proxy else None
|
||||
).get_res(url=url, allow_redirects=False)
|
||||
while req and req.status_code in [301, 302]:
|
||||
url = req.headers['Location']
|
||||
@@ -140,7 +141,7 @@ class TorrentHelper:
|
||||
ua=ua,
|
||||
cookies=cookie,
|
||||
referer=referer,
|
||||
proxies=settings.PROXY if proxy else None
|
||||
proxies=config.proxy if proxy else None
|
||||
).get_res(url=url, allow_redirects=False)
|
||||
if req and req.status_code == 200:
|
||||
if not req.content:
|
||||
@@ -169,7 +170,7 @@ class TorrentHelper:
|
||||
ua=ua,
|
||||
cookies=cookie,
|
||||
referer=referer,
|
||||
proxies=settings.PROXY if proxy else None
|
||||
proxies=config.proxy if proxy else None
|
||||
).post_res(url=action, data=data)
|
||||
if req and req.status_code == 200:
|
||||
# 检查是不是种子文件,如果不是抛出异常
|
||||
@@ -401,11 +402,12 @@ class TorrentHelper:
|
||||
:return: 识别到的全部集数
|
||||
"""
|
||||
episodes = []
|
||||
config = get_chain_runtime_config_snapshot()
|
||||
for file in files:
|
||||
if not file:
|
||||
continue
|
||||
file_path = Path(file)
|
||||
if not file_path.suffix or file_path.suffix.lower() not in settings.RMT_MEDIAEXT:
|
||||
if not file_path.suffix or file_path.suffix.lower() not in config.video_extensions:
|
||||
continue
|
||||
# 只使用文件名识别
|
||||
meta = MetaInfo(file_path.name, custom_words=custom_words)
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"root": "app"
|
||||
},
|
||||
"settings_imports": {
|
||||
"count": 135,
|
||||
"count": 134,
|
||||
"files": [
|
||||
"app/adapters/cache/backends.py",
|
||||
"app/adapters/cache/redis.py",
|
||||
@@ -53,7 +53,6 @@
|
||||
"app/application/security/passkey.py",
|
||||
"app/application/security/token.py",
|
||||
"app/application/security/url.py",
|
||||
"app/application/torrent.py",
|
||||
"app/cli.py",
|
||||
"app/db/base.py",
|
||||
"app/db/engine.py",
|
||||
|
||||
+2
-3
@@ -13,8 +13,8 @@
|
||||
"runtime_to_db": [],
|
||||
"workflow_to_db": []
|
||||
},
|
||||
"edge_count": 6397,
|
||||
"edge_sha256": "801b80e33c626aecf70e5320a2c1c81db401549faa652e718be7386bac593f43",
|
||||
"edge_count": 6396,
|
||||
"edge_sha256": "343715ec8f599f096a45de0dd279d493e7eea7bcde70079f0df0446019578073",
|
||||
"edges": [
|
||||
"app -> app.runtime",
|
||||
"app -> app.runtime.compat",
|
||||
@@ -2787,7 +2787,6 @@
|
||||
"app.application.torrent -> app.foundation.text",
|
||||
"app.application.torrent -> app.runtime",
|
||||
"app.application.torrent -> app.runtime.cache",
|
||||
"app.application.torrent -> app.runtime.config",
|
||||
"app.application.torrent -> app.runtime.log",
|
||||
"app.application.torrent -> app.schemas",
|
||||
"app.application.torrent -> app.schemas.media",
|
||||
|
||||
Reference in New Issue
Block a user