@ -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
|
||||
|
@ -610,7 +610,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
|
||||
|
@ -1,3 +1,4 @@
|
||||
import json
|
||||
import os
|
||||
import sqlite3
|
||||
from datetime import datetime
|
||||
@ -43,6 +44,7 @@ class NAStoolSync(_PluginBase):
|
||||
_transfer = None
|
||||
_plugin = None
|
||||
_download = None
|
||||
_downloader = None
|
||||
|
||||
def init_plugin(self, config: dict = None):
|
||||
self._transferhistory = TransferHistoryOper()
|
||||
@ -55,6 +57,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):
|
||||
@ -85,18 +88,31 @@ 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,
|
||||
}
|
||||
)
|
||||
|
||||
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 +127,34 @@ 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 keys[0].isdigit() and int(keys[0]) == int(sub_downloaders[0]):
|
||||
# 替换key
|
||||
plugin_key = plugin_key.replace(keys[0], 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 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,
|
||||
key=plugin_key,
|
||||
value=plugin_value)
|
||||
@ -351,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]]:
|
||||
@ -471,7 +515,7 @@ class NAStoolSync(_PluginBase):
|
||||
'props': {
|
||||
'model': 'path',
|
||||
'rows': '2',
|
||||
'label': '路径映射',
|
||||
'label': '历史记录路径映射',
|
||||
'placeholder': 'NAStool路径:MoviePilot路径(一行一个)'
|
||||
}
|
||||
}
|
||||
@ -479,6 +523,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': [
|
||||
@ -492,7 +558,7 @@ class NAStoolSync(_PluginBase):
|
||||
'component': 'VTextarea',
|
||||
'props': {
|
||||
'model': 'site',
|
||||
'label': '站点映射',
|
||||
'label': '下载历史站点映射',
|
||||
'placeholder': 'NAStool站点名:MoviePilot站点名(一行一个)'
|
||||
}
|
||||
}
|
||||
@ -516,7 +582,6 @@ class NAStoolSync(_PluginBase):
|
||||
'开启清空记录时,会在导入历史数据之前删除MoviePilot之前的记录。'
|
||||
'如果转移记录很多,同步时间可能会长,'
|
||||
'所以点击确定后页面没反应是正常现象,后台正在处理。'
|
||||
'路径映射在同步转移记录时有效、站点映射在同步下载记录时有效。'
|
||||
}
|
||||
}
|
||||
]
|
||||
@ -532,6 +597,7 @@ class NAStoolSync(_PluginBase):
|
||||
"download": False,
|
||||
"nt_db_path": "",
|
||||
"path": "",
|
||||
"downloader": "",
|
||||
"site": "",
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user