fix
This commit is contained in:
@ -73,6 +73,9 @@ class ChainBase(AbstractSingleton, metaclass=Singleton):
|
||||
tmdbid: int = None) -> Optional[MediaInfo]:
|
||||
return self.run_module("recognize_media", meta=meta, mtype=mtype, tmdbid=tmdbid)
|
||||
|
||||
def obtain_image(self, mediainfo: MediaInfo) -> Optional[MediaInfo]:
|
||||
return self.run_module("obtain_image", mediainfo=mediainfo)
|
||||
|
||||
def douban_info(self, doubanid: str) -> Optional[dict]:
|
||||
return self.run_module("douban_info", doubanid=doubanid)
|
||||
|
||||
@ -82,9 +85,6 @@ class ChainBase(AbstractSingleton, metaclass=Singleton):
|
||||
def webhook_parser(self, body: Any, form: Any, args: Any) -> Optional[dict]:
|
||||
return self.run_module("webhook_parser", body=body, form=form, args=args)
|
||||
|
||||
def obtain_image(self, mediainfo: MediaInfo) -> Optional[MediaInfo]:
|
||||
return self.run_module("obtain_image", mediainfo=mediainfo)
|
||||
|
||||
def search_medias(self, meta: MetaBase) -> Optional[List[MediaInfo]]:
|
||||
return self.run_module("search_medias", meta=meta)
|
||||
|
||||
@ -103,6 +103,9 @@ class ChainBase(AbstractSingleton, metaclass=Singleton):
|
||||
episodes: Set[int] = None) -> Optional[Tuple[Optional[str], str]]:
|
||||
return self.run_module("download", torrent_path=torrent_path, cookie=cookie, episodes=episodes)
|
||||
|
||||
def download_added(self, context: Context, torrent_path: Path) -> None:
|
||||
return self.run_module("download_added", context=context, torrent_path=torrent_path)
|
||||
|
||||
def list_torrents(self, status: TorrentStatus = None, hashs: Union[list, str] = None) -> Optional[List[dict]]:
|
||||
return self.run_module("list_torrents", status=status, hashs=hashs)
|
||||
|
||||
@ -112,6 +115,9 @@ class ChainBase(AbstractSingleton, metaclass=Singleton):
|
||||
def transfer_completed(self, hashs: Union[str, list], transinfo: dict) -> None:
|
||||
return self.run_module("transfer_completed", hashs=hashs, transinfo=transinfo)
|
||||
|
||||
def remove_torrents(self, hashs: Union[str, list]) -> bool:
|
||||
return self.run_module("remove_torrents", hashs=hashs)
|
||||
|
||||
def media_exists(self, mediainfo: MediaInfo) -> Optional[dict]:
|
||||
return self.run_module("media_exists", mediainfo=mediainfo)
|
||||
|
||||
|
@ -117,7 +117,10 @@ class DownloadChain(ChainBase):
|
||||
if _hash:
|
||||
# 下载成功
|
||||
downloaded_list.append(_context)
|
||||
# 发送消息
|
||||
self.post_download_message(meta=_meta, mediainfo=_media, torrent=_torrent, userid=userid)
|
||||
# 下载成功后处理
|
||||
self.download_added(context=_context, torrent_path=_torrent_file)
|
||||
else:
|
||||
# 下载失败
|
||||
logger.error(f"{_media.get_title_string()} 添加下载任务失败:"
|
||||
|
@ -203,6 +203,8 @@ class UserMessageChain(ChainBase):
|
||||
return
|
||||
# 下载成功,发送通知
|
||||
self.downloadchain.post_download_message(meta=meta, mediainfo=self._current_media, torrent=torrent)
|
||||
# 下载成功后处理
|
||||
self.download_added(context=context, torrent_path=torrent_file)
|
||||
|
||||
elif text.lower() == "p":
|
||||
# 上一页
|
||||
|
@ -35,7 +35,7 @@ class _ModuleBase(metaclass=ABCMeta):
|
||||
识别前的预处理
|
||||
:param title: 标题
|
||||
:param subtitle: 副标题
|
||||
:return: 处理后的标题、副标题,注意如果返回None,有可能是没有对应的处理模块,应无视结果
|
||||
:return: 处理后的标题、副标题,该方法可被多个模块同时处理
|
||||
"""
|
||||
pass
|
||||
|
||||
@ -51,6 +51,14 @@ class _ModuleBase(metaclass=ABCMeta):
|
||||
"""
|
||||
pass
|
||||
|
||||
def obtain_image(self, mediainfo: MediaInfo) -> Optional[MediaInfo]:
|
||||
"""
|
||||
获取图片
|
||||
:param mediainfo: 识别的媒体信息
|
||||
:return: 更新后的媒体信息,该方法可被多个模块同时处理
|
||||
"""
|
||||
pass
|
||||
|
||||
def douban_info(self, doubanid: str) -> Optional[dict]:
|
||||
"""
|
||||
获取豆瓣信息
|
||||
@ -82,14 +90,6 @@ class _ModuleBase(metaclass=ABCMeta):
|
||||
"""
|
||||
pass
|
||||
|
||||
def obtain_image(self, mediainfo: MediaInfo) -> Optional[MediaInfo]:
|
||||
"""
|
||||
获取图片
|
||||
:param mediainfo: 识别的媒体信息
|
||||
:return: 更新后的媒体信息,该方法可被多个模块同时处理
|
||||
"""
|
||||
pass
|
||||
|
||||
def search_medias(self, meta: MetaBase) -> Optional[List[MediaInfo]]:
|
||||
"""
|
||||
搜索媒体信息
|
||||
@ -98,6 +98,14 @@ class _ModuleBase(metaclass=ABCMeta):
|
||||
"""
|
||||
pass
|
||||
|
||||
def media_exists(self, mediainfo: MediaInfo) -> Optional[dict]:
|
||||
"""
|
||||
判断媒体文件是否存在
|
||||
:param mediainfo: 识别的媒体信息
|
||||
:return: 如不存在返回None,存在时返回信息,包括每季已存在所有集{type: movie/tv, seasons: {season: [episodes]}}
|
||||
"""
|
||||
pass
|
||||
|
||||
def search_torrents(self, mediainfo: Optional[MediaInfo], sites: List[CommentedMap],
|
||||
keyword: str = None) -> Optional[List[TorrentInfo]]:
|
||||
"""
|
||||
@ -138,6 +146,15 @@ class _ModuleBase(metaclass=ABCMeta):
|
||||
"""
|
||||
pass
|
||||
|
||||
def download_added(self, context: Context, torrent_path: Path) -> None:
|
||||
"""
|
||||
添加下载任务后的处理
|
||||
:param context: 上下文,包括识别信息、媒体信息、种子信息
|
||||
:param torrent_path: 种子文件地址
|
||||
:return: None,该方法可被多个模块同时处理
|
||||
"""
|
||||
pass
|
||||
|
||||
def list_torrents(self, status: TorrentStatus = None,
|
||||
hashs: Union[list, str] = None) -> Optional[List[dict]]:
|
||||
"""
|
||||
@ -166,11 +183,11 @@ class _ModuleBase(metaclass=ABCMeta):
|
||||
"""
|
||||
pass
|
||||
|
||||
def media_exists(self, mediainfo: MediaInfo) -> Optional[dict]:
|
||||
def remove_torrents(self, hashs: Union[str, list]) -> bool:
|
||||
"""
|
||||
判断媒体文件是否存在
|
||||
:param mediainfo: 识别的媒体信息
|
||||
:return: 如不存在返回None,存在时返回信息,包括每季已存在所有集{type: movie/tv, seasons: {season: [episodes]}}
|
||||
删除下载器种子
|
||||
:param hashs: 种子Hash
|
||||
:return: bool
|
||||
"""
|
||||
pass
|
||||
|
||||
|
@ -139,5 +139,14 @@ class QbittorrentModule(_ModuleBase):
|
||||
self.qbittorrent.set_torrents_tag(ids=hashs, tags=['已整理'])
|
||||
# 移动模式删除种子
|
||||
if settings.TRANSFER_TYPE == "move":
|
||||
if self.qbittorrent.delete_torrents(delete_file=True, ids=hashs):
|
||||
if self.remove_torrents(hashs):
|
||||
logger.info(f"移动模式删除种子成功:{hashs} ")
|
||||
|
||||
def remove_torrents(self, hashs: Union[str, list]) -> bool:
|
||||
"""
|
||||
删除下载器种子
|
||||
:param hashs: 种子Hash
|
||||
:return: bool
|
||||
"""
|
||||
return self.qbittorrent.delete_torrents(delete_file=True, ids=hashs)
|
||||
|
||||
|
30
app/modules/subtitle/__init__.py
Normal file
30
app/modules/subtitle/__init__.py
Normal file
@ -0,0 +1,30 @@
|
||||
from pathlib import Path
|
||||
from typing import Tuple, Union
|
||||
|
||||
from app.core.context import Context
|
||||
from app.modules import _ModuleBase
|
||||
|
||||
|
||||
class SubtitleModule(_ModuleBase):
|
||||
"""
|
||||
字幕下载模块
|
||||
"""
|
||||
|
||||
def init_module(self) -> None:
|
||||
pass
|
||||
|
||||
def init_setting(self) -> Tuple[str, Union[str, bool]]:
|
||||
pass
|
||||
|
||||
def stop(self) -> None:
|
||||
pass
|
||||
|
||||
def download_added(self, context: Context, torrent_path: Path) -> None:
|
||||
"""
|
||||
添加下载任务成功后,从站点下载字幕
|
||||
:param context: 上下文,包括识别信息、媒体信息、种子信息
|
||||
:param torrent_path: 种子文件地址
|
||||
:return: None,该方法可被多个模块同时处理
|
||||
"""
|
||||
pass
|
||||
|
@ -122,5 +122,13 @@ class TransmissionModule(_ModuleBase):
|
||||
self.transmission.set_torrent_tag(ids=hashs, tags=['已整理'])
|
||||
# 移动模式删除种子
|
||||
if settings.TRANSFER_TYPE == "move":
|
||||
if self.transmission.delete_torrents(delete_file=True, ids=hashs):
|
||||
if self.remove_torrents(hashs):
|
||||
logger.info(f"移动模式删除种子成功:{hashs} ")
|
||||
|
||||
def remove_torrents(self, hashs: Union[str, list]) -> bool:
|
||||
"""
|
||||
删除下载器种子
|
||||
:param hashs: 种子Hash
|
||||
:return: bool
|
||||
"""
|
||||
return self.transmission.delete_torrents(delete_file=True, ids=hashs)
|
||||
|
30
app/modules/words/__init__.py
Normal file
30
app/modules/words/__init__.py
Normal file
@ -0,0 +1,30 @@
|
||||
from pathlib import Path
|
||||
from typing import Tuple, Union
|
||||
|
||||
from app.core.context import Context
|
||||
from app.modules import _ModuleBase
|
||||
|
||||
|
||||
class WordseModule(_ModuleBase):
|
||||
"""
|
||||
字幕下载模块
|
||||
"""
|
||||
|
||||
def init_module(self) -> None:
|
||||
pass
|
||||
|
||||
def init_setting(self) -> Tuple[str, Union[str, bool]]:
|
||||
pass
|
||||
|
||||
def stop(self) -> None:
|
||||
pass
|
||||
|
||||
def prepare_recognize(self, title: str,
|
||||
subtitle: str = None) -> Tuple[str, str]:
|
||||
"""
|
||||
处理各类特别命名,以便识别
|
||||
:param title: 标题
|
||||
:param subtitle: 副标题
|
||||
:return: 处理后的标题、副标题,该方法可被多个模块同时处理
|
||||
"""
|
||||
pass
|
Reference in New Issue
Block a user