Revert "Merge pull request #5573 from wikrin/refactor-static-methods-conversion"

This reverts commit b8fc20b981, reversing
changes made to e09cfc6704.
This commit is contained in:
jxxghp
2026-03-14 18:21:31 +08:00
parent f38cb274e4
commit 6065c29891
20 changed files with 79 additions and 81 deletions

View File

@@ -230,7 +230,7 @@ class DownloadChain(ChainBase):
return None
# 获取种子文件的文件夹名和文件清单
_folder_name, _file_list = TorrentHelper.get_fileinfo_from_torrent_content(torrent_content)
_folder_name, _file_list = TorrentHelper().get_fileinfo_from_torrent_content(torrent_content)
storage = 'local'
# 下载目录
@@ -238,7 +238,7 @@ class DownloadChain(ChainBase):
download_dir = Path(save_path)
else:
# 根据媒体信息查询下载目录配置
dir_info = DirectoryHelper.get_dir(_media, include_unsorted=True)
dir_info = DirectoryHelper().get_dir(_media, include_unsorted=True)
storage = dir_info.storage if dir_info else storage
# 拼装子目录
if dir_info:
@@ -487,7 +487,7 @@ class DownloadChain(ChainBase):
contexts = event_data.updated_contexts
# 分组排序
contexts = TorrentHelper.sort_group_torrents(contexts)
contexts = TorrentHelper().sort_group_torrents(contexts)
# 如果是电影,直接下载
for context in contexts:
@@ -557,7 +557,7 @@ class DownloadChain(ChainBase):
if isinstance(content, str):
logger.warn(f"{meta.org_string} 下载地址是磁力链,无法确定种子文件集数")
continue
torrent_episodes = TorrentHelper.get_torrent_episodes(torrent_files)
torrent_episodes = TorrentHelper().get_torrent_episodes(torrent_files)
logger.info(f"{meta.org_string} 解析种子文件集数为 {torrent_episodes}")
if not torrent_episodes:
continue
@@ -731,7 +731,7 @@ class DownloadChain(ChainBase):
logger.warn(f"{meta.org_string} 下载地址是磁力链,无法解析种子文件集数")
continue
# 种子全部集
torrent_episodes = TorrentHelper.get_torrent_episodes(torrent_files)
torrent_episodes = TorrentHelper().get_torrent_episodes(torrent_files)
logger.info(f"{torrent.site_name} - {meta.org_string} 解析种子文件集数:{torrent_episodes}")
# 选中的集
selected_episodes = set(torrent_episodes).intersection(set(need_episodes))

View File

@@ -274,7 +274,7 @@ class MessageChain(ChainBase):
userid=userid))
return
# 搜索结果排序
contexts = TorrentHelper.sort_torrents(contexts)
contexts = TorrentHelper().sort_torrents(contexts)
try:
# 判断是否设置自动下载
auto_download_user = settings.AUTO_DOWNLOAD_USER

View File

@@ -236,7 +236,7 @@ class SearchChain(ChainBase):
# 匹配订阅附加参数
if filter_params:
logger.info(f'开始附加参数过滤,附加参数:{filter_params} ...')
torrents = [torrent for torrent in torrents if TorrentHelper.filter_torrent(torrent, filter_params)]
torrents = [torrent for torrent in torrents if TorrentHelper().filter_torrent(torrent, filter_params)]
# 开始过滤规则过滤
if rule_groups is None:
# 取搜索过滤规则
@@ -259,6 +259,7 @@ class SearchChain(ChainBase):
# 开始匹配
_match_torrents = []
torrenthelper = TorrentHelper()
try:
# 英文标题应该在别名/原标题中,不需要再匹配
logger.info(f"开始匹配结果 标题:{mediainfo.title},原标题:{mediainfo.original_title},别名:{mediainfo.names}")
@@ -292,7 +293,7 @@ class SearchChain(ChainBase):
continue
# 比对种子
if TorrentHelper.match_torrent(mediainfo=mediainfo,
if torrenthelper.match_torrent(mediainfo=mediainfo,
torrent_meta=torrent_meta,
torrent=torrent):
# 匹配成功
@@ -318,7 +319,7 @@ class SearchChain(ChainBase):
# 排序
progress.update(value=99,
text=f'正在对 {len(contexts)} 个资源进行排序,请稍候...')
contexts = TorrentHelper.sort_torrents(contexts)
contexts = torrenthelper.sort_torrents(contexts)
# 结束进度
logger.info(f'搜索完成,共 {len(contexts)} 个资源')

View File

@@ -196,7 +196,7 @@ class StorageChain(ChainBase):
associated_dir = max(
(
Path(p)
for d in DirectoryHelper.get_dirs()
for d in DirectoryHelper().get_dirs()
for p in (d.download_path, d.library_path)
if p and fileitem_path.is_relative_to(p)
),

View File

@@ -875,6 +875,7 @@ class SubscribeChain(ChainBase):
# 遍历预识别后的种子
_match_context = []
torrenthelper = TorrentHelper()
systemconfig = SystemConfigOper()
wordsmatcher = WordsMatcher()
for domain, contexts in processed_torrents.items():
@@ -925,7 +926,7 @@ class SubscribeChain(ChainBase):
not torrent_mediainfo.tmdb_id and not torrent_mediainfo.douban_id):
logger.debug(
f'{torrent_info.site_name} - {torrent_info.title} 重新识别失败,尝试通过标题匹配...')
if TorrentHelper.match_torrent(mediainfo=mediainfo,
if torrenthelper.match_torrent(mediainfo=mediainfo,
torrent_meta=torrent_meta,
torrent=torrent_info):
# 匹配成功
@@ -991,7 +992,7 @@ class SubscribeChain(ChainBase):
continue
# 匹配订阅附加参数
if not TorrentHelper.filter_torrent(torrent_info=torrent_info,
if not torrenthelper.filter_torrent(torrent_info=torrent_info,
filter_params=self.get_params(subscribe)):
continue

View File

@@ -210,12 +210,11 @@ class TorrentsChain(ChainBase):
# 读取缓存
torrents_cache = self.get_torrents()
torrenthelper = TorrentHelper()
# 缓存过滤掉无效种子
for _domain, _torrents in torrents_cache.items():
torrents_cache[_domain] = [_torrent for _torrent in _torrents
if not torrenthelper.is_invalid(_torrent.torrent_info.enclosure)]
if not TorrentHelper().is_invalid(_torrent.torrent_info.enclosure)]
# 需要刷新的站点domain
domains = []

View File

@@ -988,12 +988,12 @@ class TransferChain(ChainBase, ConfigReloadMixin, metaclass=Singleton):
if not task.target_directory:
if task.target_path:
# 指定目标路径,`手动整理`场景下使用,忽略源目录匹配,使用指定目录匹配
task.target_directory = DirectoryHelper.get_dir(media=task.mediainfo,
task.target_directory = DirectoryHelper().get_dir(media=task.mediainfo,
dest_path=task.target_path,
target_storage=task.target_storage)
else:
# 启用源目录匹配时,根据源目录匹配下载目录,否则按源目录同盘优先原则,如无源目录,则根据媒体信息获取目标目录
task.target_directory = DirectoryHelper.get_dir(media=task.mediainfo,
task.target_directory = DirectoryHelper().get_dir(media=task.mediainfo,
storage=task.fileitem.storage,
src_path=Path(task.fileitem.path),
target_storage=task.target_storage)
@@ -1077,7 +1077,7 @@ class TransferChain(ChainBase, ConfigReloadMixin, metaclass=Singleton):
# 全局锁,避免定时服务重复
with downloader_lock:
# 获取下载器监控目录
download_dirs = DirectoryHelper.get_download_dirs()
download_dirs = DirectoryHelper().get_download_dirs()
# 如果没有下载器监控的目录则不处理
if not any(dir_info.monitor_type == "downloader" and dir_info.storage == "local"