mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-04-13 12:59:52 +08:00
add ModuleType Schema
This commit is contained in:
@@ -5,7 +5,7 @@ from app.core.config import settings
|
||||
from app.core.event import eventmanager
|
||||
from app.helper.module import ModuleHelper
|
||||
from app.log import logger
|
||||
from app.schemas.types import EventType
|
||||
from app.schemas.types import EventType, ModuleType
|
||||
from app.utils.object import ObjectUtils
|
||||
from app.utils.singleton import Singleton
|
||||
|
||||
@@ -124,6 +124,17 @@ class ModuleManager(metaclass=Singleton):
|
||||
and ObjectUtils.check_method(getattr(module, method)):
|
||||
yield module
|
||||
|
||||
def get_running_type_modules(self, module_type: ModuleType) -> Generator:
|
||||
"""
|
||||
获取指定类型的模块列表
|
||||
"""
|
||||
if not self._running_modules:
|
||||
return []
|
||||
for _, module in self._running_modules.items():
|
||||
if hasattr(module, 'get_type') \
|
||||
and module.get_type() == module_type:
|
||||
yield module
|
||||
|
||||
def get_module(self, module_id: str) -> Any:
|
||||
"""
|
||||
根据模块id获取模块
|
||||
|
||||
@@ -2,7 +2,7 @@ from typing import Optional
|
||||
|
||||
from app.helper.servicebase import ServiceBaseHelper
|
||||
from app.schemas import DownloaderConf, ServiceInfo
|
||||
from app.schemas.types import SystemConfigKey
|
||||
from app.schemas.types import SystemConfigKey, ModuleType
|
||||
|
||||
|
||||
class DownloaderHelper(ServiceBaseHelper[DownloaderConf]):
|
||||
@@ -14,29 +14,24 @@ class DownloaderHelper(ServiceBaseHelper[DownloaderConf]):
|
||||
super().__init__(
|
||||
config_key=SystemConfigKey.Downloaders,
|
||||
conf_type=DownloaderConf,
|
||||
modules=["QbittorrentModule", "TransmissionModule"]
|
||||
module_type=ModuleType.Downloader
|
||||
)
|
||||
|
||||
def is_qbittorrent(self, service: Optional[ServiceInfo] = None, name: Optional[str] = None) -> bool:
|
||||
def is_downloader(
|
||||
self,
|
||||
service_type: Optional[str] = None,
|
||||
service: Optional[ServiceInfo] = None,
|
||||
name: Optional[str] = None,
|
||||
) -> bool:
|
||||
"""
|
||||
判断指定的下载器是否为 qbittorrent 类型,需要传入 `service` 或 `name` 中的任一参数
|
||||
|
||||
通用的下载器类型判断方法
|
||||
:param service_type: 下载器的类型名称(如 'qbittorrent', 'transmission')
|
||||
:param service: 要判断的服务信息
|
||||
:param name: 服务的名称
|
||||
:return: 如果服务类型为 qbittorrent,返回 True;否则返回 False。
|
||||
:return: 如果服务类型或实例为指定类型,返回 True;否则返回 False
|
||||
"""
|
||||
if not service:
|
||||
service = self.get_service(name=name)
|
||||
return service.type == "qbittorrent" if service else False
|
||||
# 如果未提供 service 则通过 name 获取服务
|
||||
service = service or self.get_service(name=name)
|
||||
|
||||
def is_transmission(self, service: Optional[ServiceInfo] = None, name: Optional[str] = None) -> bool:
|
||||
"""
|
||||
判断指定的下载器是否为 transmission 类型,需要传入 `service` 或 `name` 中的任一参数
|
||||
|
||||
:param service: 要判断的服务信息
|
||||
:param name: 服务的名称
|
||||
:return: 如果服务类型为 transmission,返回 True;否则返回 False。
|
||||
"""
|
||||
if not service:
|
||||
service = self.get_service(name=name)
|
||||
return service.type == "transmission" if service else False
|
||||
# 判断服务类型是否为指定类型
|
||||
return bool(service and service.type == service_type)
|
||||
|
||||
@@ -2,7 +2,7 @@ from typing import Optional
|
||||
|
||||
from app.helper.servicebase import ServiceBaseHelper
|
||||
from app.schemas import MediaServerConf, ServiceInfo
|
||||
from app.schemas.types import SystemConfigKey
|
||||
from app.schemas.types import SystemConfigKey, ModuleType
|
||||
|
||||
|
||||
class MediaServerHelper(ServiceBaseHelper[MediaServerConf]):
|
||||
@@ -14,41 +14,24 @@ class MediaServerHelper(ServiceBaseHelper[MediaServerConf]):
|
||||
super().__init__(
|
||||
config_key=SystemConfigKey.MediaServers,
|
||||
conf_type=MediaServerConf,
|
||||
modules=["PlexModule", "EmbyModule", "JellyfinModule"]
|
||||
module_type=ModuleType.MediaServer
|
||||
)
|
||||
|
||||
def is_plex(self, service: Optional[ServiceInfo] = None, name: Optional[str] = None) -> bool:
|
||||
def is_media_server(
|
||||
self,
|
||||
service_type: Optional[str] = None,
|
||||
service: Optional[ServiceInfo] = None,
|
||||
name: Optional[str] = None,
|
||||
) -> bool:
|
||||
"""
|
||||
判断指定的媒体服务器是否为 Plex 类型,需要传入 `service` 或 `name` 中的任一参数
|
||||
|
||||
通用的媒体服务器类型判断方法
|
||||
:param service_type: 媒体服务器的类型名称(如 'plex', 'emby', 'jellyfin')
|
||||
:param service: 要判断的服务信息
|
||||
:param name: 服务的名称
|
||||
:return: 如果服务类型为 plex,返回 True;否则返回 False。
|
||||
:return: 如果服务类型或实例为指定类型,返回 True;否则返回 False
|
||||
"""
|
||||
if not service:
|
||||
service = self.get_service(name=name)
|
||||
return service.type == "plex" if service else False
|
||||
# 如果未提供 service 则通过 name 获取服务
|
||||
service = service or self.get_service(name=name)
|
||||
|
||||
def is_emby(self, service: Optional[ServiceInfo] = None, name: Optional[str] = None) -> bool:
|
||||
"""
|
||||
判断指定的媒体服务器是否为 Emby 类型,需要传入 `service` 或 `name` 中的任一参数
|
||||
|
||||
:param service: 要判断的服务信息
|
||||
:param name: 服务的名称
|
||||
:return: 如果服务类型为 emby,返回 True;否则返回 False。
|
||||
"""
|
||||
if not service:
|
||||
service = self.get_service(name=name)
|
||||
return service.type == "emby" if service else False
|
||||
|
||||
def is_jellyfin(self, service: Optional[ServiceInfo] = None, name: Optional[str] = None) -> bool:
|
||||
"""
|
||||
判断指定的媒体服务器是否为 Jellyfin 类型,需要传入 `service` 或 `name` 中的任一参数
|
||||
|
||||
:param service: 要判断的服务信息
|
||||
:param name: 服务的名称
|
||||
:return: 如果服务类型为 jellyfin,返回 True;否则返回 False。
|
||||
"""
|
||||
if not service:
|
||||
service = self.get_service(name=name)
|
||||
return service.type == "jellyfin" if service else False
|
||||
# 判断服务类型是否为指定类型
|
||||
return bool(service and service.type == service_type)
|
||||
|
||||
@@ -2,7 +2,7 @@ from typing import Optional
|
||||
|
||||
from app.helper.servicebase import ServiceBaseHelper
|
||||
from app.schemas import NotificationConf, ServiceInfo
|
||||
from app.schemas.types import SystemConfigKey
|
||||
from app.schemas.types import SystemConfigKey, ModuleType
|
||||
|
||||
|
||||
class NotificationHelper(ServiceBaseHelper[NotificationConf]):
|
||||
@@ -14,84 +14,25 @@ class NotificationHelper(ServiceBaseHelper[NotificationConf]):
|
||||
super().__init__(
|
||||
config_key=SystemConfigKey.Notifications,
|
||||
conf_type=NotificationConf,
|
||||
modules=[
|
||||
"WechatModule",
|
||||
"WebPushModule",
|
||||
"VoceChatModule",
|
||||
"TelegramModule",
|
||||
"SynologyChatModule",
|
||||
"SlackModule"
|
||||
]
|
||||
module_type=ModuleType.Notification
|
||||
)
|
||||
|
||||
def is_wechat(self, service: Optional[ServiceInfo] = None, name: Optional[str] = None) -> bool:
|
||||
def is_notification(
|
||||
self,
|
||||
service_type: Optional[str] = None,
|
||||
service: Optional[ServiceInfo] = None,
|
||||
name: Optional[str] = None,
|
||||
) -> bool:
|
||||
"""
|
||||
判断指定的消息通知服务是否为 Wechat 类型,需要传入 `service` 或 `name` 中的任一参数
|
||||
通用的消息通知服务类型判断方法
|
||||
|
||||
:param service_type: 消息通知服务的类型名称(如 'wechat', 'voicechat', 'telegram', 等)
|
||||
:param service: 要判断的服务信息
|
||||
:param name: 服务的名称
|
||||
:return: 如果服务类型为 wechat,返回 True;否则返回 False。
|
||||
:return: 如果服务类型或实例为指定类型,返回 True;否则返回 False
|
||||
"""
|
||||
if not service:
|
||||
service = self.get_service(name=name)
|
||||
return service.type == "wechat" if service else False
|
||||
# 如果未提供 service 则通过 name 获取服务
|
||||
service = service or self.get_service(name=name)
|
||||
|
||||
def is_webpush(self, service: Optional[ServiceInfo] = None, name: Optional[str] = None) -> bool:
|
||||
"""
|
||||
判断指定的消息通知服务是否为 WebPush 类型,需要传入 `service` 或 `name` 中的任一参数
|
||||
|
||||
:param service: 要判断的服务信息
|
||||
:param name: 服务的名称
|
||||
:return: 如果服务类型为 webpush,返回 True;否则返回 False。
|
||||
"""
|
||||
if not service:
|
||||
service = self.get_service(name=name)
|
||||
return service.type == "webpush" if service else False
|
||||
|
||||
def is_voicechat(self, service: Optional[ServiceInfo] = None, name: Optional[str] = None) -> bool:
|
||||
"""
|
||||
判断指定的消息通知服务是否为 VoiceChat 类型,需要传入 `service` 或 `name` 中的任一参数
|
||||
|
||||
:param service: 要判断的服务信息
|
||||
:param name: 服务的名称
|
||||
:return: 如果服务类型为 voicechat,返回 True;否则返回 False。
|
||||
"""
|
||||
if not service:
|
||||
service = self.get_service(name=name)
|
||||
return service.type == "voicechat" if service else False
|
||||
|
||||
def is_telegram(self, service: Optional[ServiceInfo] = None, name: Optional[str] = None) -> bool:
|
||||
"""
|
||||
判断指定的消息通知服务是否为 Telegram 类型,需要传入 `service` 或 `name` 中的任一参数
|
||||
|
||||
:param service: 要判断的服务信息
|
||||
:param name: 服务的名称
|
||||
:return: 如果服务类型为 telegram,返回 True;否则返回 False。
|
||||
"""
|
||||
if not service:
|
||||
service = self.get_service(name=name)
|
||||
return service.type == "telegram" if service else False
|
||||
|
||||
def is_synologychat(self, service: Optional[ServiceInfo] = None, name: Optional[str] = None) -> bool:
|
||||
"""
|
||||
判断指定的消息通知服务是否为 SynologyChat 类型,需要传入 `service` 或 `name` 中的任一参数
|
||||
|
||||
:param service: 要判断的服务信息
|
||||
:param name: 服务的名称
|
||||
:return: 如果服务类型为 synologychat,返回 True;否则返回 False。
|
||||
"""
|
||||
if not service:
|
||||
service = self.get_service(name=name)
|
||||
return service.type == "synologychat" if service else False
|
||||
|
||||
def is_slack(self, service: Optional[ServiceInfo] = None, name: Optional[str] = None) -> bool:
|
||||
"""
|
||||
判断指定的消息通知服务是否为 Slack 类型,需要传入 `service` 或 `name` 中的任一参数
|
||||
|
||||
:param service: 要判断的服务信息
|
||||
:param name: 服务的名称
|
||||
:return: 如果服务类型为 slack,返回 True;否则返回 False。
|
||||
"""
|
||||
if not service:
|
||||
service = self.get_service(name=name)
|
||||
return service.type == "slack" if service else False
|
||||
# 判断服务类型是否为指定类型
|
||||
return bool(service and service.type == service_type)
|
||||
|
||||
@@ -3,7 +3,7 @@ from typing import Dict, List, Optional, Type, TypeVar, Generic, Iterator
|
||||
from app.core.module import ModuleManager
|
||||
from app.helper.serviceconfig import ServiceConfigHelper
|
||||
from app.schemas import ServiceInfo
|
||||
from app.schemas.types import SystemConfigKey
|
||||
from app.schemas.types import SystemConfigKey, ModuleType
|
||||
|
||||
TConf = TypeVar("TConf")
|
||||
|
||||
@@ -13,11 +13,11 @@ class ServiceBaseHelper(Generic[TConf]):
|
||||
通用服务帮助类,抽象获取配置和服务实例的通用逻辑
|
||||
"""
|
||||
|
||||
def __init__(self, config_key: SystemConfigKey, conf_type: Type[TConf], modules: List[str]):
|
||||
def __init__(self, config_key: SystemConfigKey, conf_type: Type[TConf], module_type: ModuleType):
|
||||
self.modulemanager = ModuleManager()
|
||||
self.config_key = config_key
|
||||
self.conf_type = conf_type
|
||||
self.modules = modules
|
||||
self.module_type = module_type
|
||||
|
||||
def get_configs(self, include_disabled: bool = False) -> Dict[str, TConf]:
|
||||
"""
|
||||
@@ -47,8 +47,8 @@ class ServiceBaseHelper(Generic[TConf]):
|
||||
迭代所有模块的实例及其对应的配置,返回 ServiceInfo 实例
|
||||
"""
|
||||
configs = self.get_configs()
|
||||
for module_name in self.modules:
|
||||
module = self.modulemanager.get_running_module(module_name)
|
||||
modules = self.modulemanager.get_running_type_modules(self.module_type)
|
||||
for module in modules:
|
||||
if not module:
|
||||
continue
|
||||
module_instances = module.get_instances()
|
||||
@@ -81,9 +81,10 @@ class ServiceBaseHelper(Generic[TConf]):
|
||||
return {
|
||||
service_info.name: service_info
|
||||
for service_info in self.iterate_module_instances()
|
||||
if service_info.config and
|
||||
(type_filter is None or service_info.type == type_filter) and
|
||||
(name_filters_set is None or service_info.name in name_filters_set)
|
||||
if service_info.config and (
|
||||
type_filter is None or service_info.type == type_filter
|
||||
) and (
|
||||
name_filters_set is None or service_info.name in name_filters_set)
|
||||
}
|
||||
|
||||
def get_service(self, name: str, type_filter: Optional[str] = None) -> Optional[ServiceInfo]:
|
||||
|
||||
@@ -3,6 +3,7 @@ from typing import Generic, Tuple, Union, TypeVar, Type, Dict, Optional, Callabl
|
||||
|
||||
from app.helper.serviceconfig import ServiceConfigHelper
|
||||
from app.schemas import Notification, MessageChannel, NotificationConf, MediaServerConf, DownloaderConf
|
||||
from app.schemas.types import ModuleType
|
||||
|
||||
|
||||
class _ModuleBase(metaclass=ABCMeta):
|
||||
@@ -34,6 +35,14 @@ class _ModuleBase(metaclass=ABCMeta):
|
||||
"""
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
@abstractmethod
|
||||
def get_type() -> ModuleType:
|
||||
"""
|
||||
获取模块类型
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def stop(self) -> None:
|
||||
"""
|
||||
|
||||
@@ -7,6 +7,7 @@ from app.core.meta import MetaBase
|
||||
from app.log import logger
|
||||
from app.modules import _ModuleBase
|
||||
from app.modules.bangumi.bangumi import BangumiApi
|
||||
from app.schemas.types import ModuleType
|
||||
from app.utils.http import RequestUtils
|
||||
|
||||
|
||||
@@ -35,7 +36,14 @@ class BangumiModule(_ModuleBase):
|
||||
|
||||
@staticmethod
|
||||
def get_name() -> str:
|
||||
return "Bangumi"
|
||||
return "Bangumi"@staticmethod
|
||||
|
||||
@staticmethod
|
||||
def get_type() -> ModuleType:
|
||||
"""
|
||||
获取模块类型
|
||||
"""
|
||||
return ModuleType.MediaRecognize
|
||||
|
||||
def recognize_media(self, bangumiid: int = None,
|
||||
**kwargs) -> Optional[MediaInfo]:
|
||||
|
||||
@@ -14,7 +14,7 @@ from app.modules.douban.apiv2 import DoubanApi
|
||||
from app.modules.douban.douban_cache import DoubanCache
|
||||
from app.modules.douban.scraper import DoubanScraper
|
||||
from app.schemas import MediaPerson, APIRateLimitException
|
||||
from app.schemas.types import MediaType
|
||||
from app.schemas.types import MediaType, ModuleType
|
||||
from app.utils.common import retry
|
||||
from app.utils.http import RequestUtils
|
||||
from app.utils.limit import rate_limit_exponential
|
||||
@@ -51,6 +51,13 @@ class DoubanModule(_ModuleBase):
|
||||
def get_name() -> str:
|
||||
return "豆瓣"
|
||||
|
||||
@staticmethod
|
||||
def get_type() -> ModuleType:
|
||||
"""
|
||||
获取模块类型
|
||||
"""
|
||||
return ModuleType.MediaRecognize
|
||||
|
||||
def recognize_media(self, meta: MetaBase = None,
|
||||
mtype: MediaType = None,
|
||||
doubanid: str = None,
|
||||
|
||||
@@ -5,7 +5,6 @@ from app.core.context import MediaInfo
|
||||
from app.log import logger
|
||||
from app.modules import _ModuleBase, _MediaServerBase
|
||||
from app.modules.emby.emby import Emby
|
||||
from app.schemas import MediaServerConf
|
||||
from app.schemas.types import MediaType
|
||||
|
||||
|
||||
@@ -22,6 +21,10 @@ class EmbyModule(_ModuleBase, _MediaServerBase[Emby]):
|
||||
def get_name() -> str:
|
||||
return "Emby"
|
||||
|
||||
@staticmethod
|
||||
def get_type() -> str:
|
||||
return "mediaserver"
|
||||
|
||||
def stop(self):
|
||||
pass
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ from app.core.context import MediaInfo, settings
|
||||
from app.log import logger
|
||||
from app.modules import _ModuleBase
|
||||
from app.utils.http import RequestUtils
|
||||
from app.schemas.types import MediaType
|
||||
from app.schemas.types import MediaType, ModuleType
|
||||
|
||||
|
||||
class FanartModule(_ModuleBase):
|
||||
@@ -335,6 +335,13 @@ class FanartModule(_ModuleBase):
|
||||
def get_name() -> str:
|
||||
return "Fanart"
|
||||
|
||||
@staticmethod
|
||||
def get_type() -> ModuleType:
|
||||
"""
|
||||
获取模块类型
|
||||
"""
|
||||
return ModuleType.Other
|
||||
|
||||
def obtain_images(self, mediainfo: MediaInfo) -> Optional[MediaInfo]:
|
||||
"""
|
||||
获取图片
|
||||
|
||||
@@ -17,7 +17,7 @@ from app.log import logger
|
||||
from app.modules import _ModuleBase
|
||||
from app.modules.filemanager.storages import StorageBase
|
||||
from app.schemas import TransferInfo, ExistMediaInfo, TmdbEpisode, TransferDirectoryConf, FileItem, StorageUsage
|
||||
from app.schemas.types import MediaType
|
||||
from app.schemas.types import MediaType, ModuleType
|
||||
from app.utils.system import SystemUtils
|
||||
|
||||
lock = Lock()
|
||||
@@ -44,6 +44,13 @@ class FileManagerModule(_ModuleBase):
|
||||
def get_name() -> str:
|
||||
return "文件整理"
|
||||
|
||||
@staticmethod
|
||||
def get_type() -> ModuleType:
|
||||
"""
|
||||
获取模块类型
|
||||
"""
|
||||
return ModuleType.Other
|
||||
|
||||
def stop(self):
|
||||
pass
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ from app.helper.rule import RuleHelper
|
||||
from app.log import logger
|
||||
from app.modules import _ModuleBase
|
||||
from app.modules.filter.RuleParser import RuleParser
|
||||
from app.schemas.types import ModuleType
|
||||
from app.utils.string import StringUtils
|
||||
|
||||
|
||||
@@ -159,6 +160,13 @@ class FilterModule(_ModuleBase):
|
||||
def get_name() -> str:
|
||||
return "过滤器"
|
||||
|
||||
@staticmethod
|
||||
def get_type() -> ModuleType:
|
||||
"""
|
||||
获取模块类型
|
||||
"""
|
||||
return ModuleType.Other
|
||||
|
||||
def stop(self):
|
||||
pass
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ from app.modules.indexer.spider.tnode import TNodeSpider
|
||||
from app.modules.indexer.spider.torrentleech import TorrentLeech
|
||||
from app.modules.indexer.spider.yema import YemaSpider
|
||||
from app.schemas import SiteUserData
|
||||
from app.schemas.types import MediaType
|
||||
from app.schemas.types import MediaType, ModuleType
|
||||
from app.utils.string import StringUtils
|
||||
|
||||
|
||||
@@ -40,6 +40,13 @@ class IndexerModule(_ModuleBase):
|
||||
def get_name() -> str:
|
||||
return "站点索引"
|
||||
|
||||
@staticmethod
|
||||
def get_type() -> ModuleType:
|
||||
"""
|
||||
获取模块类型
|
||||
"""
|
||||
return ModuleType.Indexer
|
||||
|
||||
def stop(self):
|
||||
pass
|
||||
|
||||
|
||||
@@ -5,8 +5,7 @@ from app.core.context import MediaInfo
|
||||
from app.log import logger
|
||||
from app.modules import _ModuleBase, _MediaServerBase
|
||||
from app.modules.jellyfin.jellyfin import Jellyfin
|
||||
from app.schemas import MediaServerConf
|
||||
from app.schemas.types import MediaType
|
||||
from app.schemas.types import MediaType, ModuleType
|
||||
|
||||
|
||||
class JellyfinModule(_ModuleBase, _MediaServerBase[Jellyfin]):
|
||||
@@ -22,6 +21,13 @@ class JellyfinModule(_ModuleBase, _MediaServerBase[Jellyfin]):
|
||||
def get_name() -> str:
|
||||
return "Jellyfin"
|
||||
|
||||
@staticmethod
|
||||
def get_type() -> ModuleType:
|
||||
"""
|
||||
获取模块类型
|
||||
"""
|
||||
return ModuleType.MediaServer
|
||||
|
||||
def init_setting(self) -> Tuple[str, Union[str, bool]]:
|
||||
pass
|
||||
|
||||
|
||||
@@ -5,8 +5,7 @@ from app.core.context import MediaInfo
|
||||
from app.log import logger
|
||||
from app.modules import _ModuleBase, _MediaServerBase
|
||||
from app.modules.plex.plex import Plex
|
||||
from app.schemas import MediaServerConf
|
||||
from app.schemas.types import MediaType
|
||||
from app.schemas.types import MediaType, ModuleType
|
||||
|
||||
|
||||
class PlexModule(_ModuleBase, _MediaServerBase[Plex]):
|
||||
@@ -22,6 +21,13 @@ class PlexModule(_ModuleBase, _MediaServerBase[Plex]):
|
||||
def get_name() -> str:
|
||||
return "Plex"
|
||||
|
||||
@staticmethod
|
||||
def get_type() -> ModuleType:
|
||||
"""
|
||||
获取模块类型
|
||||
"""
|
||||
return ModuleType.MediaServer
|
||||
|
||||
def stop(self):
|
||||
pass
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ from app.log import logger
|
||||
from app.modules import _ModuleBase, _DownloaderBase
|
||||
from app.modules.qbittorrent.qbittorrent import Qbittorrent
|
||||
from app.schemas import TransferTorrent, DownloadingTorrent
|
||||
from app.schemas.types import TorrentStatus
|
||||
from app.schemas.types import TorrentStatus, ModuleType
|
||||
from app.utils.string import StringUtils
|
||||
from app.utils.system import SystemUtils
|
||||
|
||||
@@ -30,6 +30,13 @@ class QbittorrentModule(_ModuleBase, _DownloaderBase[Qbittorrent]):
|
||||
def get_name() -> str:
|
||||
return "Qbittorrent"
|
||||
|
||||
@staticmethod
|
||||
def get_type() -> ModuleType:
|
||||
"""
|
||||
获取模块类型
|
||||
"""
|
||||
return ModuleType.Downloader
|
||||
|
||||
def stop(self):
|
||||
pass
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ from app.log import logger
|
||||
from app.modules import _ModuleBase, _MessageBase
|
||||
from app.modules.slack.slack import Slack
|
||||
from app.schemas import MessageChannel, CommingMessage, Notification
|
||||
from app.schemas.types import ModuleType
|
||||
|
||||
|
||||
class SlackModule(_ModuleBase, _MessageBase[Slack]):
|
||||
@@ -23,6 +24,13 @@ class SlackModule(_ModuleBase, _MessageBase[Slack]):
|
||||
def get_name() -> str:
|
||||
return "Slack"
|
||||
|
||||
@staticmethod
|
||||
def get_type() -> ModuleType:
|
||||
"""
|
||||
获取模块类型
|
||||
"""
|
||||
return ModuleType.Notification
|
||||
|
||||
def stop(self):
|
||||
"""
|
||||
停止模块
|
||||
|
||||
@@ -10,6 +10,7 @@ from app.core.context import Context
|
||||
from app.helper.torrent import TorrentHelper
|
||||
from app.log import logger
|
||||
from app.modules import _ModuleBase
|
||||
from app.schemas.types import ModuleType
|
||||
from app.utils.http import RequestUtils
|
||||
from app.utils.string import StringUtils
|
||||
from app.utils.system import SystemUtils
|
||||
@@ -32,6 +33,13 @@ class SubtitleModule(_ModuleBase):
|
||||
def get_name() -> str:
|
||||
return "站点字幕"
|
||||
|
||||
@staticmethod
|
||||
def get_type() -> ModuleType:
|
||||
"""
|
||||
获取模块类型
|
||||
"""
|
||||
return ModuleType.Other
|
||||
|
||||
def init_setting(self) -> Tuple[str, Union[str, bool]]:
|
||||
pass
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ from app.log import logger
|
||||
from app.modules import _ModuleBase, _MessageBase
|
||||
from app.modules.synologychat.synologychat import SynologyChat
|
||||
from app.schemas import MessageChannel, CommingMessage, Notification
|
||||
from app.schemas.types import ModuleType
|
||||
|
||||
|
||||
class SynologyChatModule(_ModuleBase, _MessageBase[SynologyChat]):
|
||||
@@ -20,6 +21,13 @@ class SynologyChatModule(_ModuleBase, _MessageBase[SynologyChat]):
|
||||
def get_name() -> str:
|
||||
return "Synology Chat"
|
||||
|
||||
@staticmethod
|
||||
def get_type() -> ModuleType:
|
||||
"""
|
||||
获取模块类型
|
||||
"""
|
||||
return ModuleType.Notification
|
||||
|
||||
def stop(self):
|
||||
pass
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ from app.log import logger
|
||||
from app.modules import _ModuleBase, _MessageBase
|
||||
from app.modules.telegram.telegram import Telegram
|
||||
from app.schemas import MessageChannel, CommingMessage, Notification
|
||||
from app.schemas.types import ModuleType
|
||||
|
||||
|
||||
class TelegramModule(_ModuleBase, _MessageBase[Telegram]):
|
||||
@@ -22,6 +23,13 @@ class TelegramModule(_ModuleBase, _MessageBase[Telegram]):
|
||||
def get_name() -> str:
|
||||
return "Telegram"
|
||||
|
||||
@staticmethod
|
||||
def get_type() -> ModuleType:
|
||||
"""
|
||||
获取模块类型
|
||||
"""
|
||||
return ModuleType.Notification
|
||||
|
||||
def stop(self):
|
||||
"""
|
||||
停止模块
|
||||
|
||||
@@ -13,7 +13,7 @@ from app.modules.themoviedb.scraper import TmdbScraper
|
||||
from app.modules.themoviedb.tmdb_cache import TmdbCache
|
||||
from app.modules.themoviedb.tmdbapi import TmdbApi
|
||||
from app.schemas import MediaPerson
|
||||
from app.schemas.types import MediaType, MediaImageType
|
||||
from app.schemas.types import MediaType, MediaImageType, ModuleType
|
||||
from app.utils.http import RequestUtils
|
||||
|
||||
|
||||
@@ -41,6 +41,13 @@ class TheMovieDbModule(_ModuleBase):
|
||||
def get_name() -> str:
|
||||
return "TheMovieDb"
|
||||
|
||||
@staticmethod
|
||||
def get_type() -> ModuleType:
|
||||
"""
|
||||
获取模块类型
|
||||
"""
|
||||
return ModuleType.MediaRecognize
|
||||
|
||||
def stop(self):
|
||||
self.cache.save()
|
||||
self.tmdb.close()
|
||||
|
||||
@@ -4,6 +4,7 @@ from app.core.config import settings
|
||||
from app.log import logger
|
||||
from app.modules import _ModuleBase
|
||||
from app.modules.thetvdb import tvdbapi
|
||||
from app.schemas.types import ModuleType
|
||||
from app.utils.http import RequestUtils
|
||||
|
||||
|
||||
@@ -20,6 +21,13 @@ class TheTvDbModule(_ModuleBase):
|
||||
def get_name() -> str:
|
||||
return "TheTvDb"
|
||||
|
||||
@staticmethod
|
||||
def get_type() -> ModuleType:
|
||||
"""
|
||||
获取模块类型
|
||||
"""
|
||||
return ModuleType.MediaRecognize
|
||||
|
||||
def stop(self):
|
||||
self.tvdb.close()
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ from app.log import logger
|
||||
from app.modules import _ModuleBase, _DownloaderBase
|
||||
from app.modules.transmission.transmission import Transmission
|
||||
from app.schemas import TransferTorrent, DownloadingTorrent
|
||||
from app.schemas.types import TorrentStatus
|
||||
from app.schemas.types import TorrentStatus, ModuleType
|
||||
from app.utils.string import StringUtils
|
||||
from app.utils.system import SystemUtils
|
||||
|
||||
@@ -30,6 +30,13 @@ class TransmissionModule(_ModuleBase, _DownloaderBase[Transmission]):
|
||||
def get_name() -> str:
|
||||
return "Transmission"
|
||||
|
||||
@staticmethod
|
||||
def get_type() -> ModuleType:
|
||||
"""
|
||||
获取模块类型
|
||||
"""
|
||||
return ModuleType.Downloader
|
||||
|
||||
def stop(self):
|
||||
pass
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ from app.log import logger
|
||||
from app.modules import _ModuleBase, _MessageBase
|
||||
from app.modules.vocechat.vocechat import VoceChat
|
||||
from app.schemas import MessageChannel, CommingMessage, Notification
|
||||
from app.schemas.types import ModuleType
|
||||
|
||||
|
||||
class VoceChatModule(_ModuleBase, _MessageBase[VoceChat]):
|
||||
@@ -22,6 +23,13 @@ class VoceChatModule(_ModuleBase, _MessageBase[VoceChat]):
|
||||
def get_name() -> str:
|
||||
return "VoceChat"
|
||||
|
||||
@staticmethod
|
||||
def get_type() -> ModuleType:
|
||||
"""
|
||||
获取模块类型
|
||||
"""
|
||||
return ModuleType.Notification
|
||||
|
||||
def stop(self):
|
||||
pass
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ from app.core.config import global_vars, settings
|
||||
from app.log import logger
|
||||
from app.modules import _ModuleBase, _MessageBase
|
||||
from app.schemas import Notification
|
||||
from app.schemas.types import ModuleType
|
||||
|
||||
|
||||
class WebPushModule(_ModuleBase, _MessageBase):
|
||||
@@ -21,6 +22,13 @@ class WebPushModule(_ModuleBase, _MessageBase):
|
||||
def get_name() -> str:
|
||||
return "WebPush"
|
||||
|
||||
@staticmethod
|
||||
def get_type() -> ModuleType:
|
||||
"""
|
||||
获取模块类型
|
||||
"""
|
||||
return ModuleType.Notification
|
||||
|
||||
def stop(self):
|
||||
pass
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ from app.modules import _ModuleBase, _MessageBase
|
||||
from app.modules.wechat.WXBizMsgCrypt3 import WXBizMsgCrypt
|
||||
from app.modules.wechat.wechat import WeChat
|
||||
from app.schemas import MessageChannel, CommingMessage, Notification
|
||||
from app.schemas.types import ModuleType
|
||||
from app.utils.dom import DomUtils
|
||||
|
||||
|
||||
@@ -23,6 +24,13 @@ class WechatModule(_ModuleBase, _MessageBase[WeChat]):
|
||||
def get_name() -> str:
|
||||
return "微信"
|
||||
|
||||
@staticmethod
|
||||
def get_type() -> ModuleType:
|
||||
"""
|
||||
获取模块类型
|
||||
"""
|
||||
return ModuleType.Notification
|
||||
|
||||
def stop(self):
|
||||
pass
|
||||
|
||||
|
||||
@@ -179,3 +179,19 @@ class StorageSchema(Enum):
|
||||
Alipan = "alipan"
|
||||
U115 = "u115"
|
||||
Rclone = "rclone"
|
||||
|
||||
|
||||
# 模块类型
|
||||
class ModuleType(Enum):
|
||||
# 下载器
|
||||
Downloader = "downloader"
|
||||
# 媒体服务器
|
||||
MediaServer = "mediaserver"
|
||||
# 消息服务
|
||||
Notification = "notification"
|
||||
# 媒体识别
|
||||
MediaRecognize = "mediarecognize"
|
||||
# 站点索引
|
||||
Indexer = "indexer"
|
||||
# 其它
|
||||
Other = "other"
|
||||
|
||||
Reference in New Issue
Block a user