mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-04 23:17:20 +08:00
refactor(chain): 处理链功能域 mixin 化,清理未使用导入并根治兼容层循环导入
- ChainBase 拆分为 RecognitionMixin/MessageProcessingMixin/NotificationMixin - TransferChain 拆分为 7 个功能 mixin(_mixins.py),SubscribeChain 音乐订阅域拆出 _music.py - 斜杠命令交互四件套收敛为 InteractionChainMixin 委托,会话管理器移至 application 层,chain 层不再 re-export - 模块基础类收敛到 app/modules/_base(notification/mediaserver 语义重命名) - 清理 app/chain/__init__.py 24 个未使用导入,修正 49 处测试 patch 目标到实际命名空间 - 兼容层 legacy 符号不再并入 __all__,根治 schemas 初始化反向拉起 application.transfer 的循环导入 - 修复 bangumi 集数为字符串时 set_bangumi_info 抛 TypeError - 新增重复代码等架构门禁测试;capability 清单校验排除下划线内部目录
This commit is contained in:
@@ -5,13 +5,16 @@ from app.domain.context import MediaInfo
|
||||
from app.runtime.events import eventmanager
|
||||
from app.application.mediaserver import MusicMediaServerHelper
|
||||
from app.runtime.log import logger
|
||||
from app.modules import _ModuleBase, _MediaServerBase
|
||||
from app.modules._base import _MediaServerModuleBase
|
||||
from app.modules.plex.plex import Plex
|
||||
from app.schemas import AuthCredentials, AuthInterceptCredentials
|
||||
from app.schemas.types import MediaType, ModuleType, ChainEventType, MediaServerType
|
||||
|
||||
|
||||
class PlexModule(_ModuleBase, _MediaServerBase[Plex]):
|
||||
class PlexModule(_MediaServerModuleBase[Plex]):
|
||||
|
||||
# 媒体库标识(ExistMediaInfo.server_type)
|
||||
_server_type_value = "plex"
|
||||
|
||||
def init_module(self) -> None:
|
||||
"""
|
||||
@@ -54,32 +57,17 @@ class PlexModule(_ModuleBase, _MediaServerBase[Plex]):
|
||||
except Exception as err:
|
||||
logger.error(f"停止Plex模块实例失败:{err}")
|
||||
|
||||
def test(self) -> Optional[Tuple[bool, str]]:
|
||||
"""
|
||||
测试模块连接性
|
||||
"""
|
||||
if not self.get_instances():
|
||||
return None
|
||||
for name, server in self.get_instances().items():
|
||||
if server.is_inactive():
|
||||
server.reconnect()
|
||||
if not server.get_librarys():
|
||||
return False, f"无法连接Plex服务器:{name}"
|
||||
return True, ""
|
||||
def _test_server(self, server, name: str) -> Optional[str]:
|
||||
"""Plex 用媒体库列表探测连接状态。"""
|
||||
if server.is_inactive():
|
||||
server.reconnect()
|
||||
if not server.get_librarys():
|
||||
return f"无法连接Plex服务器:{name}"
|
||||
return None
|
||||
|
||||
def init_setting(self) -> Tuple[str, Union[str, bool]]:
|
||||
pass
|
||||
|
||||
def scheduler_job(self) -> None:
|
||||
"""
|
||||
定时任务,每10分钟调用一次
|
||||
"""
|
||||
# 定时重连
|
||||
for name, server in self.get_instances().items():
|
||||
if server.is_inactive():
|
||||
logger.info(f"Plex {name} 服务器连接断开,尝试重连 ...")
|
||||
server.reconnect()
|
||||
|
||||
def user_authenticate(self, credentials: AuthCredentials, service_name: Optional[str] = None) \
|
||||
-> Optional[AuthCredentials]:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user