mirror of
https://github.com/thsrite/MoviePilot-Plugins.git
synced 2026-06-01 23:16:45 +00:00
fix #77 支持选择MoviePilot配置的下载路径
This commit is contained in:
@@ -15,7 +15,7 @@ MoviePilot三方插件市场:https://github.com/thsrite/MoviePilot-Plugins/
|
||||
- [云盘Strm生成(增量版) v1.1](docs%2FCloudStrmIncrement.md)
|
||||
- [Strm文件模式转换 v1.0](docs%2FStrmConvert.md)
|
||||
- 清理订阅缓存 v1.0
|
||||
- 添加种子下载 v1.0
|
||||
- 添加种子下载 v1.1
|
||||
- 删除站点种子 v1.2
|
||||
- 插件更新管理 v1.9.2
|
||||
- 插件强制重装 v1.7
|
||||
|
||||
@@ -83,11 +83,12 @@
|
||||
"name": "添加种子下载",
|
||||
"description": "选择下载器,添加种子任务。",
|
||||
"labels": "站点",
|
||||
"version": "1.0",
|
||||
"version": "1.1",
|
||||
"icon": "download.png",
|
||||
"author": "thsrite",
|
||||
"level": 1,
|
||||
"history": {
|
||||
"v1.1": "支持选择MoviePilot配置的下载路径",
|
||||
"v1.0": "删除下载器中该站点辅种,保留该站点没有辅种的种子"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -4,6 +4,7 @@ from app.modules.transmission import Transmission
|
||||
from app.plugins import _PluginBase
|
||||
from typing import Any, List, Dict, Tuple
|
||||
from app.log import logger
|
||||
from app.schemas.types import SystemConfigKey
|
||||
from app.utils.string import StringUtils
|
||||
|
||||
|
||||
@@ -15,7 +16,7 @@ class DownloadTorrent(_PluginBase):
|
||||
# 插件图标
|
||||
plugin_icon = "download.png"
|
||||
# 插件版本
|
||||
plugin_version = "1.0"
|
||||
plugin_version = "1.1"
|
||||
# 插件作者
|
||||
plugin_author = "thsrite"
|
||||
# 作者主页
|
||||
@@ -31,6 +32,7 @@ class DownloadTorrent(_PluginBase):
|
||||
_downloader = None
|
||||
_is_paused = False
|
||||
_save_path = None
|
||||
_mp_path = None
|
||||
_torrent_urls = None
|
||||
qb = None
|
||||
tr = None
|
||||
@@ -45,6 +47,7 @@ class DownloadTorrent(_PluginBase):
|
||||
self._downloader = config.get("downloader")
|
||||
self._is_paused = config.get("is_paused")
|
||||
self._save_path = config.get("save_path")
|
||||
self._mp_path = config.get("mp_path")
|
||||
self._torrent_urls = config.get("torrent_urls")
|
||||
|
||||
# 下载种子
|
||||
@@ -66,22 +69,23 @@ class DownloadTorrent(_PluginBase):
|
||||
if str(self._downloader) == "qb":
|
||||
torrent = self.qb.add_torrent(content=torrent_url,
|
||||
is_paused=self._is_paused,
|
||||
download_dir=self._save_path,
|
||||
download_dir=self._save_path or self._mp_path,
|
||||
cookie=site.cookie)
|
||||
else:
|
||||
torrent = self.tr.add_torrent(content=torrent_url,
|
||||
is_paused=self._is_paused,
|
||||
download_dir=self._save_path,
|
||||
download_dir=self._save_path or self._mp_path,
|
||||
cookie=site.cookie)
|
||||
|
||||
if torrent:
|
||||
logger.info(f"种子添加下载成功 {torrent_url} 保存位置 {self._save_path}")
|
||||
logger.info(f"种子添加下载成功 {torrent_url} 保存位置 {self._save_path or self._mp_path}")
|
||||
else:
|
||||
logger.error(f"种子添加下载失败 {torrent_url} 保存位置 {self._save_path}")
|
||||
logger.error(f"种子添加下载失败 {torrent_url} 保存位置 {self._save_path or self._mp_path}")
|
||||
|
||||
self.update_config({
|
||||
"downloader": self._downloader,
|
||||
"save_path": self._save_path,
|
||||
"mp_path": self._mp_path,
|
||||
"is_paused": self._is_paused
|
||||
})
|
||||
|
||||
@@ -99,123 +103,164 @@ class DownloadTorrent(_PluginBase):
|
||||
"""
|
||||
拼装插件配置页面,需要返回两块数据:1、页面配置;2、数据结构
|
||||
"""
|
||||
dir_conf: List[dict] = self.systemconfig.get(SystemConfigKey.DownloadDirectories)
|
||||
dir_conf = [{'title': d.get('name'), 'value': d.get('path')} for d in dir_conf]
|
||||
return [
|
||||
{
|
||||
'component': 'VForm',
|
||||
'content': [
|
||||
{
|
||||
'component': 'VRow',
|
||||
'content': [
|
||||
{
|
||||
'component': 'VCol',
|
||||
'props': {
|
||||
'cols': 12,
|
||||
'md': 4
|
||||
},
|
||||
'content': [
|
||||
{
|
||||
'component': 'VSelect',
|
||||
'props': {
|
||||
'model': 'downloader',
|
||||
'label': '下载器',
|
||||
'items': [
|
||||
{'title': 'qb', 'value': 'qb'},
|
||||
{'title': 'tr', 'value': 'tr'}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
'component': 'VCol',
|
||||
'props': {
|
||||
'cols': 12,
|
||||
'md': 4
|
||||
},
|
||||
'content': [
|
||||
{
|
||||
'component': 'VSelect',
|
||||
'props': {
|
||||
'model': 'is_paused',
|
||||
'label': '暂停种子',
|
||||
'items': [
|
||||
{'title': '开启', 'value': True},
|
||||
{'title': '不开启', 'value': False}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
'component': 'VCol',
|
||||
'props': {
|
||||
'cols': 12,
|
||||
'md': 4
|
||||
},
|
||||
'content': [
|
||||
{
|
||||
'component': 'VTextField',
|
||||
'props': {
|
||||
'model': 'save_path',
|
||||
'label': '保存路径'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
'component': 'VRow',
|
||||
'content': [
|
||||
{
|
||||
'component': 'VCol',
|
||||
'props': {
|
||||
'cols': 12,
|
||||
},
|
||||
'content': [
|
||||
{
|
||||
'component': 'VTextarea',
|
||||
'props': {
|
||||
'model': 'torrent_urls',
|
||||
'rows': '3',
|
||||
'label': '种子链接',
|
||||
'placeholder': '种子链接,一行一个'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
'component': 'VRow',
|
||||
'content': [
|
||||
{
|
||||
'component': 'VCol',
|
||||
'props': {
|
||||
'cols': 12,
|
||||
},
|
||||
'content': [
|
||||
{
|
||||
'component': 'VAlert',
|
||||
'props': {
|
||||
'type': 'info',
|
||||
'variant': 'tonal',
|
||||
'text': '保存路径为下载器保存路径,种子链接一行一个。'
|
||||
'添加的种子链接需站点已在站点管理维护或公共站点。'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
], {
|
||||
"downloader": "qb",
|
||||
"is_paused": False,
|
||||
"save_path": "",
|
||||
"torrent_urls": ""
|
||||
}
|
||||
{
|
||||
'component': 'VForm',
|
||||
'content': [
|
||||
{
|
||||
'component': 'VRow',
|
||||
'content': [
|
||||
{
|
||||
'component': 'VCol',
|
||||
'props': {
|
||||
'cols': 12,
|
||||
'md': 3
|
||||
},
|
||||
'content': [
|
||||
{
|
||||
'component': 'VSelect',
|
||||
'props': {
|
||||
'model': 'downloader',
|
||||
'label': '下载器',
|
||||
'items': [
|
||||
{'title': 'qb', 'value': 'qb'},
|
||||
{'title': 'tr', 'value': 'tr'}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
'component': 'VCol',
|
||||
'props': {
|
||||
'cols': 12,
|
||||
'md': 3
|
||||
},
|
||||
'content': [
|
||||
{
|
||||
'component': 'VSelect',
|
||||
'props': {
|
||||
'model': 'is_paused',
|
||||
'label': '暂停种子',
|
||||
'items': [
|
||||
{'title': '开启', 'value': True},
|
||||
{'title': '不开启', 'value': False}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
'component': 'VCol',
|
||||
'props': {
|
||||
'cols': 12,
|
||||
'md': 3
|
||||
},
|
||||
'content': [
|
||||
{
|
||||
'component': 'VSelect',
|
||||
'props': {
|
||||
'model': 'mp_path',
|
||||
'label': 'MoviePilot保存路径',
|
||||
'items': dir_conf
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
'component': 'VCol',
|
||||
'props': {
|
||||
'cols': 12,
|
||||
'md': 3
|
||||
},
|
||||
'content': [
|
||||
{
|
||||
'component': 'VTextField',
|
||||
'props': {
|
||||
'model': 'save_path',
|
||||
'label': '自定义保存路径'
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
'component': 'VRow',
|
||||
'content': [
|
||||
{
|
||||
'component': 'VCol',
|
||||
'props': {
|
||||
'cols': 12,
|
||||
},
|
||||
'content': [
|
||||
{
|
||||
'component': 'VTextarea',
|
||||
'props': {
|
||||
'model': 'torrent_urls',
|
||||
'rows': '3',
|
||||
'label': '种子链接',
|
||||
'placeholder': '种子链接,一行一个'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
'component': 'VRow',
|
||||
'content': [
|
||||
{
|
||||
'component': 'VCol',
|
||||
'props': {
|
||||
'cols': 12,
|
||||
},
|
||||
'content': [
|
||||
{
|
||||
'component': 'VAlert',
|
||||
'props': {
|
||||
'type': 'info',
|
||||
'variant': 'tonal',
|
||||
'text': '自定义保存路径优先级高于MoviePilot保存路径。'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
'component': 'VRow',
|
||||
'content': [
|
||||
{
|
||||
'component': 'VCol',
|
||||
'props': {
|
||||
'cols': 12,
|
||||
},
|
||||
'content': [
|
||||
{
|
||||
'component': 'VAlert',
|
||||
'props': {
|
||||
'type': 'info',
|
||||
'variant': 'tonal',
|
||||
'text': '保存路径为下载器保存路径,种子链接一行一个。'
|
||||
'添加的种子链接需站点已在站点管理维护或公共站点。'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
], {
|
||||
"downloader": "qb",
|
||||
"is_paused": False,
|
||||
"save_path": "",
|
||||
"mp_path": "",
|
||||
"torrent_urls": ""
|
||||
}
|
||||
|
||||
def get_page(self) -> List[dict]:
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user