Compare commits

..

No commits in common. "92df9239af3e2b180d93af3d8b479bb903dbffd0" and "9d599b5e64751aa007ca96e547a7b0d3f507dc36" have entirely different histories.

4 changed files with 20 additions and 29 deletions

View File

@ -4,7 +4,7 @@
## 基本结构 ## 基本结构
* 插件位于 `plugins` 目录下. * 插件位于 `media_servers` 目录下.
* 每个插件是一个 `.py` 文件 (例如 `emby.py`, `plex.py`),文件名小写。 * 每个插件是一个 `.py` 文件 (例如 `emby.py`, `plex.py`),文件名小写。
* 每个插件文件包含一个与文件名对应的首字母大写命名类(例如 `emby.py` 中的 `Emby` 类)。 * 每个插件文件包含一个与文件名对应的首字母大写命名类(例如 `emby.py` 中的 `Emby` 类)。
@ -58,12 +58,12 @@ except requests.exceptions.RequestException as e:
## 使用自定义插件 ## 使用自定义插件
放到 `/plugins` 目录即可识别,如果你使用 docker 运行: 放到 `/media_servers` 目录即可识别,如果你使用 docker 运行:
```shell ```shell
docker run -d \ docker run -d \
# ... 例如添加这行挂载,其它一致 # ... 例如添加这行挂载,其它一致
-v ./quark-auto-save/plugins/plex.py:/app/plugins/plex.py \ -v ./quark-auto-save/media_servers/plex.py:/app/media_servers/plex.py \
# ... # ...
``` ```
@ -71,7 +71,7 @@ docker run -d \
## 配置文件 ## 配置文件
`quark_config.json``plugins` 中配置插件参数: `quark_config.json``media_servers` 中配置插件参数:
```json ```json
{ {

View File

@ -58,11 +58,9 @@ class Alist_strm_gen:
self.strm_server = f"{self.url.strip()}/d" self.strm_server = f"{self.url.strip()}/d"
def run(self, task, **kwargs): def run(self, task, **kwargs):
task_config = task.get("addition", {}).get( if task_config := task.get("addition", {}).get(self.plugin_name, {}):
self.plugin_name, self.default_task_config if not task_config.get("auto_gen"):
) return
if not task_config.get("auto_gen"):
return
if task.get("savepath") and task.get("savepath").startswith( if task.get("savepath") and task.get("savepath").startswith(
self.quark_root_dir self.quark_root_dir
): ):

View File

@ -10,8 +10,7 @@ class Aria2:
"dir": "/Downloads", # 下载目录需要Aria2有权限访问 "dir": "/Downloads", # 下载目录需要Aria2有权限访问
} }
default_task_config = { default_task_config = {
"auto_download": False, # 是否自动添加下载任务 "auto_download": False, # 是否开启自动下载
"pause": False, # 添加任务后为暂停状态,不自动开始(手动下载)
} }
is_active = False is_active = False
rpc_url = None rpc_url = None
@ -30,11 +29,9 @@ class Aria2:
self.is_active = True self.is_active = True
def run(self, task, **kwargs): def run(self, task, **kwargs):
task_config = task.get("addition", {}).get( if task_config := task.get("addition", {}).get(self.plugin_name, {}):
self.plugin_name, self.default_task_config if not task_config.get("auto_download"):
) return
if not task_config.get("auto_download"):
return
if (tree := kwargs.get("tree")) and (account := kwargs.get("account")): if (tree := kwargs.get("tree")) and (account := kwargs.get("account")):
for node in tree.all_nodes_itr(): for node in tree.all_nodes_itr():
if not node.data.get("is_dir", True): if not node.data.get("is_dir", True):
@ -55,7 +52,6 @@ class Aria2:
], ],
"out": os.path.basename(save_path), "out": os.path.basename(save_path),
"dir": os.path.dirname(save_path), "dir": os.path.dirname(save_path),
"pause": task_config.get("pause"),
}, },
] ]
self.add_uri(aria2_params) self.add_uri(aria2_params)

View File

@ -26,18 +26,15 @@ class Emby:
self.is_active = True self.is_active = True
def run(self, task, **kwargs): def run(self, task, **kwargs):
task_config = task.get("addition", {}).get( if task_config := task.get("addition", {}).get(self.plugin_name, {}):
self.plugin_name, self.default_task_config if media_id := task_config.get("media_id"):
) if media_id != "0":
if media_id := task_config.get("media_id"): self.refresh(media_id)
if media_id != "0": elif task_config.get("try_match"):
self.refresh(media_id) if match_media_id := self.search(task["taskname"]):
elif task_config.get("try_match"): self.refresh(match_media_id)
if match_media_id := self.search(task["taskname"]): task["addition"][self.plugin_name]["media_id"] = match_media_id
self.refresh(match_media_id) return task
task_config["media_id"] = match_media_id
task.setdefault("addition", {})[self.plugin_name] = task_config
return task
def get_info(self): def get_info(self):
url = f"{self.url}/emby/System/Info" url = f"{self.url}/emby/System/Info"