mirror of
https://github.com/Cp0204/quark-auto-save.git
synced 2026-01-19 19:49:36 +08:00
Compare commits
3 Commits
0f6b6839c4
...
5cc955f590
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5cc955f590 | ||
|
|
33215957bf | ||
|
|
473ac0d468 |
15
Dockerfile
15
Dockerfile
@ -1,6 +1,12 @@
|
|||||||
# 使用官方 Python 镜像作为基础镜像
|
# 使用官方 Python 镜像作为基础镜像
|
||||||
FROM python:3.13-alpine
|
FROM python:3.13-alpine
|
||||||
|
|
||||||
|
#构建版本
|
||||||
|
ARG BUILD_SHA
|
||||||
|
ARG BUILD_TAG
|
||||||
|
ENV BUILD_SHA=$BUILD_SHA
|
||||||
|
ENV BUILD_TAG=$BUILD_TAG
|
||||||
|
|
||||||
# 设置工作目录
|
# 设置工作目录
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
@ -8,17 +14,12 @@ WORKDIR /app
|
|||||||
COPY . /app
|
COPY . /app
|
||||||
|
|
||||||
# 安装依赖
|
# 安装依赖
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
RUN pip install --no-cache-dir -r requirements.txt && \
|
||||||
|
echo "{\"BUILD_SHA\":\"$BUILD_SHA\", \"BUILD_TAG\":\"$BUILD_TAG\"}" > build.json
|
||||||
|
|
||||||
# 时区
|
# 时区
|
||||||
ENV TZ="Asia/Shanghai"
|
ENV TZ="Asia/Shanghai"
|
||||||
|
|
||||||
#构建版本
|
|
||||||
ARG BUILD_SHA
|
|
||||||
ARG BUILD_TAG
|
|
||||||
ENV BUILD_SHA=$BUILD_SHA
|
|
||||||
ENV BUILD_TAG=$BUILD_TAG
|
|
||||||
|
|
||||||
# 端口
|
# 端口
|
||||||
EXPOSE 5005
|
EXPOSE 5005
|
||||||
|
|
||||||
|
|||||||
20
app/run.py
20
app/run.py
@ -34,8 +34,15 @@ from quark_auto_save import Quark, Config, MagicRename
|
|||||||
|
|
||||||
|
|
||||||
def get_app_ver():
|
def get_app_ver():
|
||||||
BUILD_SHA = os.environ.get("BUILD_SHA", "")
|
"""获取应用版本"""
|
||||||
BUILD_TAG = os.environ.get("BUILD_TAG", "")
|
try:
|
||||||
|
with open("build.json", "r") as f:
|
||||||
|
build_info = json.loads(f.read())
|
||||||
|
BUILD_SHA = build_info["BUILD_SHA"]
|
||||||
|
BUILD_TAG = build_info["BUILD_TAG"]
|
||||||
|
except Exception as e:
|
||||||
|
BUILD_SHA = os.getenv("BUILD_SHA", "")
|
||||||
|
BUILD_TAG = os.getenv("BUILD_TAG", "")
|
||||||
if BUILD_TAG[:1] == "v":
|
if BUILD_TAG[:1] == "v":
|
||||||
return BUILD_TAG
|
return BUILD_TAG
|
||||||
elif BUILD_SHA:
|
elif BUILD_SHA:
|
||||||
@ -316,7 +323,9 @@ def get_share_detail():
|
|||||||
return jsonify(
|
return jsonify(
|
||||||
{"success": False, "data": {"error": get_stoken.get("message")}}
|
{"success": False, "data": {"error": get_stoken.get("message")}}
|
||||||
)
|
)
|
||||||
share_detail = account.get_detail(pwd_id, stoken, pdir_fid, _fetch_share=1)
|
share_detail = account.get_detail(
|
||||||
|
pwd_id, stoken, pdir_fid, _fetch_share=1, fetch_share_full_path=1
|
||||||
|
)
|
||||||
|
|
||||||
if share_detail.get("code") != 0:
|
if share_detail.get("code") != 0:
|
||||||
return jsonify(
|
return jsonify(
|
||||||
@ -324,7 +333,10 @@ def get_share_detail():
|
|||||||
)
|
)
|
||||||
|
|
||||||
data = share_detail["data"]
|
data = share_detail["data"]
|
||||||
data["paths"] = paths
|
data["paths"] = [
|
||||||
|
{"fid": i["fid"], "name": i["file_name"]}
|
||||||
|
for i in share_detail["data"].get("full_path", [])
|
||||||
|
] or paths
|
||||||
data["stoken"] = stoken
|
data["stoken"] = stoken
|
||||||
|
|
||||||
# 正则处理预览
|
# 正则处理预览
|
||||||
|
|||||||
@ -1220,9 +1220,9 @@
|
|||||||
} else if (shareurl.includes(dir.fid)) {
|
} else if (shareurl.includes(dir.fid)) {
|
||||||
shareurl = shareurl.match(`.*/${dir.fid}[^/]*`)[0]
|
shareurl = shareurl.match(`.*/${dir.fid}[^/]*`)[0]
|
||||||
} else if (shareurl.includes('#/list/share')) {
|
} else if (shareurl.includes('#/list/share')) {
|
||||||
shareurl = `${shareurl}/${dir.fid}-${dir.name?.replace('-', '*101')}`
|
shareurl = `${shareurl.split('#')[0]}#/list/share/${dir.fid}`
|
||||||
} else {
|
} else {
|
||||||
shareurl = `${shareurl}#/list/share/${dir.fid}-${dir.name?.replace('-', '*101')}`
|
shareurl = `${shareurl.split('#')[0]}#/list/share/${dir.fid}`
|
||||||
}
|
}
|
||||||
return shareurl;
|
return shareurl;
|
||||||
},
|
},
|
||||||
|
|||||||
@ -18,8 +18,26 @@ class Smartstrm:
|
|||||||
else:
|
else:
|
||||||
print(f"{self.plugin_name} 模块缺少必要参数: {key}")
|
print(f"{self.plugin_name} 模块缺少必要参数: {key}")
|
||||||
if self.webhook and self.strmtask:
|
if self.webhook and self.strmtask:
|
||||||
print(f"SmartStrm 触发任务: {self.strmtask} ")
|
if self.get_info():
|
||||||
self.is_active = True
|
self.is_active = True
|
||||||
|
|
||||||
|
def get_info(self):
|
||||||
|
"""获取 SmartStrm 信息"""
|
||||||
|
try:
|
||||||
|
response = requests.request(
|
||||||
|
"GET",
|
||||||
|
self.webhook,
|
||||||
|
timeout=5,
|
||||||
|
)
|
||||||
|
response = response.json()
|
||||||
|
if response.get("success"):
|
||||||
|
print(f"SmartStrm 触发任务: 连接成功 {response.get('version','')}")
|
||||||
|
return response
|
||||||
|
print(f"SmartStrm 触发任务:连接失败 {response.get('message','')}")
|
||||||
|
return None
|
||||||
|
except Exception as e:
|
||||||
|
print(f"SmartStrm 触发任务:连接出错 {str(e)}")
|
||||||
|
return None
|
||||||
|
|
||||||
def run(self, task, **kwargs):
|
def run(self, task, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
# !/usr/bin/env python3
|
# !/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Modify: 2024-11-13
|
# Modify: 2025-09-05
|
||||||
# Repo: https://github.com/Cp0204/quark_auto_save
|
# Repo: https://github.com/Cp0204/quark_auto_save
|
||||||
# ConfigFile: quark_config.json
|
# ConfigFile: quark_config.json
|
||||||
"""
|
"""
|
||||||
@ -497,7 +497,9 @@ class Quark:
|
|||||||
).json()
|
).json()
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def get_detail(self, pwd_id, stoken, pdir_fid, _fetch_share=0):
|
def get_detail(
|
||||||
|
self, pwd_id, stoken, pdir_fid, _fetch_share=0, fetch_share_full_path=0
|
||||||
|
):
|
||||||
list_merge = []
|
list_merge = []
|
||||||
page = 1
|
page = 1
|
||||||
while True:
|
while True:
|
||||||
@ -515,6 +517,8 @@ class Quark:
|
|||||||
"_fetch_share": _fetch_share,
|
"_fetch_share": _fetch_share,
|
||||||
"_fetch_total": "1",
|
"_fetch_total": "1",
|
||||||
"_sort": "file_type:asc,updated_at:desc",
|
"_sort": "file_type:asc,updated_at:desc",
|
||||||
|
"ver": "2",
|
||||||
|
"fetch_share_full_path": fetch_share_full_path,
|
||||||
}
|
}
|
||||||
response = self._send_request("GET", url, params=querystring).json()
|
response = self._send_request("GET", url, params=querystring).json()
|
||||||
if response["code"] != 0:
|
if response["code"] != 0:
|
||||||
@ -709,6 +713,7 @@ class Quark:
|
|||||||
match_pwd = re.search(r"pwd=(\w+)", url)
|
match_pwd = re.search(r"pwd=(\w+)", url)
|
||||||
passcode = match_pwd.group(1) if match_pwd else ""
|
passcode = match_pwd.group(1) if match_pwd else ""
|
||||||
# path: fid-name
|
# path: fid-name
|
||||||
|
# Legacy 20250905
|
||||||
paths = []
|
paths = []
|
||||||
matches = re.findall(r"/(\w{32})-?([^/]+)?", url)
|
matches = re.findall(r"/(\w{32})-?([^/]+)?", url)
|
||||||
for match in matches:
|
for match in matches:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user