Merge pull request #484 from thsrite/main
This commit is contained in:
commit
47b7dade5d
@ -573,15 +573,15 @@ class MediaSyncDel(_PluginBase):
|
||||
if transferhis.download_hash:
|
||||
try:
|
||||
# 2、判断种子是否被删除完
|
||||
delete_flag, success_flag = self.handle_torrent(src=transferhis.src,
|
||||
torrent_hash=transferhis.download_hash)
|
||||
delete_flag, success_flag, handle_cnt = self.handle_torrent(src=transferhis.src,
|
||||
torrent_hash=transferhis.download_hash)
|
||||
if not success_flag:
|
||||
error_cnt += 1
|
||||
else:
|
||||
if delete_flag:
|
||||
del_cnt += 1
|
||||
del_cnt += handle_cnt
|
||||
else:
|
||||
stop_cnt += 1
|
||||
stop_cnt += handle_cnt
|
||||
except Exception as e:
|
||||
logger.error("删除种子失败,尝试删除源文件:%s" % str(e))
|
||||
|
||||
@ -596,15 +596,22 @@ class MediaSyncDel(_PluginBase):
|
||||
episode_num=episode_num)
|
||||
if images:
|
||||
image = self.get_tmdbimage_url(images[-1].get("file_path"), prefix="original")
|
||||
|
||||
torrent_cnt_msg = ""
|
||||
if del_cnt:
|
||||
torrent_cnt_msg += f"删除种子{del_cnt}个\n"
|
||||
if stop_cnt:
|
||||
torrent_cnt_msg += f"暂停种子{stop_cnt}个\n"
|
||||
if error_cnt:
|
||||
torrent_cnt_msg += f"删种失败{error_cnt}个\n"
|
||||
# 发送通知
|
||||
self.post_message(
|
||||
mtype=NotificationType.MediaServer,
|
||||
title="媒体库同步删除任务完成",
|
||||
image=image,
|
||||
text=f"{msg}\n"
|
||||
f"删除{del_cnt}个\n"
|
||||
f"暂停{stop_cnt}个\n"
|
||||
f"错误{error_cnt}个\n"
|
||||
f"删除记录{len(transfer_history)}个\n"
|
||||
f"{torrent_cnt_msg}"
|
||||
f"时间 {time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))}"
|
||||
)
|
||||
|
||||
@ -771,15 +778,15 @@ class MediaSyncDel(_PluginBase):
|
||||
if transferhis.download_hash:
|
||||
try:
|
||||
# 2、判断种子是否被删除完
|
||||
delete_flag, success_flag = self.handle_torrent(src=transferhis.src,
|
||||
torrent_hash=transferhis.download_hash)
|
||||
delete_flag, success_flag, handle_cnt = self.handle_torrent(src=transferhis.src,
|
||||
torrent_hash=transferhis.download_hash)
|
||||
if not success_flag:
|
||||
error_cnt += 1
|
||||
else:
|
||||
if delete_flag:
|
||||
del_cnt += 1
|
||||
del_cnt += handle_cnt
|
||||
else:
|
||||
stop_cnt += 1
|
||||
stop_cnt += handle_cnt
|
||||
except Exception as e:
|
||||
logger.error("删除种子失败,尝试删除源文件:%s" % str(e))
|
||||
|
||||
@ -787,13 +794,19 @@ class MediaSyncDel(_PluginBase):
|
||||
|
||||
# 发送消息
|
||||
if self._notify:
|
||||
torrent_cnt_msg = ""
|
||||
if del_cnt:
|
||||
torrent_cnt_msg += f"删除种子{del_cnt}个\n"
|
||||
if stop_cnt:
|
||||
torrent_cnt_msg += f"暂停种子{stop_cnt}个\n"
|
||||
if error_cnt:
|
||||
torrent_cnt_msg += f"删种失败{error_cnt}个\n"
|
||||
self.post_message(
|
||||
mtype=NotificationType.MediaServer,
|
||||
title="媒体库同步删除任务完成",
|
||||
text=f"{msg}\n"
|
||||
f"删除{del_cnt}个\n"
|
||||
f"暂停{stop_cnt}个\n"
|
||||
f"错误{error_cnt}个\n"
|
||||
f"删除记录{len(transfer_history)}个\n"
|
||||
f"{torrent_cnt_msg}"
|
||||
f"时间 {time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))}",
|
||||
image=image)
|
||||
|
||||
@ -827,6 +840,7 @@ class MediaSyncDel(_PluginBase):
|
||||
plugin_id=plugin_id)
|
||||
logger.info(f"查询到 {history_key} 转种历史 {transfer_history}")
|
||||
|
||||
handle_cnt = 0
|
||||
try:
|
||||
# 删除本次种子记录
|
||||
self._downloadhis.delete_file_by_fullpath(fullpath=src)
|
||||
@ -836,7 +850,7 @@ class MediaSyncDel(_PluginBase):
|
||||
if not download_files:
|
||||
logger.error(
|
||||
f"未查询到种子任务 {torrent_hash} 存在文件记录,未执行下载器文件同步或该种子已被删除")
|
||||
return False, False
|
||||
return False, False, 0
|
||||
|
||||
# 查询未删除数
|
||||
no_del_cnt = 0
|
||||
@ -871,6 +885,7 @@ class MediaSyncDel(_PluginBase):
|
||||
# 删除源种子
|
||||
logger.info(f"删除源下载器下载任务:{settings.DOWNLOADER} - {torrent_hash}")
|
||||
self.chain.remove_torrents(torrent_hash)
|
||||
handle_cnt += 1
|
||||
|
||||
# 删除转种后任务
|
||||
logger.info(f"删除转种后下载任务:{download} - {download_id}")
|
||||
@ -881,6 +896,7 @@ class MediaSyncDel(_PluginBase):
|
||||
else:
|
||||
self.qb.delete_torrents(delete_file=True,
|
||||
ids=download_id)
|
||||
handle_cnt += 1
|
||||
else:
|
||||
# 暂停种子
|
||||
# 转种后未删除源种时,同步暂停源种
|
||||
@ -890,6 +906,7 @@ class MediaSyncDel(_PluginBase):
|
||||
# 暂停源种子
|
||||
logger.info(f"暂停源下载器下载任务:{settings.DOWNLOADER} - {torrent_hash}")
|
||||
self.chain.stop_torrents(torrent_hash)
|
||||
handle_cnt += 1
|
||||
|
||||
else:
|
||||
# 未转种de情况
|
||||
@ -901,16 +918,20 @@ class MediaSyncDel(_PluginBase):
|
||||
# 暂停源种子
|
||||
logger.info(f"暂停源下载器下载任务:{download} - {download_id}")
|
||||
self.chain.stop_torrents(download_id)
|
||||
handle_cnt += 1
|
||||
|
||||
# 处理辅种
|
||||
self.__del_seed(download=download, download_id=download_id, action_flag="del" if delete_flag else 'stop')
|
||||
handle_cnt = self.__del_seed(download=download,
|
||||
download_id=download_id,
|
||||
action_flag="del" if delete_flag else 'stop',
|
||||
handle_cnt=handle_cnt)
|
||||
|
||||
return delete_flag, True
|
||||
return delete_flag, True, handle_cnt
|
||||
except Exception as e:
|
||||
logger.error(f"删种失败: {e}")
|
||||
return False, False
|
||||
return False, False, 0
|
||||
|
||||
def __del_seed(self, download, download_id, action_flag):
|
||||
def __del_seed(self, download, download_id, action_flag, handle_cnt):
|
||||
"""
|
||||
删除辅种
|
||||
"""
|
||||
@ -934,6 +955,7 @@ class MediaSyncDel(_PluginBase):
|
||||
# 删除辅种历史中与本下载器相同的辅种记录
|
||||
if str(downloader) == str(download):
|
||||
for torrent in torrents:
|
||||
handle_cnt += 1
|
||||
if str(download) == "qbittorrent":
|
||||
# 删除辅种
|
||||
if action_flag == "del":
|
||||
@ -964,6 +986,8 @@ class MediaSyncDel(_PluginBase):
|
||||
value=seed_history,
|
||||
plugin_id=plugin_id)
|
||||
|
||||
return handle_cnt
|
||||
|
||||
@staticmethod
|
||||
def parse_emby_log(last_time):
|
||||
log_url = "{HOST}System/Logs/embyserver.txt?api_key={APIKEY}"
|
||||
|
Loading…
x
Reference in New Issue
Block a user