mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 23:47:41 +08:00
refactor(chain): chain 与 module 仅经 run_module 契约互联,实现模块内容封闭
- mTorrent 字幕链接解析下沉为 IndexerModule.site_subtitle_links,subtitle 模块自行跳过 API 站点 - TMDB/MusicBrainz 识别缓存管理改为模块方法(tmdb_cache_*/music_cache_*)经 run_module 分发 - WechatClawBot 客户端查找/临时客户端/缓存迁移内聚为 wechatclawbot_* 模块方法, chain 移除 WechatClawBot 类与 ModuleManager 内省 - LISTENBRAINZ_* 常量迁至 schemas/types.py,模块与链层再导入保持兼容 - TMDbException 升为 schemas/exception.py 跨层契约,vendored 异常保持类身份一致 - 架构守护测试新增 test_chain_does_not_import_module_internals(共 18 项) - 文档同步:chain->module 仅允许 run_module 分发,直接导入禁止
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from datetime import datetime
|
||||
from typing import List, Optional, Tuple, Union
|
||||
|
||||
from app.domain.context import SubtitleInfo, TorrentInfo
|
||||
from app.domain.context import Context, SubtitleInfo, TorrentInfo
|
||||
from app.db.oper.site import SiteOper
|
||||
from app.foundation.reflection import ModuleHelper
|
||||
from app.application.site.sites import SitesHelper # pylint: disable=no-name-in-module
|
||||
@@ -94,6 +94,28 @@ class IndexerModule(_ModuleBase):
|
||||
"""索引模块无需独立开关配置"""
|
||||
pass
|
||||
|
||||
def site_subtitle_links(self, context: Context) -> Optional[List[str]]:
|
||||
"""
|
||||
解析采用API访问的站点的字幕下载链接,非API站点返回None交由页面解析模块处理
|
||||
:param context: 上下文,包括识别信息、媒体信息、种子信息
|
||||
:return: 字幕下载链接列表,不适用时返回None
|
||||
"""
|
||||
torrent = context.torrent_info
|
||||
if torrent.site is None:
|
||||
return None
|
||||
site = SiteOper().get(torrent.site)
|
||||
if not site:
|
||||
return None
|
||||
indexer = SitesHelper().get_indexer(site.domain)
|
||||
if not indexer:
|
||||
return None
|
||||
if indexer.get("parser") == "mTorrent":
|
||||
return MTorrentSpider(indexer).get_subtitle_links(
|
||||
torrent.page_url
|
||||
)
|
||||
# TODO 其它采用API访问的站点
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def __search_check(site: dict, search_word: Optional[str] = None) -> bool:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user