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:
+8
-13
@@ -4,12 +4,8 @@ from typing import Optional, List
|
||||
from app import schemas
|
||||
from app.chain import ChainBase
|
||||
from app.domain.context import MediaInfo
|
||||
from app.modules.themoviedb.tmdb_cache import TmdbCache
|
||||
from app.modules.themoviedb.tmdbv3api.exceptions import TMDbException
|
||||
from app.schemas import MediaType
|
||||
|
||||
__all__ = ["TmdbChain", "TMDbException"]
|
||||
|
||||
|
||||
class TmdbChain(ChainBase):
|
||||
"""
|
||||
@@ -325,23 +321,22 @@ class TmdbChain(ChainBase):
|
||||
return [info.backdrop_path for info in infos if info and info.backdrop_path][:num]
|
||||
return []
|
||||
|
||||
@staticmethod
|
||||
def cache_items() -> list:
|
||||
def cache_items(self) -> list:
|
||||
"""
|
||||
查询TMDB识别缓存条目列表
|
||||
"""
|
||||
return TmdbCache().list_items()
|
||||
result = self.run_module("tmdb_cache_items")
|
||||
return result or []
|
||||
|
||||
@staticmethod
|
||||
def delete_cache(cache_key: str) -> dict:
|
||||
def delete_cache(self, cache_key: str) -> dict:
|
||||
"""
|
||||
按缓存键删除单条TMDB识别缓存
|
||||
"""
|
||||
return TmdbCache().delete(cache_key)
|
||||
result = self.run_module("tmdb_cache_delete", cache_key=cache_key)
|
||||
return result or {}
|
||||
|
||||
@staticmethod
|
||||
def clear_cache() -> None:
|
||||
def clear_cache(self) -> None:
|
||||
"""
|
||||
清空全部TMDB识别缓存
|
||||
"""
|
||||
TmdbCache().clear()
|
||||
self.run_module("tmdb_cache_clear")
|
||||
|
||||
Reference in New Issue
Block a user