Skip to content

Commit

Permalink
Merge pull request #667 from so1ve/feat/transfer-skip-verify
Browse files Browse the repository at this point in the history
  • Loading branch information
jxxghp authored Feb 4, 2025
2 parents 8346aa1 + 232b117 commit 728c012
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 11 deletions.
3 changes: 2 additions & 1 deletion package.v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,12 @@
"name": "自动转移做种",
"description": "定期转移下载器中的做种任务到另一个下载器。",
"labels": "做种",
"version": "1.9",
"version": "1.10",
"icon": "seed.png",
"author": "jxxghp",
"level": 2,
"history": {
"v1.10": "支持跳过校验(仅支持 qBittorrent)",
"v1.9": "优化执行周期输入,需要MoviePilot v2.2.1+",
"v1.8": "支持qbittorrent 5",
"v1.7": "MoviePilot V2 版本自动转移做种插件",
Expand Down
49 changes: 39 additions & 10 deletions plugins.v2/torrenttransfer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class TorrentTransfer(_PluginBase):
# 插件图标
plugin_icon = "seed.png"
# 插件版本
plugin_version = "1.9"
plugin_version = "1.10"
# 插件作者
plugin_author = "jxxghp"
# 作者主页
Expand Down Expand Up @@ -61,6 +61,7 @@ class TorrentTransfer(_PluginBase):
_deleteduplicate = False
_fromtorrentpath = None
_autostart = False
_skipverify = False
_transferemptylabel = False
_add_torrent_tags = None
# 退出事件
Expand Down Expand Up @@ -92,6 +93,7 @@ def init_plugin(self, config: dict = None):
self._fromtorrentpath = config.get("fromtorrentpath")
self._nopaths = config.get("nopaths")
self._autostart = config.get("autostart")
self._skipverify = config.get("skipverify")
self._transferemptylabel = config.get("transferemptylabel")
self._add_torrent_tags = config.get("add_torrent_tags") or ""
self._torrent_tags = self._add_torrent_tags.strip().split(",") if self._add_torrent_tags else []
Expand Down Expand Up @@ -467,6 +469,19 @@ def get_form(self) -> Tuple[List[dict], Dict[str, Any]]:
}
]
},
{
"component": "VCol",
"props": {"cols": 12, "md": 3},
"content": [
{
"component": "VSwitch",
"props": {
"model": "skipverify",
"label": "跳过校验(仅QB有效)",
},
}
],
},
{
'component': 'VCol',
'props': {
Expand Down Expand Up @@ -536,6 +551,7 @@ def get_form(self) -> Tuple[List[dict], Dict[str, Any]]:
"fromtorrentpath": "",
"nopaths": "",
"autostart": True,
"skipverify": False,
"transferemptylabel": False,
"add_torrent_tags": "已整理,转移做种"
}
Expand Down Expand Up @@ -572,7 +588,8 @@ def __download(self, service: ServiceInfo, content: bytes,
state = downloader.add_torrent(content=content,
download_dir=save_path,
is_paused=True,
tag=self._torrent_tags + [tag])
tag=self._torrent_tags + [tag],
is_skip_checking=self._skipverify)
if not state:
return None
else:
Expand Down Expand Up @@ -803,14 +820,19 @@ def transfer(self):

# TR会自动校验,QB需要手动校验
if self.downloader_helper.is_downloader("qbittorrent", service=to_service):
logger.info(f"qbittorrent 开始校验 {download_id} ...")
to_downloader.recheck_torrents(ids=[download_id])

# 追加校验任务
logger.info(f"添加校验检查任务:{download_id} ...")
if not self._recheck_torrents.get(to_service.name):
self._recheck_torrents[to_service.name] = []
self._recheck_torrents[to_service.name].append(download_id)
if self._skipverify:
if self._autostart:
logger.info(f"{download_id} 跳过校验,开启自动开始,注意观察种子的完整性")
self.__add_recheck_torrents(to_service, download_id)
else:
# 跳过校验
logger.info(f"{download_id} 跳过校验,请自行检查手动开始任务...")
else:
logger.info(f"qbittorrent 开始校验 {download_id} ...")
to_downloader.recheck_torrents(ids=[download_id])
self.__add_recheck_torrents(to_service, download_id)
else:
self.__add_recheck_torrents(to_service, download_id)

# 删除源种子,不能删除文件!
if self._deletesource:
Expand Down Expand Up @@ -843,6 +865,13 @@ def transfer(self):
logger.info(f"没有需要转移的种子")
logger.info("转移做种任务执行完成")

def __add_recheck_torrents(self, service: ServiceInfo, download_id: str):
# 追加校验任务
logger.info(f"添加校验检查任务:{download_id} ...")
if not self._recheck_torrents.get(service.name):
self._recheck_torrents[service.name] = []
self._recheck_torrents[service.name].append(download_id)

def check_recheck(self):
"""
定时检查下载器中种子是否校验完成,校验完成且完整的自动开始辅种
Expand Down

0 comments on commit 728c012

Please sign in to comment.