Merge remote-tracking branch 'origin/main'

This commit is contained in:
jxxghp
2023-11-25 07:24:21 +08:00
4 changed files with 195 additions and 53 deletions

View File

@@ -747,7 +747,7 @@ class AutoSignIn(_PluginBase):
self.eventmanager.send_event(EventType.PluginAction,
{
"site_id": site_id,
"action": "site_login"
"action": "site_refresh"
})
# 记录本次命中重试关键词的站点
if self._retry_keyword:

View File

@@ -606,8 +606,9 @@ class MediaSyncDel(_PluginBase):
self._exclude_path.split(",")):
logger.info(f"媒体路径 {media_path} 已被排除,暂不处理")
# 发送消息通知网盘删除插件删除网盘资源
self.eventmanager.send_event(EventType.Pl,
self.eventmanager.send_event(EventType.PluginAction,
{
"action": "networkdisk_del",
"media_path": media_path,
"media_name": media_name,
"tmdb_id": tmdb_id,
@@ -1209,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))

View File

@@ -55,14 +55,16 @@ class SiteRefresh(_PluginBase):
return self._enabled
@eventmanager.register(EventType.PluginAction)
def site_login(self, event):
def site_refresh(self, event):
"""
开始站点登录
开始站点登录刷新Cookie&UA
"""
if not self.get_state():
return
if not event:
return
event_data = event.event_data
if not event_data or event_data.get("action") != "site_login":
if not event_data or event_data.get("action") != "site_refresh":
return
# 站点id
site_id = event_data.get("site_id")