mirror of
https://github.com/d0zingcat/MoviePilot-Plugins.git
synced 2026-05-13 23:16:47 +00:00
fix 媒体文件同步删除v1.6=>修复删除辅种
This commit is contained in:
@@ -130,11 +130,12 @@
|
||||
"name": "媒体文件同步删除",
|
||||
"description": "同步删除历史记录、源文件和下载任务。",
|
||||
"labels": "文件整理",
|
||||
"version": "1.5",
|
||||
"version": "1.6",
|
||||
"icon": "mediasyncdel.png",
|
||||
"author": "thsrite",
|
||||
"level": 1,
|
||||
"history": {
|
||||
"v1.6": "修复删除辅种",
|
||||
"v1.5": "支持手动删除订阅历史记录(本次更新之后的历史)"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -17,9 +17,6 @@ from app.db.models.transferhistory import TransferHistory
|
||||
from app.log import logger
|
||||
from app.modules.emby import Emby
|
||||
from app.modules.jellyfin import Jellyfin
|
||||
from app.modules.qbittorrent import Qbittorrent
|
||||
from app.modules.themoviedb.tmdbv3api import Episode
|
||||
from app.modules.transmission import Transmission
|
||||
from app.plugins import _PluginBase
|
||||
from app.schemas.types import NotificationType, EventType, MediaType, MediaImageType
|
||||
|
||||
@@ -32,7 +29,7 @@ class MediaSyncDel(_PluginBase):
|
||||
# 插件图标
|
||||
plugin_icon = "mediasyncdel.png"
|
||||
# 插件版本
|
||||
plugin_version = "1.5"
|
||||
plugin_version = "1.6"
|
||||
# 插件作者
|
||||
plugin_author = "thsrite"
|
||||
# 作者主页
|
||||
@@ -45,7 +42,6 @@ class MediaSyncDel(_PluginBase):
|
||||
auth_level = 1
|
||||
|
||||
# 私有属性
|
||||
episode = None
|
||||
_scheduler: Optional[BackgroundScheduler] = None
|
||||
_enabled = False
|
||||
_sync_type: str = ""
|
||||
@@ -58,16 +54,11 @@ class MediaSyncDel(_PluginBase):
|
||||
_transferchain = None
|
||||
_transferhis = None
|
||||
_downloadhis = None
|
||||
qb = None
|
||||
tr = None
|
||||
|
||||
def init_plugin(self, config: dict = None):
|
||||
self._transferchain = TransferChain()
|
||||
self._transferhis = self._transferchain.transferhis
|
||||
self._downloadhis = self._transferchain.downloadhis
|
||||
self.episode = Episode()
|
||||
self.qb = Qbittorrent()
|
||||
self.tr = Transmission()
|
||||
|
||||
# 停止现有任务
|
||||
self.stop_service()
|
||||
@@ -1199,12 +1190,8 @@ class MediaSyncDel(_PluginBase):
|
||||
# 删除转种后任务
|
||||
logger.info(f"删除转种后下载任务:{download} - {download_id}")
|
||||
# 删除转种后下载任务
|
||||
if download == "transmission":
|
||||
self.tr.delete_torrents(delete_file=True,
|
||||
ids=download_id)
|
||||
else:
|
||||
self.qb.delete_torrents(delete_file=True,
|
||||
ids=download_id)
|
||||
self.chain.remove_torrents(hashs=torrent_hash,
|
||||
downloader=download)
|
||||
handle_torrent_hashs.append(download_id)
|
||||
else:
|
||||
# 暂停种子
|
||||
@@ -1219,10 +1206,7 @@ class MediaSyncDel(_PluginBase):
|
||||
|
||||
logger.info(f"暂停转种后下载任务:{download} - {download_id}")
|
||||
# 删除转种后下载任务
|
||||
if download == "transmission":
|
||||
self.tr.stop_torrents(ids=download_id)
|
||||
else:
|
||||
self.qb.stop_torrents(ids=download_id)
|
||||
self.chain.stop_torrents(hashs=download_id, downloader=download)
|
||||
handle_torrent_hashs.append(download_id)
|
||||
else:
|
||||
# 未转种de情况
|
||||
@@ -1237,8 +1221,7 @@ class MediaSyncDel(_PluginBase):
|
||||
handle_torrent_hashs.append(download_id)
|
||||
|
||||
# 处理辅种
|
||||
handle_torrent_hashs = self.__del_seed(download=download,
|
||||
download_id=download_id,
|
||||
handle_torrent_hashs = self.__del_seed(download_id=download_id,
|
||||
delete_flag=delete_flag,
|
||||
handle_torrent_hashs=handle_torrent_hashs)
|
||||
# 处理合集
|
||||
@@ -1284,27 +1267,19 @@ class MediaSyncDel(_PluginBase):
|
||||
|
||||
# 删除合集种子
|
||||
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)
|
||||
|
||||
self.chain.remove_torrents(hashs=download_file.download_hash,
|
||||
downloader=download_file.downloader)
|
||||
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)
|
||||
self.chain.stop_torrents(hashs=download_file.download_hash,
|
||||
downloader=download_file.downloader)
|
||||
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,
|
||||
handle_torrent_hashs = self.__del_seed(download_id=download_file.download_hash,
|
||||
delete_flag=delete_flag,
|
||||
handle_torrent_hashs=handle_torrent_hashs)
|
||||
except Exception as e:
|
||||
@@ -1313,7 +1288,7 @@ class MediaSyncDel(_PluginBase):
|
||||
|
||||
return handle_torrent_hashs
|
||||
|
||||
def __del_seed(self, download, download_id, delete_flag, handle_torrent_hashs):
|
||||
def __del_seed(self, download_id, delete_flag, handle_torrent_hashs):
|
||||
"""
|
||||
删除辅种
|
||||
"""
|
||||
@@ -1337,30 +1312,18 @@ class MediaSyncDel(_PluginBase):
|
||||
# 删除辅种历史
|
||||
for torrent in torrents:
|
||||
handle_torrent_hashs.append(torrent)
|
||||
if str(download) == "qbittorrent":
|
||||
# 删除辅种
|
||||
if delete_flag:
|
||||
logger.info(f"删除辅种:{downloader} - {torrent}")
|
||||
self.qb.delete_torrents(delete_file=True,
|
||||
ids=torrent)
|
||||
# 暂停辅种
|
||||
else:
|
||||
self.qb.stop_torrents(ids=torrent)
|
||||
logger.info(f"辅种:{downloader} - {torrent} 暂停")
|
||||
# 删除辅种
|
||||
if delete_flag:
|
||||
logger.info(f"删除辅种:{downloader} - {torrent}")
|
||||
self.chain.remove_torrents(hashs=torrent,
|
||||
downloader=downloader)
|
||||
# 暂停辅种
|
||||
else:
|
||||
# 删除辅种
|
||||
if delete_flag:
|
||||
logger.info(f"删除辅种:{downloader} - {torrent}")
|
||||
self.tr.delete_torrents(delete_file=True,
|
||||
ids=torrent)
|
||||
# 暂停辅种
|
||||
else:
|
||||
self.tr.stop_torrents(ids=torrent)
|
||||
logger.info(f"辅种:{downloader} - {torrent} 暂停")
|
||||
self.chain.stop_torrents(hashs=torrent, download=downloader)
|
||||
logger.info(f"辅种:{downloader} - {torrent} 暂停")
|
||||
|
||||
# 处理辅种的辅种
|
||||
handle_torrent_hashs = self.__del_seed(download=downloader,
|
||||
download_id=torrent,
|
||||
handle_torrent_hashs = self.__del_seed(download_id=torrent,
|
||||
delete_flag=delete_flag,
|
||||
handle_torrent_hashs=handle_torrent_hashs)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user