Merge pull request #69 from lingjiameng/main

This commit is contained in:
jxxghp
2024-02-25 23:51:02 +08:00
committed by GitHub

View File

@@ -59,6 +59,7 @@ class TorrentTransfer(_PluginBase):
_deletesource = False
_fromtorrentpath = None
_autostart = False
_transferemptylabel = False
# 退出事件
_event = Event()
# 待检查种子清单
@@ -85,6 +86,7 @@ class TorrentTransfer(_PluginBase):
self._fromtorrentpath = config.get("fromtorrentpath")
self._nopaths = config.get("nopaths")
self._autostart = config.get("autostart")
self._transferemptylabel = config.get("transferemptylabel")
# 停止现有任务
self.stop_service()
@@ -131,7 +133,8 @@ class TorrentTransfer(_PluginBase):
"deletesource": self._deletesource,
"fromtorrentpath": self._fromtorrentpath,
"nopaths": self._nopaths,
"autostart": self._autostart
"autostart": self._autostart,
"transferemptylabel": self._transferemptylabel
})
# 启动服务
@@ -191,7 +194,7 @@ class TorrentTransfer(_PluginBase):
'component': 'VCol',
'props': {
'cols': 12,
'md': 6
'md': 4
},
'content': [
{
@@ -207,7 +210,7 @@ class TorrentTransfer(_PluginBase):
'component': 'VCol',
'props': {
'cols': 12,
'md': 6
'md': 4
},
'content': [
{
@@ -218,6 +221,22 @@ class TorrentTransfer(_PluginBase):
}
}
]
},
{
'component': 'VCol',
'props': {
'cols': 12,
'md': 4
},
'content': [
{
'component': 'VSwitch',
'props': {
'model': 'transferemptylabel',
'label': '转移无标签种子',
}
}
]
}
]
},
@@ -463,7 +482,8 @@ class TorrentTransfer(_PluginBase):
"deletesource": False,
"fromtorrentpath": "",
"nopaths": "",
"autostart": True
"autostart": True,
"transferemptylabel": False
}
def get_page(self) -> List[dict]:
@@ -560,26 +580,37 @@ class TorrentTransfer(_PluginBase):
# 获取种子标签
torrent_labels = self.__get_label(torrent, downloader)
# 排除含有不转移的标签
if torrent_labels and self._nolabels:
is_skip = False
for label in self._nolabels.split(','):
if label in torrent_labels:
logger.info(f"种子 {hash_str} 含有不转移标签 {label},跳过 ...")
is_skip = True
break
if is_skip:
continue
# 排除不含有转移标签的种子
if torrent_labels and self._includelabels:
is_skip = False
for label in self._includelabels.split(','):
if label not in torrent_labels:
logger.info(f"种子 {hash_str} 不含有转移标签 {label},跳过 ...")
is_skip = True
break
if is_skip:
# 种子为无标签,则进行规范化
is_torrent_labels_empty = torrent_labels == [''] or torrent_labels == [] or torrent_labels is None
if is_torrent_labels_empty:
torrent_labels = []
#根据设置决定是否转移无标签的种子
if is_torrent_labels_empty:
if not self._transferemptylabel:
continue
else:
# 排除含有不转移的标签
if self._nolabels:
is_skip = False
for label in self._nolabels.split(','):
if label in torrent_labels:
logger.info(f"种子 {hash_str} 含有不转移标签 {label},跳过 ...")
is_skip = True
break
if is_skip:
continue
# 排除不含有转移标签的种子
if self._includelabels:
is_skip = False
for label in self._includelabels.split(','):
if label not in torrent_labels:
logger.info(f"种子 {hash_str} 不含有转移标签 {label},跳过 ...")
is_skip = True
break
if is_skip:
continue
# 添加转移数据
trans_torrents.append({