mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 23:47:41 +08:00
refactor: unify module runtime settings
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
from typing import Tuple, Union
|
||||
|
||||
from app.runtime.config import settings
|
||||
from app.application.database import get_database_governance
|
||||
from app.modules import _ModuleBase
|
||||
from app.runtime.settings import RuntimeSettingsCompat
|
||||
from app.schemas.types import ModuleType, OtherModulesType
|
||||
|
||||
settings = RuntimeSettingsCompat()
|
||||
|
||||
|
||||
class PostgreSQLModule(_ModuleBase):
|
||||
"""
|
||||
@@ -12,10 +14,12 @@ class PostgreSQLModule(_ModuleBase):
|
||||
"""
|
||||
|
||||
def init_module(self) -> None:
|
||||
"""PostgreSQL 连接由数据库 adapter 管理,无需模块级初始化。"""
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def get_name() -> str:
|
||||
"""返回模块展示名称。"""
|
||||
return "PostgreSQL"
|
||||
|
||||
@staticmethod
|
||||
@@ -40,9 +44,11 @@ class PostgreSQLModule(_ModuleBase):
|
||||
return 0
|
||||
|
||||
def init_setting(self) -> Tuple[str, Union[str, bool]]:
|
||||
"""数据库类型由部署配置决定,不声明独立模块开关。"""
|
||||
pass
|
||||
|
||||
def stop(self) -> None:
|
||||
"""连接池由数据库生命周期释放,本模块无独立资源。"""
|
||||
pass
|
||||
|
||||
def test(self):
|
||||
|
||||
@@ -4,9 +4,9 @@ from typing import Set, Tuple, Optional, Union, List, Dict
|
||||
from qbittorrentapi import TorrentFilesList
|
||||
|
||||
from app.schemas.dashboard import DownloaderInfo as _SchemaDownloaderInfo
|
||||
from app.runtime.config import settings
|
||||
from app.domain.metainfo import MetaInfo
|
||||
from app.runtime.log import logger
|
||||
from app.runtime.settings import RuntimeSettingsCompat
|
||||
from app.modules._base import _DownloaderModuleBase
|
||||
from app.modules.qbittorrent.qbittorrent import Qbittorrent
|
||||
from app.schemas.transfer import DownloaderTorrent
|
||||
@@ -21,6 +21,8 @@ from app.foundation import size as size_tools
|
||||
from app.foundation import temporal as time_tools
|
||||
from app.foundation import text as text_tools
|
||||
|
||||
settings = RuntimeSettingsCompat()
|
||||
|
||||
_QBITTORRENT_DOWNLOADING_STATES = {
|
||||
"allocating",
|
||||
"checkingdl",
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
from typing import Tuple, Union
|
||||
|
||||
from app.runtime.config import settings
|
||||
from app.adapters.cache.redis import RedisHelper
|
||||
from app.modules import _ModuleBase
|
||||
from app.runtime.settings import RuntimeSettingsCompat
|
||||
from app.schemas.types import ModuleType, OtherModulesType
|
||||
|
||||
settings = RuntimeSettingsCompat()
|
||||
|
||||
|
||||
class RedisModule(_ModuleBase):
|
||||
"""
|
||||
@@ -12,10 +14,12 @@ class RedisModule(_ModuleBase):
|
||||
"""
|
||||
|
||||
def init_module(self) -> None:
|
||||
"""Redis 客户端由缓存 adapter 惰性管理,无需模块级初始化。"""
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def get_name() -> str:
|
||||
"""返回模块展示名称。"""
|
||||
return "Redis缓存"
|
||||
|
||||
@staticmethod
|
||||
@@ -40,9 +44,11 @@ class RedisModule(_ModuleBase):
|
||||
return 0
|
||||
|
||||
def init_setting(self) -> Tuple[str, Union[str, bool]]:
|
||||
"""缓存后端由部署配置决定,不声明独立模块开关。"""
|
||||
pass
|
||||
|
||||
def stop(self) -> None:
|
||||
"""缓存 adapter 负责连接释放,本模块无独立资源。"""
|
||||
pass
|
||||
|
||||
def test(self):
|
||||
|
||||
@@ -2,9 +2,9 @@ from pathlib import Path
|
||||
from typing import Set, Tuple, Optional, Union, List, Dict
|
||||
|
||||
from app.schemas.dashboard import DownloaderInfo as _SchemaDownloaderInfo
|
||||
from app.runtime.config import settings
|
||||
from app.domain.metainfo import MetaInfo
|
||||
from app.runtime.log import logger
|
||||
from app.runtime.settings import RuntimeSettingsCompat
|
||||
from app.modules._base import _DownloaderModuleBase
|
||||
from app.modules.rtorrent.rtorrent import Rtorrent
|
||||
from app.schemas.transfer import DownloaderTorrent
|
||||
@@ -19,8 +19,12 @@ from app.foundation import size as size_tools
|
||||
from app.foundation import temporal as time_tools
|
||||
from app.foundation import text as text_tools
|
||||
|
||||
settings = RuntimeSettingsCompat()
|
||||
|
||||
|
||||
class RtorrentModule(_DownloaderModuleBase[Rtorrent]):
|
||||
"""rTorrent 下载器模块,负责任务添加、标签和文件状态转换。"""
|
||||
|
||||
def init_module(self) -> None:
|
||||
"""
|
||||
初始化模块
|
||||
@@ -31,6 +35,7 @@ class RtorrentModule(_DownloaderModuleBase[Rtorrent]):
|
||||
|
||||
@staticmethod
|
||||
def get_name() -> str:
|
||||
"""返回模块展示名称。"""
|
||||
return "Rtorrent"
|
||||
|
||||
@staticmethod
|
||||
@@ -55,9 +60,11 @@ class RtorrentModule(_DownloaderModuleBase[Rtorrent]):
|
||||
return 3
|
||||
|
||||
def stop(self):
|
||||
"""下载器客户端由服务基类管理,本模块无额外停止动作。"""
|
||||
pass
|
||||
|
||||
def init_setting(self) -> Tuple[str, Union[str, bool]]:
|
||||
"""下载器实例由系统配置管理,不声明独立模块开关。"""
|
||||
pass
|
||||
|
||||
def download(
|
||||
|
||||
@@ -4,9 +4,9 @@ from typing import Set, Tuple, Optional, Union, List, Dict
|
||||
from transmission_rpc import File
|
||||
|
||||
from app.schemas.dashboard import DownloaderInfo as _SchemaDownloaderInfo
|
||||
from app.runtime.config import settings
|
||||
from app.domain.metainfo import MetaInfo
|
||||
from app.runtime.log import logger
|
||||
from app.runtime.settings import RuntimeSettingsCompat
|
||||
from app.modules._base import _DownloaderModuleBase
|
||||
from app.modules.transmission.transmission import Transmission
|
||||
from app.schemas.transfer import DownloaderTorrent
|
||||
@@ -20,6 +20,8 @@ from app.schemas.types import (
|
||||
from app.foundation import size as size_tools
|
||||
from app.foundation import temporal as time_tools
|
||||
|
||||
settings = RuntimeSettingsCompat()
|
||||
|
||||
_TRANSMISSION_DOWNLOADING_STATES = {
|
||||
"download_pending",
|
||||
"downloading",
|
||||
@@ -30,6 +32,7 @@ _TRANSMISSION_PAUSED_STATES = {
|
||||
|
||||
|
||||
class TransmissionModule(_DownloaderModuleBase[Transmission]):
|
||||
"""Transmission 下载器模块,负责任务添加、标签和文件选择。"""
|
||||
|
||||
def init_module(self) -> None:
|
||||
"""
|
||||
@@ -40,6 +43,7 @@ class TransmissionModule(_DownloaderModuleBase[Transmission]):
|
||||
|
||||
@staticmethod
|
||||
def get_name() -> str:
|
||||
"""返回模块展示名称。"""
|
||||
return "Transmission"
|
||||
|
||||
@staticmethod
|
||||
@@ -64,9 +68,11 @@ class TransmissionModule(_DownloaderModuleBase[Transmission]):
|
||||
return 2
|
||||
|
||||
def stop(self):
|
||||
"""下载器客户端由服务基类管理,本模块无额外停止动作。"""
|
||||
pass
|
||||
|
||||
def init_setting(self) -> Tuple[str, Union[str, bool]]:
|
||||
"""下载器实例由系统配置管理,不声明独立模块开关。"""
|
||||
pass
|
||||
|
||||
def download(self, content: Union[Path, str, bytes], download_dir: Path, cookie: str,
|
||||
|
||||
Reference in New Issue
Block a user