From b80243e2f2714394575a35b2c9276438be85367c Mon Sep 17 00:00:00 2001 From: d0zingcat Date: Wed, 6 Mar 2024 12:07:07 +0800 Subject: [PATCH 1/8] allow mp to download torrents and send to qb Signed-off-by: d0zingcat --- plugins/brushflow/__init__.py | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/plugins/brushflow/__init__.py b/plugins/brushflow/__init__.py index 147b639..be85573 100644 --- a/plugins/brushflow/__init__.py +++ b/plugins/brushflow/__init__.py @@ -1,4 +1,5 @@ import re +import requests import threading import time from datetime import datetime, timedelta @@ -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", @@ -1641,7 +1660,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_resp = requests.get(content, + headers={'User-Agent': torrent.site_ua.strip(), 'cookie': torrent.site_cookie.strip()}) + if torrent_resp.ok: + content = torrent_resp.content + else: + logger.error('下载种子文件失败,继续提交种子链接进行下载') + state = self.qb.add_torrent(content=content, download_dir=self._save_path or None, cookie=torrent.site_cookie, tag=["已整理", "刷流", tag], From dddfc0d69ad10a4018ff30ca06ad9187bca77b45 Mon Sep 17 00:00:00 2001 From: d0zingcat Date: Wed, 6 Mar 2024 12:18:11 +0800 Subject: [PATCH 2/8] fix config update Signed-off-by: d0zingcat --- plugins/brushflow/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/brushflow/__init__.py b/plugins/brushflow/__init__.py index be85573..a809c26 100644 --- a/plugins/brushflow/__init__.py +++ b/plugins/brushflow/__init__.py @@ -1315,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): From d3a067ed48b64ce2bb51c55d515c38ae1fe2bde0 Mon Sep 17 00:00:00 2001 From: d0zingcat Date: Wed, 6 Mar 2024 12:57:56 +0800 Subject: [PATCH 3/8] typo Signed-off-by: d0zingcat --- plugins/brushflow/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/brushflow/__init__.py b/plugins/brushflow/__init__.py index a809c26..35ca9a3 100644 --- a/plugins/brushflow/__init__.py +++ b/plugins/brushflow/__init__.py @@ -32,7 +32,7 @@ class BrushFlow(_PluginBase): # 插件图标 plugin_icon = "brush.jpg" # 插件版本 - plugin_version = "1.3" + plugin_version = "1.4" # 插件作者 plugin_author = "jxxghp" # 作者主页 @@ -1316,7 +1316,7 @@ class BrushFlow(_PluginBase): "dl_speed": self._dl_speed, "save_path": self._save_path, "clear_task": self._clear_task, - "offline_mode": self._offline_mode, + "offline_mode": self._offline_mode }) def brush(self): From 1a7c3bda25af838785cb8d17d0bfc060608c1501 Mon Sep 17 00:00:00 2001 From: thsrite Date: Wed, 6 Mar 2024 13:40:16 +0800 Subject: [PATCH 4/8] =?UTF-8?q?fix=20=E4=BA=91=E7=9B=98=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=88=A0=E9=99=A4=E6=9C=AC=E5=9C=B0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E7=BC=93=E5=AD=98=EF=BC=88=E9=85=8D=E5=90=88=E4=BA=91?= =?UTF-8?q?=E7=9B=98strm=E7=94=9F=E6=88=90=E6=8F=92=E4=BB=B6=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- plugins/clouddiskdel/__init__.py | 37 ++++++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 7da0d81..4e881de 100644 --- a/package.json +++ b/package.json @@ -258,7 +258,7 @@ "CloudDiskDel": { "name": "云盘文件删除", "description": "媒体库删除strm文件后同步删除云盘资源。", - "version": "1.2", + "version": "1.3", "icon": "clouddisk.png", "author": "thsrite", "level": 1 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 From a5370e2e49f5d91629b58a3d6c28c4eca1d0176c Mon Sep 17 00:00:00 2001 From: d0zingcat Date: Wed, 6 Mar 2024 16:34:16 +0800 Subject: [PATCH 5/8] use requestutils instead Signed-off-by: d0zingcat --- plugins/brushflow/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/brushflow/__init__.py b/plugins/brushflow/__init__.py index 35ca9a3..c1453b9 100644 --- a/plugins/brushflow/__init__.py +++ b/plugins/brushflow/__init__.py @@ -1,5 +1,4 @@ import re -import requests import threading import time from datetime import datetime, timedelta @@ -19,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() @@ -1663,10 +1663,10 @@ class BrushFlow(_PluginBase): tag = StringUtils.generate_random_str(10) content = torrent.enclosure if self._offline_mode: - torrent_resp = requests.get(content, - headers={'User-Agent': torrent.site_ua.strip(), 'cookie': torrent.site_cookie.strip()}) - if torrent_resp.ok: - content = torrent_resp.content + 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, From 1e383603df16219c9e0c64635ab9aff2635b47c7 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Wed, 6 Mar 2024 20:21:00 +0800 Subject: [PATCH 6/8] fix RemoveLink --- package.json | 2 +- plugins/removelink/__init__.py | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 7da0d81..4961fef 100644 --- a/package.json +++ b/package.json @@ -346,7 +346,7 @@ "RemoveLink": { "name": "清理硬链接", "description": "监控目录内文件被删除时,同步删除监控目录内所有和它硬链接的文件", - "version": "1.5", + "version": "1.6", "icon": "Ombi_A.png", "author": "DzAvril", "level": 1 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]: From bccc46d1c210716eec41c2edd795b80fc3cf1c96 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Thu, 7 Mar 2024 07:04:12 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20package.json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4961fef..73ad7f9 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 From 61665ff58ac8f01a6f9ddc944ee8f4ee0afeb005 Mon Sep 17 00:00:00 2001 From: thsrite Date: Thu, 7 Mar 2024 10:56:01 +0800 Subject: [PATCH 8/8] =?UTF-8?q?fix=205be3182b=20json=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 8d63578..b233b3f 100644 --- a/package.json +++ b/package.json @@ -398,6 +398,5 @@ "icon": "Themeengine_A.png", "author": "jeblove", "level": 1 - }, - + } }