fix #406 支持QB分类自动管理模式
This commit is contained in:
parent
31b460f89f
commit
0050a96faf
@ -113,6 +113,7 @@ docker pull jxxghp/moviepilot:latest
|
|||||||
- **QB_HOST:** qbittorrent地址,格式:`ip:port`,https需要添加`https://`前缀
|
- **QB_HOST:** qbittorrent地址,格式:`ip:port`,https需要添加`https://`前缀
|
||||||
- **QB_USER:** qbittorrent用户名
|
- **QB_USER:** qbittorrent用户名
|
||||||
- **QB_PASSWORD:** qbittorrent密码
|
- **QB_PASSWORD:** qbittorrent密码
|
||||||
|
- **QB_CATEGORY:** qbittorrent分类自动管理,`true`/`false`,默认`flase`,开启后会将下载二级分类传递到下载器,由下载器管理下载目录,需要同步开启`DOWNLOAD_CATEGORY`
|
||||||
|
|
||||||
- `transmission`设置项:
|
- `transmission`设置项:
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@ class ChainBase(metaclass=ABCMeta):
|
|||||||
torrent_list=torrent_list, season_episodes=season_episodes)
|
torrent_list=torrent_list, season_episodes=season_episodes)
|
||||||
|
|
||||||
def download(self, torrent_path: Path, download_dir: Path, cookie: str,
|
def download(self, torrent_path: Path, download_dir: Path, cookie: str,
|
||||||
episodes: Set[int] = None,
|
episodes: Set[int] = None, category: str = None
|
||||||
) -> Optional[Tuple[Optional[str], str]]:
|
) -> Optional[Tuple[Optional[str], str]]:
|
||||||
"""
|
"""
|
||||||
根据种子文件,选择并添加下载任务
|
根据种子文件,选择并添加下载任务
|
||||||
@ -243,10 +243,11 @@ class ChainBase(metaclass=ABCMeta):
|
|||||||
:param download_dir: 下载目录
|
:param download_dir: 下载目录
|
||||||
:param cookie: cookie
|
:param cookie: cookie
|
||||||
:param episodes: 需要下载的集数
|
:param episodes: 需要下载的集数
|
||||||
|
:param category: 种子分类
|
||||||
:return: 种子Hash,错误信息
|
:return: 种子Hash,错误信息
|
||||||
"""
|
"""
|
||||||
return self.run_module("download", torrent_path=torrent_path, download_dir=download_dir,
|
return self.run_module("download", torrent_path=torrent_path, download_dir=download_dir,
|
||||||
cookie=cookie, episodes=episodes, )
|
cookie=cookie, episodes=episodes, category=category)
|
||||||
|
|
||||||
def download_added(self, context: Context, torrent_path: Path, download_dir: Path) -> None:
|
def download_added(self, context: Context, torrent_path: Path, download_dir: Path) -> None:
|
||||||
"""
|
"""
|
||||||
|
@ -151,7 +151,8 @@ class DownloadChain(ChainBase):
|
|||||||
result: Optional[tuple] = self.download(torrent_path=torrent_file,
|
result: Optional[tuple] = self.download(torrent_path=torrent_file,
|
||||||
cookie=_torrent.site_cookie,
|
cookie=_torrent.site_cookie,
|
||||||
episodes=episodes,
|
episodes=episodes,
|
||||||
download_dir=download_dir)
|
download_dir=download_dir,
|
||||||
|
category=_media.category)
|
||||||
if result:
|
if result:
|
||||||
_hash, error_msg = result
|
_hash, error_msg = result
|
||||||
else:
|
else:
|
||||||
|
@ -109,6 +109,8 @@ class Settings(BaseSettings):
|
|||||||
QB_USER: str = None
|
QB_USER: str = None
|
||||||
# Qbittorrent密码
|
# Qbittorrent密码
|
||||||
QB_PASSWORD: str = None
|
QB_PASSWORD: str = None
|
||||||
|
# Qbittorrent分类自动管理
|
||||||
|
QB_CATEGORY: bool = False
|
||||||
# Transmission地址,IP:PORT
|
# Transmission地址,IP:PORT
|
||||||
TR_HOST: str = None
|
TR_HOST: str = None
|
||||||
# Transmission用户名
|
# Transmission用户名
|
||||||
|
@ -37,13 +37,14 @@ class QbittorrentModule(_ModuleBase):
|
|||||||
self.qbittorrent = Qbittorrent()
|
self.qbittorrent = Qbittorrent()
|
||||||
|
|
||||||
def download(self, torrent_path: Path, download_dir: Path, cookie: str,
|
def download(self, torrent_path: Path, download_dir: Path, cookie: str,
|
||||||
episodes: Set[int] = None) -> Optional[Tuple[Optional[str], str]]:
|
episodes: Set[int] = None, category: str = None) -> Optional[Tuple[Optional[str], str]]:
|
||||||
"""
|
"""
|
||||||
根据种子文件,选择并添加下载任务
|
根据种子文件,选择并添加下载任务
|
||||||
:param torrent_path: 种子文件地址
|
:param torrent_path: 种子文件地址
|
||||||
:param download_dir: 下载目录
|
:param download_dir: 下载目录
|
||||||
:param cookie: cookie
|
:param cookie: cookie
|
||||||
:param episodes: 需要下载的集数
|
:param episodes: 需要下载的集数
|
||||||
|
:param category: 分类
|
||||||
:return: 种子Hash,错误信息
|
:return: 种子Hash,错误信息
|
||||||
"""
|
"""
|
||||||
if not torrent_path or not torrent_path.exists():
|
if not torrent_path or not torrent_path.exists():
|
||||||
@ -61,7 +62,8 @@ class QbittorrentModule(_ModuleBase):
|
|||||||
download_dir=str(download_dir),
|
download_dir=str(download_dir),
|
||||||
is_paused=is_paused,
|
is_paused=is_paused,
|
||||||
tag=tags,
|
tag=tags,
|
||||||
cookie=cookie)
|
cookie=cookie,
|
||||||
|
category=category)
|
||||||
if not state:
|
if not state:
|
||||||
return None, f"添加种子任务失败:{torrent_path}"
|
return None, f"添加种子任务失败:{torrent_path}"
|
||||||
else:
|
else:
|
||||||
|
@ -177,6 +177,7 @@ class Qbittorrent(metaclass=Singleton):
|
|||||||
is_paused: bool = False,
|
is_paused: bool = False,
|
||||||
download_dir: str = None,
|
download_dir: str = None,
|
||||||
tag: Union[str, list] = None,
|
tag: Union[str, list] = None,
|
||||||
|
category: str = None,
|
||||||
cookie=None
|
cookie=None
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""
|
"""
|
||||||
@ -184,6 +185,7 @@ class Qbittorrent(metaclass=Singleton):
|
|||||||
:param content: 种子urls或文件内容
|
:param content: 种子urls或文件内容
|
||||||
:param is_paused: 添加后暂停
|
:param is_paused: 添加后暂停
|
||||||
:param tag: 标签
|
:param tag: 标签
|
||||||
|
:param category: 种子分类
|
||||||
:param download_dir: 下载路径
|
:param download_dir: 下载路径
|
||||||
:param cookie: 站点Cookie用于辅助下载种子
|
:param cookie: 站点Cookie用于辅助下载种子
|
||||||
:return: bool
|
:return: bool
|
||||||
@ -191,6 +193,7 @@ class Qbittorrent(metaclass=Singleton):
|
|||||||
if not self.qbc or not content:
|
if not self.qbc or not content:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
# 下载内容
|
||||||
if isinstance(content, str):
|
if isinstance(content, str):
|
||||||
urls = content
|
urls = content
|
||||||
torrent_files = None
|
torrent_files = None
|
||||||
@ -198,20 +201,26 @@ class Qbittorrent(metaclass=Singleton):
|
|||||||
urls = None
|
urls = None
|
||||||
torrent_files = content
|
torrent_files = content
|
||||||
|
|
||||||
|
# 保存目录
|
||||||
if download_dir:
|
if download_dir:
|
||||||
save_path = download_dir
|
save_path = download_dir
|
||||||
is_auto = False
|
|
||||||
else:
|
else:
|
||||||
save_path = None
|
save_path = None
|
||||||
is_auto = None
|
|
||||||
|
|
||||||
|
# 标签
|
||||||
if tag:
|
if tag:
|
||||||
tags = tag
|
tags = tag
|
||||||
else:
|
else:
|
||||||
tags = None
|
tags = None
|
||||||
|
|
||||||
try:
|
# 分类自动管理
|
||||||
|
if category and settings.QB_CATEGORY:
|
||||||
|
is_auto = True
|
||||||
|
else:
|
||||||
|
is_auto = False
|
||||||
|
category = None
|
||||||
|
|
||||||
|
try:
|
||||||
# 添加下载
|
# 添加下载
|
||||||
qbc_ret = self.qbc.torrents_add(urls=urls,
|
qbc_ret = self.qbc.torrents_add(urls=urls,
|
||||||
torrent_files=torrent_files,
|
torrent_files=torrent_files,
|
||||||
@ -220,7 +229,8 @@ class Qbittorrent(metaclass=Singleton):
|
|||||||
tags=tags,
|
tags=tags,
|
||||||
use_auto_torrent_management=is_auto,
|
use_auto_torrent_management=is_auto,
|
||||||
is_sequential_download=True,
|
is_sequential_download=True,
|
||||||
cookie=cookie)
|
cookie=cookie,
|
||||||
|
category=category)
|
||||||
return True if qbc_ret and str(qbc_ret).find("Ok") != -1 else False
|
return True if qbc_ret and str(qbc_ret).find("Ok") != -1 else False
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
logger.error(f"添加种子出错:{err}")
|
logger.error(f"添加种子出错:{err}")
|
||||||
|
@ -37,13 +37,14 @@ class TransmissionModule(_ModuleBase):
|
|||||||
self.transmission = Transmission()
|
self.transmission = Transmission()
|
||||||
|
|
||||||
def download(self, torrent_path: Path, download_dir: Path, cookie: str,
|
def download(self, torrent_path: Path, download_dir: Path, cookie: str,
|
||||||
episodes: Set[int] = None) -> Optional[Tuple[Optional[str], str]]:
|
episodes: Set[int] = None, category: str = None) -> Optional[Tuple[Optional[str], str]]:
|
||||||
"""
|
"""
|
||||||
根据种子文件,选择并添加下载任务
|
根据种子文件,选择并添加下载任务
|
||||||
:param torrent_path: 种子文件地址
|
:param torrent_path: 种子文件地址
|
||||||
:param download_dir: 下载目录
|
:param download_dir: 下载目录
|
||||||
:param cookie: cookie
|
:param cookie: cookie
|
||||||
:param episodes: 需要下载的集数
|
:param episodes: 需要下载的集数
|
||||||
|
:param category: 分类,TR中未使用
|
||||||
:return: 种子Hash
|
:return: 种子Hash
|
||||||
"""
|
"""
|
||||||
# 如果要选择文件则先暂停
|
# 如果要选择文件则先暂停
|
||||||
|
Loading…
x
Reference in New Issue
Block a user