From b80243e2f2714394575a35b2c9276438be85367c Mon Sep 17 00:00:00 2001 From: d0zingcat Date: Wed, 6 Mar 2024 12:07:07 +0800 Subject: [PATCH] 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],