From d970462315e92adedced7049692b00462dd89143 Mon Sep 17 00:00:00 2001 From: thsrite Date: Wed, 22 Nov 2023 09:26:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=88=A0=E9=99=A4=E5=90=88?= =?UTF-8?q?=E9=9B=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/mediasyncdel/__init__.py | 87 +++++++++++++++++--------------- 1 file changed, 45 insertions(+), 42 deletions(-) diff --git a/plugins/mediasyncdel/__init__.py b/plugins/mediasyncdel/__init__.py index 550e899..20e3ce3 100644 --- a/plugins/mediasyncdel/__init__.py +++ b/plugins/mediasyncdel/__init__.py @@ -1210,51 +1210,54 @@ class MediaSyncDel(_PluginBase): 处理合集 """ try: - download_file = self._downloadhis.get_file_by_fullpath(fullpath=src) - # src查询记录 判断download_hash是否不一致 - if download_file and str(download_file.download_hash) != str(torrent_hash): - # 查询新download_hash对应files数量 - hash_download_files = self._downloadhis.get_files_by_hash( - download_hash=download_file.download_hash) - # 新download_hash对应files数量 > 删种download_hash对应files数量 = 合集种子 - if hash_download_files \ - and len(hash_download_files) > len(download_files) \ - and hash_download_files[0].id > download_files[-1].id: - # 查询未删除数 - no_del_cnt = 0 - for hash_download_file in hash_download_files: - if hash_download_file and hash_download_file.state and int( - hash_download_file.state) == 1: - no_del_cnt += 1 - if no_del_cnt > 0: - logger.info(f"合集种子 {download_file.download_hash} 文件未完全删除,执行暂停种子操作") - delete_flag = False + src_download_files = self._downloadhis.get_files_by_fullpath(fullpath=src) + if src_download_files: + for download_file in src_download_files: + # src查询记录 判断download_hash是否不一致 + if download_file and download_file.download_hash and str(download_file.download_hash) != str( + torrent_hash): + # 查询新download_hash对应files数量 + hash_download_files = self._downloadhis.get_files_by_hash( + download_hash=download_file.download_hash) + # 新download_hash对应files数量 > 删种download_hash对应files数量 = 合集种子 + if hash_download_files \ + and len(hash_download_files) > len(download_files) \ + and hash_download_files[0].id > download_files[-1].id: + # 查询未删除数 + no_del_cnt = 0 + for hash_download_file in hash_download_files: + if hash_download_file and hash_download_file.state and int( + hash_download_file.state) == 1: + no_del_cnt += 1 + if no_del_cnt > 0: + logger.info(f"合集种子 {download_file.download_hash} 文件未完全删除,执行暂停种子操作") + delete_flag = False - # 删除合集种子 - if delete_flag: - if str(download_file.downloader) == "transmission": - self.tr.delete_torrents(delete_file=True, - ids=download_file.download_hash) - else: - self.qb.delete_torrents(delete_file=True, - ids=download_file.download_hash) + # 删除合集种子 + if delete_flag: + if str(download_file.downloader) == "transmission": + self.tr.delete_torrents(delete_file=True, + ids=download_file.download_hash) + else: + self.qb.delete_torrents(delete_file=True, + ids=download_file.download_hash) - logger.info(f"删除合集种子 {download_file.downloader} {download_file.download_hash}") - else: - # 暂停合集种子 - if str(download_file.downloader) == "transmission": - self.tr.stop_torrents(ids=download_file.download_hash) - else: - self.qb.stop_torrents(ids=download_file.download_hash) - logger.info(f"暂停合集种子 {download_file.downloader} {download_file.download_hash}") - # 已处理种子+1 - handle_torrent_hashs.append(download_file.download_hash) + logger.info(f"删除合集种子 {download_file.downloader} {download_file.download_hash}") + else: + # 暂停合集种子 + if str(download_file.downloader) == "transmission": + self.tr.stop_torrents(ids=download_file.download_hash) + else: + self.qb.stop_torrents(ids=download_file.download_hash) + logger.info(f"暂停合集种子 {download_file.downloader} {download_file.download_hash}") + # 已处理种子+1 + handle_torrent_hashs.append(download_file.download_hash) - # 处理合集辅种 - handle_torrent_hashs = self.__del_seed(download=download_file.downloader, - download_id=download_file.download_hash, - delete_flag=delete_flag, - handle_torrent_hashs=handle_torrent_hashs) + # 处理合集辅种 + handle_torrent_hashs = self.__del_seed(download=download_file.downloader, + download_id=download_file.download_hash, + delete_flag=delete_flag, + handle_torrent_hashs=handle_torrent_hashs) except Exception as e: logger.error(f"处理 {torrent_hash} 合集失败") print(str(e))