Compare commits

...

2 Commits

Author SHA1 Message Date
Cp0204
62ac3cedd1 添加 SmartStrm 插件
Some checks are pending
Docker Publish / build-and-push (push) Waiting to run
2025-08-02 17:00:42 +08:00
Cp0204
d0c9a78067 🎨 优化点击样式
Some checks failed
Docker Publish / build-and-push (push) Has been cancelled
2025-08-02 16:59:35 +08:00
3 changed files with 74 additions and 1 deletions

View File

@ -504,7 +504,7 @@
<td v-if="file.dir">{{ file.include_items }}项</td>
<td v-else>{{file.size | size}}</td>
<td>{{file.updated_at | ts2date}}</td>
<td v-if="!fileSelect.selectShare"><a @click.stop.prevent="deleteFile(file.fid, file.file_name, file.dir)">删除</a></td>
<td v-if="!fileSelect.selectShare"><a class="cursor-pointer text-muted" @click.stop.prevent="deleteFile(file.fid, file.file_name, file.dir)">删除</a></td>
</template>
</tr>
</tbody>

View File

@ -1,5 +1,6 @@
[
"alist",
"smartstrm",
"alist_strm",
"alist_strm_gen",
"alist_sync",

72
plugins/smartstrm.py Normal file
View File

@ -0,0 +1,72 @@
import os
import re
import requests
class Smartstrm:
default_config = {
"webhook": "", # SmartStrm Webhook 地址
"taskname": "", # SmartStrm 任务名
"fix_path": "", # 路径映射, SmartStrm 任务使用 quark 驱动时无须填写;使用 openlist 驱动时需填写 `/storage_mount_path:/quark_root_dir` ,例如我把夸克根目录挂载在 OpenList 的 /quark 下,则填写 `/quark:/` ;以及 SmartStrm 会使 OpenList 强制刷新目录,无需再用 alist 插件刷新。
}
default_task_config = {}
is_active = False
def __init__(self, **kwargs):
self.plugin_name = self.__class__.__name__.lower()
if kwargs:
for key, _ in self.default_config.items():
if key in kwargs:
setattr(self, key, kwargs[key])
else:
print(f"{self.plugin_name} 模块缺少必要参数: {key}")
if self.webhook and self.taskname:
print(f"SmartStrm 触发任务: {self.taskname} ")
self.is_active = True
def run(self, task, **kwargs):
"""
插件主入口函数
:param task: 任务配置
:param kwargs: 其他参数
"""
if match := re.match(r"^(\/[^:]*):(\/[^:]*)$", self.fix_path):
# 存储挂载路径, 夸克根文件夹
storage_mount_path, quark_root_dir = match.group(1), match.group(2)
storage_path = os.path.join(
storage_mount_path,
task["savepath"].replace(quark_root_dir, "", 1).lstrip("/"),
).replace("\\", "/")
else:
storage_path = task["savepath"]
try:
# 准备发送的数据
headers = {"Content-Type": "application/json"}
payload = {
"event": "a_task",
"task": {
"name": self.taskname,
"storage_path": storage_path,
},
}
# 发送 POST 请求
response = requests.request(
"POST",
self.webhook,
headers=headers,
json=payload,
timeout=5,
)
# 检查响应状态
if response.status_code == 200:
response = response.json()
if response.get("success"):
print(
f"SmartStrm 触发任务: {response['task']['name']}{response['task']['storage_path']} 成功✅"
)
else:
print(f"SmartStrm 触发任务: {response['message']}")
else:
print(f"SmartStrm 触发任务: {response.status_code}")
except Exception as e:
print(f"SmartStrm 触发任务:出错 {e}")