fix
This commit is contained in:
parent
5a4c6c8a74
commit
99440d18d2
@ -106,14 +106,11 @@ class ChainBase(AbstractSingleton, metaclass=Singleton):
|
|||||||
def list_torrents(self, status: TorrentStatus = None, hashs: Union[list, str] = None) -> Optional[List[dict]]:
|
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)
|
return self.run_module("list_torrents", status=status, hashs=hashs)
|
||||||
|
|
||||||
def remove_torrents(self, hashs: Union[str, list]) -> bool:
|
|
||||||
return self.run_module("remove_torrents", hashs=hashs)
|
|
||||||
|
|
||||||
def transfer(self, path: str, mediainfo: MediaInfo) -> Optional[dict]:
|
def transfer(self, path: str, mediainfo: MediaInfo) -> Optional[dict]:
|
||||||
return self.run_module("transfer", path=path, mediainfo=mediainfo)
|
return self.run_module("transfer", path=path, mediainfo=mediainfo)
|
||||||
|
|
||||||
def transfer_completed(self, hashs: Union[str, list]) -> bool:
|
def transfer_completed(self, hashs: Union[str, list], transinfo: dict) -> None:
|
||||||
return self.run_module("transfer_completed", hashs=hashs)
|
return self.run_module("transfer_completed", hashs=hashs, transinfo=transinfo)
|
||||||
|
|
||||||
def media_exists(self, mediainfo: MediaInfo) -> Optional[dict]:
|
def media_exists(self, mediainfo: MediaInfo) -> Optional[dict]:
|
||||||
return self.run_module("media_exists", mediainfo=mediainfo)
|
return self.run_module("media_exists", mediainfo=mediainfo)
|
||||||
@ -121,8 +118,8 @@ class ChainBase(AbstractSingleton, metaclass=Singleton):
|
|||||||
def refresh_mediaserver(self, mediainfo: MediaInfo, file_path: str) -> Optional[bool]:
|
def refresh_mediaserver(self, mediainfo: MediaInfo, file_path: str) -> Optional[bool]:
|
||||||
return self.run_module("refresh_mediaserver", mediainfo=mediainfo, file_path=file_path)
|
return self.run_module("refresh_mediaserver", mediainfo=mediainfo, file_path=file_path)
|
||||||
|
|
||||||
def post_message(self, title: str,
|
def post_message(self, title: str, text: str = None,
|
||||||
text: str = None, image: str = None, userid: Union[str, int] = None) -> Optional[bool]:
|
image: str = None, userid: Union[str, int] = None) -> Optional[bool]:
|
||||||
return self.run_module("post_message", title=title, text=text, image=image, userid=userid)
|
return self.run_module("post_message", title=title, text=text, image=image, userid=userid)
|
||||||
|
|
||||||
def post_medias_message(self, title: str, items: List[MediaInfo],
|
def post_medias_message(self, title: str, items: List[MediaInfo],
|
||||||
@ -138,5 +135,5 @@ class ChainBase(AbstractSingleton, metaclass=Singleton):
|
|||||||
def scrape_metadata(self, path: Path, mediainfo: MediaInfo) -> None:
|
def scrape_metadata(self, path: Path, mediainfo: MediaInfo) -> None:
|
||||||
return self.run_module("scrape_metadata", path=path, mediainfo=mediainfo)
|
return self.run_module("scrape_metadata", path=path, mediainfo=mediainfo)
|
||||||
|
|
||||||
def register_commands(self, commands: dict):
|
def register_commands(self, commands: dict) -> None:
|
||||||
return self.run_module("register_commands", commands=commands)
|
return self.run_module("register_commands", commands=commands)
|
||||||
|
@ -104,14 +104,9 @@ class TransferChain(ChainBase):
|
|||||||
),
|
),
|
||||||
continue
|
continue
|
||||||
# 转移完成
|
# 转移完成
|
||||||
self.transfer_completed(hashs=torrent.get("hash"))
|
self.transfer_completed(hashs=torrent.get("hash"), transinfo=transferinfo)
|
||||||
# 刮剥
|
# 刮剥
|
||||||
self.scrape_metadata(path=transferinfo.get('target_path'), mediainfo=mediainfo)
|
self.scrape_metadata(path=transferinfo.get('target_path'), mediainfo=mediainfo)
|
||||||
# 移动模式删除种子
|
|
||||||
if settings.TRANSFER_TYPE == "move":
|
|
||||||
result2 = self.remove_torrents(hashs=torrent.get("hash"))
|
|
||||||
if result2:
|
|
||||||
logger.info(f"移动模式删除种子成功:{torrent.get('title')} ")
|
|
||||||
# 刷新媒体库
|
# 刷新媒体库
|
||||||
self.refresh_mediaserver(mediainfo=mediainfo, file_path=transferinfo.get('target_path'))
|
self.refresh_mediaserver(mediainfo=mediainfo, file_path=transferinfo.get('target_path'))
|
||||||
# 发送通知
|
# 发送通知
|
||||||
|
@ -11,9 +11,8 @@ from app.utils.types import TorrentStatus, MediaType
|
|||||||
|
|
||||||
class _ModuleBase(metaclass=ABCMeta):
|
class _ModuleBase(metaclass=ABCMeta):
|
||||||
"""
|
"""
|
||||||
模块基类,实现对应方法,在有需要时会被自动调用,返回None代表不启用该模块
|
模块基类,实现对应方法,在有需要时会被自动调用,返回None代表不启用该模块,将继续执行下一模块
|
||||||
输入参数与输出参数一致的,可以被多个模块重复实现
|
输入参数与输出参数一致的,或没有输出的,可以被多个模块重复实现
|
||||||
通过监听事件来实现多个模块之间的协作
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
@ -56,7 +55,7 @@ class _ModuleBase(metaclass=ABCMeta):
|
|||||||
"""
|
"""
|
||||||
获取豆瓣信息
|
获取豆瓣信息
|
||||||
:param doubanid: 豆瓣ID
|
:param doubanid: 豆瓣ID
|
||||||
:return: 识别的媒体信息,包括剧集信息
|
:return: 识别的媒体信息
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -87,7 +86,7 @@ class _ModuleBase(metaclass=ABCMeta):
|
|||||||
"""
|
"""
|
||||||
获取图片
|
获取图片
|
||||||
:param mediainfo: 识别的媒体信息
|
:param mediainfo: 识别的媒体信息
|
||||||
:return: 更新后的媒体信息,注意如果返回None,有可能是没有对应的处理模块,应无视结果
|
:return: 更新后的媒体信息,该方法可被多个模块同时处理
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -124,7 +123,7 @@ class _ModuleBase(metaclass=ABCMeta):
|
|||||||
过滤资源
|
过滤资源
|
||||||
:param torrent_list: 资源列表
|
:param torrent_list: 资源列表
|
||||||
:param season_episodes: 过滤的剧集信息
|
:param season_episodes: 过滤的剧集信息
|
||||||
:return: 过滤后的资源列表,注意如果返回None,有可能是没有对应的处理模块,应无视结果
|
:return: 过滤后的资源列表,该方法可被多个模块同时处理
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -139,7 +138,8 @@ class _ModuleBase(metaclass=ABCMeta):
|
|||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def list_torrents(self, status: TorrentStatus = None, hashs: Union[list, str] = None) -> Optional[List[dict]]:
|
def list_torrents(self, status: TorrentStatus = None,
|
||||||
|
hashs: Union[list, str] = None) -> Optional[List[dict]]:
|
||||||
"""
|
"""
|
||||||
获取下载器种子列表
|
获取下载器种子列表
|
||||||
:param status: 种子状态
|
:param status: 种子状态
|
||||||
@ -148,28 +148,21 @@ class _ModuleBase(metaclass=ABCMeta):
|
|||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def remove_torrents(self, hashs: Union[str, list]) -> bool:
|
|
||||||
"""
|
|
||||||
删除下载器种子
|
|
||||||
:param hashs: 种子Hash
|
|
||||||
:return: bool
|
|
||||||
"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
def transfer(self, path: str, mediainfo: MediaInfo) -> Optional[dict]:
|
def transfer(self, path: str, mediainfo: MediaInfo) -> Optional[dict]:
|
||||||
"""
|
"""
|
||||||
转移一个路径下的文件
|
转移一个路径下的文件
|
||||||
:param path: 文件路径
|
:param path: 文件路径
|
||||||
:param mediainfo: 识别的媒体信息
|
:param mediainfo: 识别的媒体信息
|
||||||
:return: 转移后的目录或None代表失败
|
:return: {path, target_path, message}
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def transfer_completed(self, hashs: Union[str, list]) -> bool:
|
def transfer_completed(self, hashs: Union[str, list], transinfo: dict) -> None:
|
||||||
"""
|
"""
|
||||||
转移完成后的处理
|
转移完成后的处理
|
||||||
:param hashs: 种子Hash
|
:param hashs: 种子Hash
|
||||||
:return: 处理状态
|
:param transinfo: 转移信息
|
||||||
|
:return: None,该方法可被多个模块同时处理
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -190,8 +183,8 @@ class _ModuleBase(metaclass=ABCMeta):
|
|||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def post_message(self, title: str,
|
def post_message(self, title: str, text: str = None,
|
||||||
text: str = None, image: str = None, userid: Union[str, int] = None) -> Optional[bool]:
|
image: str = None, userid: Union[str, int] = None) -> Optional[bool]:
|
||||||
"""
|
"""
|
||||||
发送消息
|
发送消息
|
||||||
:param title: 标题
|
:param title: 标题
|
||||||
@ -231,20 +224,22 @@ class _ModuleBase(metaclass=ABCMeta):
|
|||||||
刮削元数据
|
刮削元数据
|
||||||
:param path: 媒体文件路径
|
:param path: 媒体文件路径
|
||||||
:param mediainfo: 识别的媒体信息
|
:param mediainfo: 识别的媒体信息
|
||||||
:return: 成功或失败
|
:return: None,该方法可被多个模块同时处理
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def register_commands(self, commands: dict):
|
def register_commands(self, commands: dict) -> None:
|
||||||
"""
|
"""
|
||||||
注册命令,实现这个函数接收系统可用的命令菜单
|
注册命令,实现这个函数接收系统可用的命令菜单
|
||||||
:param commands: 命令字典
|
:param commands: 命令字典
|
||||||
|
:return: None,该方法可被多个模块同时处理
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def stop(self):
|
def stop(self) -> None:
|
||||||
"""
|
"""
|
||||||
如果关闭时模块有服务需要停止,需要实现此方法
|
如果关闭时模块有服务需要停止,需要实现此方法
|
||||||
|
:return: None,该方法可被多个模块同时处理
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
@ -33,7 +33,7 @@ class FileTransferModule(_ModuleBase):
|
|||||||
文件转移
|
文件转移
|
||||||
:param path: 文件路径
|
:param path: 文件路径
|
||||||
:param mediainfo: 识别的媒体信息
|
:param mediainfo: 识别的媒体信息
|
||||||
:return: 转移后的目录或None代表失败
|
:return: {path, target_path, message}
|
||||||
"""
|
"""
|
||||||
if not settings.LIBRARY_PATH:
|
if not settings.LIBRARY_PATH:
|
||||||
logger.error("未设置媒体库目录,无法转移文件")
|
logger.error("未设置媒体库目录,无法转移文件")
|
||||||
|
@ -3,6 +3,7 @@ from typing import Set, Tuple, Optional, Union, List
|
|||||||
|
|
||||||
from app.core.config import settings
|
from app.core.config import settings
|
||||||
from app.core.metainfo import MetaInfo
|
from app.core.metainfo import MetaInfo
|
||||||
|
from app.log import logger
|
||||||
from app.modules import _ModuleBase
|
from app.modules import _ModuleBase
|
||||||
from app.modules.qbittorrent.qbittorrent import Qbittorrent
|
from app.modules.qbittorrent.qbittorrent import Qbittorrent
|
||||||
from app.utils.string import StringUtils
|
from app.utils.string import StringUtils
|
||||||
@ -28,7 +29,7 @@ class QbittorrentModule(_ModuleBase):
|
|||||||
:param torrent_path: 种子文件地址
|
:param torrent_path: 种子文件地址
|
||||||
:param cookie: cookie
|
:param cookie: cookie
|
||||||
:param episodes: 需要下载的集数
|
:param episodes: 需要下载的集数
|
||||||
:return: 种子Hash
|
:return: 种子Hash,错误信息
|
||||||
"""
|
"""
|
||||||
if not torrent_path.exists():
|
if not torrent_path.exists():
|
||||||
return None, f"种子文件不存在:{torrent_path}"
|
return None, f"种子文件不存在:{torrent_path}"
|
||||||
@ -83,14 +84,6 @@ class QbittorrentModule(_ModuleBase):
|
|||||||
else:
|
else:
|
||||||
return torrent_hash, "添加下载成功"
|
return torrent_hash, "添加下载成功"
|
||||||
|
|
||||||
def transfer_completed(self, hashs: Union[str, list]) -> bool:
|
|
||||||
"""
|
|
||||||
转移完成后的处理
|
|
||||||
:param hashs: 种子Hash
|
|
||||||
:return: 处理状态
|
|
||||||
"""
|
|
||||||
return self.qbittorrent.set_torrents_tag(ids=hashs, tags=['已整理'])
|
|
||||||
|
|
||||||
def list_torrents(self, status: TorrentStatus = None, hashs: Union[list, str] = None) -> Optional[List[dict]]:
|
def list_torrents(self, status: TorrentStatus = None, hashs: Union[list, str] = None) -> Optional[List[dict]]:
|
||||||
"""
|
"""
|
||||||
获取下载器种子列表
|
获取下载器种子列表
|
||||||
@ -137,10 +130,14 @@ class QbittorrentModule(_ModuleBase):
|
|||||||
return None
|
return None
|
||||||
return ret_torrents
|
return ret_torrents
|
||||||
|
|
||||||
def remove_torrents(self, hashs: Union[str, list]) -> bool:
|
def transfer_completed(self, hashs: Union[str, list], transinfo: dict) -> None:
|
||||||
"""
|
"""
|
||||||
删除下载器种子
|
转移完成后的处理
|
||||||
:param hashs: 种子Hash
|
:param hashs: 种子Hash
|
||||||
:return: bool
|
:param transinfo: 转移信息
|
||||||
"""
|
"""
|
||||||
return self.qbittorrent.delete_torrents(delete_file=True, ids=hashs)
|
self.qbittorrent.set_torrents_tag(ids=hashs, tags=['已整理'])
|
||||||
|
# 移动模式删除种子
|
||||||
|
if settings.TRANSFER_TYPE == "move":
|
||||||
|
if self.qbittorrent.delete_torrents(delete_file=True, ids=hashs):
|
||||||
|
logger.info(f"移动模式删除种子成功:{hashs} ")
|
||||||
|
@ -71,14 +71,6 @@ class TransmissionModule(_ModuleBase):
|
|||||||
else:
|
else:
|
||||||
return torrent_hash, "添加下载任务成功"
|
return torrent_hash, "添加下载任务成功"
|
||||||
|
|
||||||
def transfer_completed(self, hashs: Union[str, list]) -> bool:
|
|
||||||
"""
|
|
||||||
转移完成后的处理
|
|
||||||
:param hashs: 种子Hash
|
|
||||||
:return: 处理状态
|
|
||||||
"""
|
|
||||||
return self.transmission.set_torrent_tag(ids=hashs, tags=['已整理'])
|
|
||||||
|
|
||||||
def list_torrents(self, status: TorrentStatus = None, hashs: Union[list, str] = None) -> Optional[List[dict]]:
|
def list_torrents(self, status: TorrentStatus = None, hashs: Union[list, str] = None) -> Optional[List[dict]]:
|
||||||
"""
|
"""
|
||||||
获取下载器种子列表
|
获取下载器种子列表
|
||||||
@ -120,10 +112,15 @@ class TransmissionModule(_ModuleBase):
|
|||||||
return None
|
return None
|
||||||
return ret_torrents
|
return ret_torrents
|
||||||
|
|
||||||
def remove_torrents(self, hashs: Union[str, list]) -> bool:
|
def transfer_completed(self, hashs: Union[str, list], transinfo: dict) -> None:
|
||||||
"""
|
"""
|
||||||
删除下载器种子
|
转移完成后的处理
|
||||||
:param hashs: 种子Hash
|
:param hashs: 种子Hash
|
||||||
:return: bool
|
:param transinfo: 转移信息
|
||||||
|
:return: None
|
||||||
"""
|
"""
|
||||||
return self.transmission.delete_torrents(delete_file=True, ids=hashs)
|
self.transmission.set_torrent_tag(ids=hashs, tags=['已整理'])
|
||||||
|
# 移动模式删除种子
|
||||||
|
if settings.TRANSFER_TYPE == "move":
|
||||||
|
if self.transmission.delete_torrents(delete_file=True, ids=hashs):
|
||||||
|
logger.info(f"移动模式删除种子成功:{hashs} ")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user