diff --git a/package.json b/package.json index 36e57a6..4cc27bb 100644 --- a/package.json +++ b/package.json @@ -210,7 +210,7 @@ "BrushFlow": { "name": "站点刷流", "description": "自动托管刷流,将会提高对应站点的访问频率。", - "version": "1.3", + "version": "1.4", "icon": "brush.jpg", "author": "jxxghp", "level": 2 @@ -258,7 +258,7 @@ "CloudDiskDel": { "name": "云盘文件删除", "description": "媒体库删除strm文件后同步删除云盘资源。", - "version": "1.2", + "version": "1.3", "icon": "clouddisk.png", "author": "thsrite", "level": 1 @@ -346,7 +346,7 @@ "RemoveLink": { "name": "清理硬链接", "description": "监控目录内文件被删除时,同步删除监控目录内所有和它硬链接的文件", - "version": "1.5", + "version": "1.6", "icon": "Ombi_A.png", "author": "DzAvril", "level": 1 @@ -398,6 +398,5 @@ "icon": "Themeengine_A.png", "author": "jeblove", "level": 1 - }, - + } } diff --git a/plugins/brushflow/__init__.py b/plugins/brushflow/__init__.py index 27cd7bf..b9ec42f 100644 --- a/plugins/brushflow/__init__.py +++ b/plugins/brushflow/__init__.py @@ -18,6 +18,7 @@ from app.modules.qbittorrent import Qbittorrent from app.modules.transmission import Transmission from app.plugins import _PluginBase from app.schemas import Notification, NotificationType, TorrentInfo +from app.utils.http import RequestUtils from app.utils.string import StringUtils lock = threading.Lock() @@ -31,7 +32,7 @@ class BrushFlow(_PluginBase): # 插件图标 plugin_icon = "brush.jpg" # 插件版本 - plugin_version = "1.3" + plugin_version = "1.4" # 插件作者 plugin_author = "jxxghp" # 作者主页 @@ -117,6 +118,7 @@ class BrushFlow(_PluginBase): self._dl_speed = config.get("dl_speed") self._save_path = config.get("save_path") self._clear_task = config.get("clear_task") + self._offline_mode = config.get("offline_mode") # 过滤掉已删除的站点 self._brushsites = [site.get("id") for site in self.sites.get_indexers() if @@ -348,6 +350,22 @@ class BrushFlow(_PluginBase): } } ] + }, + { + 'component': 'VCol', + 'props': { + 'cols': 12, + 'md': 4 + }, + 'content': [ + { + 'component': 'VSwitch', + 'props': { + 'model': 'offline_mode', + 'label': '离线下载种子', + } + } + ] } ] }, @@ -801,6 +819,7 @@ class BrushFlow(_PluginBase): "enabled": False, "notify": True, "onlyonce": False, + "offline_mode": False, "clear_task": False, "freeleech": "free", "hr": "yes", @@ -1296,7 +1315,8 @@ class BrushFlow(_PluginBase): "up_speed": self._up_speed, "dl_speed": self._dl_speed, "save_path": self._save_path, - "clear_task": self._clear_task + "clear_task": self._clear_task, + "offline_mode": self._offline_mode }) def brush(self): @@ -1641,7 +1661,15 @@ class BrushFlow(_PluginBase): down_speed = down_speed * 1024 if down_speed else None # 生成随机Tag tag = StringUtils.generate_random_str(10) - state = self.qb.add_torrent(content=torrent.enclosure, + content = torrent.enclosure + if self._offline_mode: + torrent_res = RequestUtils(cookies=torrent.site_cookie, + ua=torrent.site_ua).get_res(url=content) + if torrent_res.ok: + content = torrent_res.content + else: + logger.error('下载种子文件失败,继续提交种子链接进行下载') + state = self.qb.add_torrent(content=content, download_dir=self._save_path or None, cookie=torrent.site_cookie, tag=["已整理", "刷流", tag], diff --git a/plugins/clouddiskdel/__init__.py b/plugins/clouddiskdel/__init__.py index cb54d19..e827ca0 100644 --- a/plugins/clouddiskdel/__init__.py +++ b/plugins/clouddiskdel/__init__.py @@ -1,3 +1,5 @@ +import json +import os import shutil import time from pathlib import Path @@ -20,7 +22,7 @@ class CloudDiskDel(_PluginBase): # 插件图标 plugin_icon = "clouddisk.png" # 插件版本 - plugin_version = "1.2" + plugin_version = "1.3" # 插件作者 plugin_author = "thsrite" # 作者主页 @@ -105,6 +107,7 @@ class CloudDiskDel(_PluginBase): for file in files: Path(file).unlink() logger.info(f"云盘文件 {file} 已删除") + self.__remove_json(file) remove_flag = True if not remove_flag: @@ -113,11 +116,13 @@ class CloudDiskDel(_PluginBase): if Path(file).exists(): Path(file).unlink() logger.info(f"云盘文件 {file} 已删除") + self.__remove_json(file) else: # 非根目录,才删除目录 shutil.rmtree(path) # 删除目录 logger.warn(f"云盘目录 {path} 已删除") + self.__remove_json(path) # 判断当前媒体父路径下是否有媒体文件,如有则无需遍历父级 if not SystemUtils.exits_files(path.parent, settings.RMT_MEDIAEXT): @@ -129,7 +134,7 @@ class CloudDiskDel(_PluginBase): # 当前路径下没有媒体文件则删除 shutil.rmtree(parent_path) logger.warn(f"云盘目录 {parent_path} 已删除") - + self.__remove_json(parent_path) break if cloud_file_flag: @@ -191,6 +196,34 @@ class CloudDiskDel(_PluginBase): # 保存历史 self.save_data("history", history) + def __remove_json(self, path): + """ + 删除json中的文件内容 + """ + try: + # 删除本地缓存文件 + cloud_files_json = os.path.join(settings.PLUGIN_DATA_PATH, "CloudStrm", "cloud_files.json") + if Path(cloud_files_json).exists(): + # 删除json文件中已删除部分文件 + # 尝试加载本地 + with open(cloud_files_json, 'r') as file: + content = file.read() + if content: + __cloud_files = json.loads(content) + if __cloud_files: + if not isinstance(__cloud_files, list): + __cloud_files = [__cloud_files] + if str(path) in __cloud_files: + # 删除已删除文件 + __cloud_files.remove(str(path)) + # 重新写入本地 + file = open(cloud_files_json, 'w') + file.write(json.dumps(__cloud_files)) + file.close() + + except Exception as e: + print(str(e)) + def get_state(self) -> bool: return self._enabled diff --git a/plugins/removelink/__init__.py b/plugins/removelink/__init__.py index 799c3c0..a8aedf7 100644 --- a/plugins/removelink/__init__.py +++ b/plugins/removelink/__init__.py @@ -28,8 +28,10 @@ class FileMonitorHandler(FileSystemEventHandler): def on_created(self, event): if event.is_directory: return - logger.info("监测到新增文件:%s" % event.src_path) file_path = Path(event.src_path) + if file_path.suffix in [".!qB", ".part", ".mp"]: + return + logger.info(f"监测到新增文件:{file_path}") if self.sync.exclude_keywords: for keyword in self.sync.exclude_keywords.split("\n"): if keyword and keyword in str(file_path): @@ -42,8 +44,10 @@ class FileMonitorHandler(FileSystemEventHandler): def on_deleted(self, event): if event.is_directory: return - logger.info("监测到删除文件:%s" % event.src_path) file_path = Path(event.src_path) + if file_path.suffix in [".!qB", ".part", ".mp"]: + return + logger.info(f"监测到删除文件:{file_path}") # 命中过滤关键字不处理 if self.sync.exclude_keywords: for keyword in self.sync.exclude_keywords.split("\n"): @@ -58,7 +62,8 @@ def updateState(monitor_dirs: List[str]): """ 更新监控目录的文件列表 """ - start_time = time.time() # 记录开始时间 + # 记录开始时间 + start_time = time.time() state_set = {} for mon_path in monitor_dirs: for root, dirs, files in os.walk(mon_path): @@ -85,7 +90,7 @@ class RemoveLink(_PluginBase): # 插件图标 plugin_icon = "Ombi_A.png" # 插件版本 - plugin_version = "1.5" + plugin_version = "1.6" # 插件作者 plugin_author = "DzAvril" # 作者主页 @@ -100,7 +105,7 @@ class RemoveLink(_PluginBase): # preivate property monitor_dirs = "" exclude_dirs = "" - exclude_keywords = ".!qB" + exclude_keywords = "" _enabled = False _notify = False _observer = [] @@ -295,7 +300,7 @@ class RemoveLink(_PluginBase): "notify": False, "onlyonce": False, "monitor_dirs": "", - "exclude_keywords": ".!qB", + "exclude_keywords": "", } def get_page(self) -> List[dict]: