From 588089a079de1ac3c2c26ee90938a01edbc97d3c Mon Sep 17 00:00:00 2001 From: thsrite Date: Tue, 8 Aug 2023 16:09:36 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix=20=E5=90=8C=E6=AD=A5=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=8F=92=E4=BB=B6=E5=A2=9E=E5=8A=A0=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E5=99=A8=E6=98=A0=E5=B0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/plugins/iyuuautoseed/__init__.py | 2 +- app/plugins/nastoolsync/__init__.py | 58 +++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/app/plugins/iyuuautoseed/__init__.py b/app/plugins/iyuuautoseed/__init__.py index 78c1cfcb..44564bcf 100644 --- a/app/plugins/iyuuautoseed/__init__.py +++ b/app/plugins/iyuuautoseed/__init__.py @@ -608,7 +608,7 @@ class IYUUAutoSeed(_PluginBase): if not history.get("downloader"): continue # 如果本次辅种下载器之前有过记录则继续添加 - if int(history.get("downloader")) == downloader: + if str(history.get("downloader")) == downloader: history_torrents = history.get("torrents") or [] history["torrents"] = list(set(history_torrents + success_torrents)) new_history = False diff --git a/app/plugins/nastoolsync/__init__.py b/app/plugins/nastoolsync/__init__.py index 04f65d14..5d4dcbc9 100644 --- a/app/plugins/nastoolsync/__init__.py +++ b/app/plugins/nastoolsync/__init__.py @@ -43,6 +43,7 @@ class NAStoolSync(_PluginBase): _transfer = None _plugin = None _download = None + _downloader = None def init_plugin(self, config: dict = None): self._transferhistory = TransferHistoryOper() @@ -55,6 +56,7 @@ class NAStoolSync(_PluginBase): self._site = config.get("site") self._transfer = config.get("transfer") self._plugin = config.get("plugin") + self._downloader = config.get("downloader") self._download = config.get("download") if self._nt_db_path and (self._transfer or self._plugin or self._download): @@ -97,6 +99,18 @@ class NAStoolSync(_PluginBase): def sync_plugin_history(self, plugin_history): """ 导入插件记录 + + NAStool + { + "id": "TorrentTransfer", + "key: "1-4bdc22bc1e062803c8686beb2796369c59ee141f", + "value": "{"to_download": 2, "to_download_id": "4bdc22bc1e062803c8686beb2796369c59ee141f", "delete_source": true}" + }, + { + "id": "IYUUAutoSeed", + "key: "f161efaf008d2e56e7939272e8d95eca58fa71dd", + "value": "[{"downloader": "2", "torrents": ["bd64a8edc5afe6b4beb8813bdbf6faedfb1d4cc4"]}]" + } """ # 开始计时 start_time = datetime.now() @@ -111,6 +125,26 @@ class NAStoolSync(_PluginBase): plugin_key = history[2] plugin_value = history[3] + # 处理下载器映射 + if self._downloader: + downloaders = self._downloader.split("\n") + for downloader in downloaders: + sub_downloaders = downloader.split(":") + # 转种记录 + if str(plugin_id) == "TorrentTransfer": + keys = str(plugin_key).split("-") + if int(keys[0]) == int(sub_downloaders[0]): + # 替换key + plugin_key = plugin_key.replace(keys[0], sub_downloaders[1]) + # 替换value + if int(plugin_value.get("to_download")) == int(sub_downloaders[0]): + plugin_value["to_download"] = sub_downloaders[1] + # 辅种记录 + if str(plugin_id) == "IYUUAutoSeed": + for value in plugin_value: + if int(value.get("downloader")) == int(sub_downloaders[0]): + value["downloader"] = sub_downloaders[1] + self._plugindata.save(plugin_id=plugin_id, key=plugin_key, value=plugin_value) @@ -479,6 +513,28 @@ class NAStoolSync(_PluginBase): } ] }, + { + 'component': 'VRow', + 'content': [ + { + 'component': 'VCol', + 'props': { + 'cols': 12, + }, + 'content': [ + { + 'component': 'VTextarea', + 'props': { + 'model': 'downloader', + 'rows': '2', + 'label': '下载器映射', + 'placeholder': 'NAStool下载器id:qbittorrent|transmission(一行一个)' + } + } + ] + } + ] + }, { 'component': 'VRow', 'content': [ @@ -516,7 +572,7 @@ class NAStoolSync(_PluginBase): '开启清空记录时,会在导入历史数据之前删除MoviePilot之前的记录。' '如果转移记录很多,同步时间可能会长,' '所以点击确定后页面没反应是正常现象,后台正在处理。' - '路径映射在同步转移记录时有效、站点映射在同步下载记录时有效。' + '路径映射在同步转移记录时有效、下载器映射在同步插件记录时有效、站点映射在同步下载记录时有效。' } } ] From 86e6122c86808d633c718b5d9c5eeb3107d7bee7 Mon Sep 17 00:00:00 2001 From: thsrite Date: Tue, 8 Aug 2023 16:34:40 +0800 Subject: [PATCH 2/4] fix --- app/plugins/nastoolsync/__init__.py | 35 +++++++++++++++++++---------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/app/plugins/nastoolsync/__init__.py b/app/plugins/nastoolsync/__init__.py index 5d4dcbc9..c83878e8 100644 --- a/app/plugins/nastoolsync/__init__.py +++ b/app/plugins/nastoolsync/__init__.py @@ -1,3 +1,4 @@ +import json import os import sqlite3 from datetime import datetime @@ -87,12 +88,13 @@ class NAStoolSync(_PluginBase): self.update_config( { "clear": False, - "nt_db_path": "", + "nt_db_path": self._nt_db_path, "path": self._path, + "downloader": self._downloader, "site": self._site, - "transfer": self._transfer, - "plugin": self._plugin, - "download": self._download, + "transfer": False, + "plugin": False, + "download": False, } ) @@ -130,19 +132,27 @@ class NAStoolSync(_PluginBase): downloaders = self._downloader.split("\n") for downloader in downloaders: sub_downloaders = downloader.split(":") - # 转种记录 + # 替换转种记录 if str(plugin_id) == "TorrentTransfer": keys = str(plugin_key).split("-") - if int(keys[0]) == int(sub_downloaders[0]): + if keys[0].isdigit() and int(keys[0]) == int(sub_downloaders[0]): # 替换key plugin_key = plugin_key.replace(keys[0], sub_downloaders[1]) - # 替换value - if int(plugin_value.get("to_download")) == int(sub_downloaders[0]): - plugin_value["to_download"] = sub_downloaders[1] - # 辅种记录 + + # 替换value + if isinstance(plugin_value, str): + plugin_value = json.loads(plugin_value) + if str(plugin_value.get("to_download")).isdigit() and int( + plugin_value.get("to_download")) == int(sub_downloaders[0]): + plugin_value["to_download"] = sub_downloaders[1] + + # 替换辅种记录 if str(plugin_id) == "IYUUAutoSeed": + if isinstance(plugin_value, str): + plugin_value = json.loads(plugin_value) for value in plugin_value: - if int(value.get("downloader")) == int(sub_downloaders[0]): + if str(value.get("downloader")).isdigit() and int(value.get("downloader")) == int( + sub_downloaders[0]): value["downloader"] = sub_downloaders[1] self._plugindata.save(plugin_id=plugin_id, @@ -385,7 +395,7 @@ class NAStoolSync(_PluginBase): return nt_historys def get_state(self) -> bool: - return True if self._nt_db_path else False + return True if self._transfer or self._plugin or self._download else False @staticmethod def get_command() -> List[Dict[str, Any]]: @@ -588,6 +598,7 @@ class NAStoolSync(_PluginBase): "download": False, "nt_db_path": "", "path": "", + "downloader": "", "site": "", } From e26f358f946f454f1fcfd9f42841401376445b8b Mon Sep 17 00:00:00 2001 From: thsrite Date: Tue, 8 Aug 2023 16:42:50 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fix=20=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/plugins/nastoolsync/__init__.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/plugins/nastoolsync/__init__.py b/app/plugins/nastoolsync/__init__.py index c83878e8..82556351 100644 --- a/app/plugins/nastoolsync/__init__.py +++ b/app/plugins/nastoolsync/__init__.py @@ -515,7 +515,7 @@ class NAStoolSync(_PluginBase): 'props': { 'model': 'path', 'rows': '2', - 'label': '路径映射', + 'label': '历史记录路径映射', 'placeholder': 'NAStool路径:MoviePilot路径(一行一个)' } } @@ -537,7 +537,7 @@ class NAStoolSync(_PluginBase): 'props': { 'model': 'downloader', 'rows': '2', - 'label': '下载器映射', + 'label': '插件数据下载器映射', 'placeholder': 'NAStool下载器id:qbittorrent|transmission(一行一个)' } } @@ -558,7 +558,7 @@ class NAStoolSync(_PluginBase): 'component': 'VTextarea', 'props': { 'model': 'site', - 'label': '站点映射', + 'label': '下载历史站点映射', 'placeholder': 'NAStool站点名:MoviePilot站点名(一行一个)' } } @@ -582,7 +582,6 @@ class NAStoolSync(_PluginBase): '开启清空记录时,会在导入历史数据之前删除MoviePilot之前的记录。' '如果转移记录很多,同步时间可能会长,' '所以点击确定后页面没反应是正常现象,后台正在处理。' - '路径映射在同步转移记录时有效、下载器映射在同步插件记录时有效、站点映射在同步下载记录时有效。' } } ] From d872efae3c73c11b9624f10698fe808a9c3bb7c9 Mon Sep 17 00:00:00 2001 From: thsrite Date: Tue, 8 Aug 2023 17:29:52 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix=20=E5=A4=87=E4=BB=BD=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/plugins/autobackup/__init__.py | 219 ++++++++++++++++------------- 1 file changed, 119 insertions(+), 100 deletions(-) diff --git a/app/plugins/autobackup/__init__.py b/app/plugins/autobackup/__init__.py index 9afe51b3..ee6fc20a 100644 --- a/app/plugins/autobackup/__init__.py +++ b/app/plugins/autobackup/__init__.py @@ -179,106 +179,125 @@ class AutoBackup(_PluginBase): 拼装插件配置页面,需要返回两块数据:1、页面配置;2、数据结构 """ return [ - { - 'component': 'VForm', - 'content': [ - { - 'component': 'VRow', - 'content': [ - { - 'component': 'VCol', - 'props': { - 'cols': 12, - 'md': 4 - }, - 'content': [ - { - 'component': 'VSwitch', - 'props': { - 'model': 'enabled', - 'label': '启用插件', - } - } - ] - }, - { - 'component': 'VCol', - 'props': { - 'cols': 12, - 'md': 4 - }, - 'content': [ - { - 'component': 'VSwitch', - 'props': { - 'model': 'notify', - 'label': '开启通知', - } - } - ] - }, - { - 'component': 'VCol', - 'props': { - 'cols': 12, - 'md': 4 - }, - 'content': [ - { - 'component': 'VSwitch', - 'props': { - 'model': 'onlyonce', - 'label': '立即运行一次', - } - } - ] - } - ] - }, - { - 'component': 'VRow', - 'content': [ - { - 'component': 'VCol', - 'props': { - 'cols': 12, - 'md': 6 - }, - 'content': [ - { - 'component': 'VTextField', - 'props': { - 'model': 'cron', - 'label': '备份周期' - } - } - ] - }, - { - 'component': 'VCol', - 'props': { - 'cols': 12, - 'md': 6 - }, - 'content': [ - { - 'component': 'VTextField', - 'props': { - 'model': 'cnt', - 'label': '最大保留备份数' - } - } - ] - } - ] - }, - ] - } - ], { - "enabled": False, - "request_method": "POST", - "webhook_url": "" - } + { + 'component': 'VForm', + 'content': [ + { + 'component': 'VRow', + 'content': [ + { + 'component': 'VCol', + 'props': { + 'cols': 12, + 'md': 4 + }, + 'content': [ + { + 'component': 'VSwitch', + 'props': { + 'model': 'enabled', + 'label': '启用插件', + } + } + ] + }, + { + 'component': 'VCol', + 'props': { + 'cols': 12, + 'md': 4 + }, + 'content': [ + { + 'component': 'VSwitch', + 'props': { + 'model': 'notify', + 'label': '开启通知', + } + } + ] + }, + { + 'component': 'VCol', + 'props': { + 'cols': 12, + 'md': 4 + }, + 'content': [ + { + 'component': 'VSwitch', + 'props': { + 'model': 'onlyonce', + 'label': '立即运行一次', + } + } + ] + } + ] + }, + { + 'component': 'VRow', + 'content': [ + { + 'component': 'VCol', + 'props': { + 'cols': 12, + 'md': 6 + }, + 'content': [ + { + 'component': 'VTextField', + 'props': { + 'model': 'cron', + 'label': '备份周期' + } + } + ] + }, + { + 'component': 'VCol', + 'props': { + 'cols': 12, + 'md': 6 + }, + 'content': [ + { + 'component': 'VTextField', + 'props': { + 'model': 'cnt', + 'label': '最大保留备份数' + } + } + ] + } + ] + }, + { + 'component': 'VRow', + 'content': [ + { + 'component': 'VCol', + 'props': { + 'cols': 12, + }, + 'content': [ + { + 'component': 'VAlert', + 'props': { + 'text': '备份文件路径默认为本地映射的config/plugins/AutoBackup。' + } + } + ] + } + ] + } + ] + } + ], { + "enabled": False, + "request_method": "POST", + "webhook_url": "" + } def get_page(self) -> List[dict]: pass