fix module name

This commit is contained in:
jxxghp 2024-05-16 14:20:18 +08:00
parent a740330e66
commit 43647e59a4
23 changed files with 97 additions and 4 deletions

View File

@ -280,9 +280,12 @@ def modulelist(_: schemas.TokenPayload = Depends(verify_token)):
"""
查询已加载的模块ID列表
"""
module_ids = [module.__name__ for module in ModuleManager().get_modules("test")]
modules = [{
"id": k,
"name": v.get_name(),
} for k, v in ModuleManager().get_modules().items()]
return schemas.Response(success=True, data={
"ids": module_ids
"modules": modules
})

View File

@ -92,7 +92,7 @@ class ChainBase(metaclass=ABCMeta):
logger.debug(f"请求模块执行:{method} ...")
result = None
modules = self.modulemanager.get_modules(method)
modules = self.modulemanager.get_running_modules(method)
for module in modules:
try:
func = getattr(module, method)

View File

@ -95,7 +95,7 @@ class ModuleManager(metaclass=Singleton):
return True
return False
def get_modules(self, method: str) -> Generator:
def get_running_modules(self, method: str) -> Generator:
"""
获取实现了同一方法的模块列表
"""
@ -105,3 +105,9 @@ class ModuleManager(metaclass=Singleton):
if hasattr(module, method) \
and ObjectUtils.check_method(getattr(module, method)):
yield module
def get_modules(self) -> dict:
"""
获取模块列表
"""
return self._modules

View File

@ -27,6 +27,14 @@ class _ModuleBase(metaclass=ABCMeta):
"""
pass
@staticmethod
@abstractmethod
def get_name() -> str:
"""
获取模块名称
"""
pass
@abstractmethod
def stop(self) -> None:
"""

View File

@ -33,6 +33,10 @@ class BangumiModule(_ModuleBase):
def init_setting(self) -> Tuple[str, Union[str, bool]]:
pass
@staticmethod
def get_name() -> str:
return "Bangumi"
def recognize_media(self, bangumiid: int = None,
**kwargs) -> Optional[MediaInfo]:
"""

View File

@ -48,6 +48,10 @@ class DoubanModule(_ModuleBase):
def init_setting(self) -> Tuple[str, Union[str, bool]]:
pass
@staticmethod
def get_name() -> str:
return "豆瓣"
def recognize_media(self, meta: MetaBase = None,
mtype: MediaType = None,
doubanid: str = None,

View File

@ -14,6 +14,10 @@ class EmbyModule(_ModuleBase):
def init_module(self) -> None:
self.emby = Emby()
@staticmethod
def get_name() -> str:
return "Emby"
def stop(self):
pass

View File

@ -331,6 +331,10 @@ class FanartModule(_ModuleBase):
def init_setting(self) -> Tuple[str, Union[str, bool]]:
return "FANART_API_KEY", True
@staticmethod
def get_name() -> str:
return "Fanart"
def obtain_images(self, mediainfo: MediaInfo) -> Optional[MediaInfo]:
"""
获取图片

View File

@ -24,6 +24,10 @@ class FileTransferModule(_ModuleBase):
def init_module(self) -> None:
pass
@staticmethod
def get_name() -> str:
return "文件整理"
def stop(self):
pass

View File

@ -136,6 +136,10 @@ class FilterModule(_ModuleBase):
def init_module(self) -> None:
self.parser = RuleParser()
@staticmethod
def get_name() -> str:
return "过滤器"
def stop(self):
pass

View File

@ -25,6 +25,10 @@ class IndexerModule(_ModuleBase):
def init_module(self) -> None:
pass
@staticmethod
def get_name() -> str:
return "站点索引"
def stop(self):
pass

View File

@ -14,6 +14,10 @@ class JellyfinModule(_ModuleBase):
def init_module(self) -> None:
self.jellyfin = Jellyfin()
@staticmethod
def get_name() -> str:
return "Jellyfin"
def init_setting(self) -> Tuple[str, Union[str, bool]]:
return "MEDIASERVER", "jellyfin"

View File

@ -14,6 +14,10 @@ class PlexModule(_ModuleBase):
def init_module(self) -> None:
self.plex = Plex()
@staticmethod
def get_name() -> str:
return "Plex"
def stop(self):
pass

View File

@ -23,6 +23,10 @@ class QbittorrentModule(_ModuleBase):
def init_module(self) -> None:
self.qbittorrent = Qbittorrent()
@staticmethod
def get_name() -> str:
return "Qbittorrent"
def stop(self):
pass

View File

@ -16,6 +16,10 @@ class SlackModule(_ModuleBase):
def init_module(self) -> None:
self.slack = Slack()
@staticmethod
def get_name() -> str:
return "Slack"
def stop(self):
self.slack.stop()

View File

@ -28,6 +28,10 @@ class SubtitleModule(_ModuleBase):
def init_module(self) -> None:
pass
@staticmethod
def get_name() -> str:
return "站点字幕"
def init_setting(self) -> Tuple[str, Union[str, bool]]:
pass

View File

@ -13,6 +13,10 @@ class SynologyChatModule(_ModuleBase):
def init_module(self) -> None:
self.synologychat = SynologyChat()
@staticmethod
def get_name() -> str:
return "Synology Chat"
def stop(self):
pass

View File

@ -15,6 +15,10 @@ class TelegramModule(_ModuleBase):
def init_module(self) -> None:
self.telegram = Telegram()
@staticmethod
def get_name() -> str:
return "Telegram"
def stop(self):
self.telegram.stop()

View File

@ -39,6 +39,10 @@ class TheMovieDbModule(_ModuleBase):
self.category = CategoryHelper()
self.scraper = TmdbScraper(self.tmdb)
@staticmethod
def get_name() -> str:
return "TheMovieDb"
def stop(self):
self.cache.save()
self.tmdb.close()

View File

@ -16,6 +16,10 @@ class TheTvDbModule(_ModuleBase):
select_first=True,
proxies=settings.PROXY)
@staticmethod
def get_name() -> str:
return "TheTvDb"
def stop(self):
self.tvdb.close()

View File

@ -23,6 +23,10 @@ class TransmissionModule(_ModuleBase):
def init_module(self) -> None:
self.transmission = Transmission()
@staticmethod
def get_name() -> str:
return "Transmission"
def stop(self):
pass

View File

@ -15,6 +15,10 @@ class VoceChatModule(_ModuleBase):
def init_module(self) -> None:
self.vocechat = VoceChat()
@staticmethod
def get_name() -> str:
return "VoceChat"
def stop(self):
pass

View File

@ -17,6 +17,10 @@ class WechatModule(_ModuleBase):
def init_module(self) -> None:
self.wechat = WeChat()
@staticmethod
def get_name() -> str:
return "微信"
def stop(self):
pass