quark-auto-save
Manage quark-auto-save tasks via CLI.
QAS, 夸克自动转存, 夸克转存, 夸克订阅, 管理任务, 运行任务, 修复失效链接
When user send message like https://pan.quark.cn/s/***, get detail, add a QAS task.
⚠️ Prerequisites
Env:
Set in the skill's env config (e.g., openclaw.json → skills.entries.quark-auto-save.env.QAS_BASE_URL). Restart gateway after editing.
First Configuration: Analyze User Habits
After the user sets the token, the following analysis must be performed and recorded in TOOLS.md:
Get Current Configuration:
python3 {baseDir}/scripts/qas_client.py get-config
Analyze Saving Habits:
- Extract
savepath directory patterns from existing tasks (e.g., /video/tv/, /video/anime/, /video/movie/)
- For
pattern + replace: deduce the final renamed filename format by applying the regex to a sample source file (e.g., 01.mp4 → Black Mirror.S01E01.mp4). Record the result pattern, not the raw regex.
- Note which
magic_regex key the user prefers (e.g. $TV_MAGIC)
Record to TOOLS.md:
The following is just an example, not specific values, everything is analyzed based on user configuration.
### quark-auto-save habits
#### TV Series
- Directory: `/video/tv/{name}`
- naming preferences: `$TV_MAGIC `(e.g., {TASKNAME}.{SXX}E{E}.{EXT})
#### Anime
- Directory: `/video/anime/{name}`
- naming preferences: `Rick and Morty.S01E01.mp4`
#### Movie
- Directory: `/video/movie/{name} {year}`
- naming preferences: `{TASKNAME}.mp4`
-
...
Python Client
Use {baseDir}/scripts/qas_client.py for all operations:
python3 {baseDir}/scripts/qas_client.py get-config # Get all config & tasks
python3 {baseDir}/scripts/qas_client.py search "query" [-d] # Search resources
python3 {baseDir}/scripts/qas_client.py get-share "<shareurl>" [-a] # Get share detail (-a for all files)
python3 {baseDir}/scripts/qas_client.py check-path "/path" # Check savepath
python3 {baseDir}/scripts/qas_client.py delete-file "/path/to/file" # Delete cloud file
python3 {baseDir}/scripts/qas_client.py rename-file "/path/to/file" "new_name" # Rename cloud file
python3 {baseDir}/scripts/qas_client.py add-task '{"taskname": "Name", ...}' # Add task
python3 {baseDir}/scripts/qas_client.py run-task [taskname|json] # Run task(s)
python3 {baseDir}/scripts/qas_client.py update-task "TaskName" '{"savepath": "/new"}' # Update task
python3 {baseDir}/scripts/qas_client.py delete-task "TaskName" # Delete task
python3 {baseDir}/scripts/qas_client.py update-config '{"key": "value"}' # Update config
Task Schema
{
"taskname": "MediaName",
"shareurl": "https://pan.quark.cn/s/xxx#/list/share/fid",
"savepath": "/video/tv/MediaName",
"pattern": "$TV_MAGIC",
"replace": "",
"update_subdir": "",
"ignore_extension": false,
"runweek": [1,2,3,4,5,6,7]
}
Required Fields: taskname, shareurl, savepath
Optional Fields: pattern, replace, update_subdir, ignore_extension, runweek, addition
add-task auto-detects zip/rar/7z files and enables auto_unarchive plugin automatically. No manual addition config needed for this.
Configuration Rules
shareurl Format
https://pan.quark.cn/s/{abc123}
https://pan.quark.cn/s/{abc123}#/list/share/{fid}
Subdirectory Priority
- Video files (mp4, mkv, avi)
- Resolution: 4K > 1080P > 720P
Archive files (zip, rar, 7z) are also supported — auto-unarchive is enabled automatically by add-task run-task.
Get subdir info:
python3 {baseDir}/scripts/qas_client.py get-share "<shareurl>"
Add task example:
python3 {baseDir}/scripts/qas_client.py add-task '{"taskname": "Black Mirror", "shareurl": "https://pan.quark.cn/s/xxx", "savepath": "/video/tv/Black Mirror", "pattern": "$TV_MAGIC"}'
pattern & replace
WIKI:
| Pattern |
Replace |
Result |
.* |
|
Save all files |
\.(mp4|mkv)$ |
|
Save video files only |
^(\d+)\.mp4 |
S02E\1.mp4 |
01.mp4 → S02E01.mp4 |
$TV_MAGIC |
|
Use custom magic regex |
replace Magic Variables
| Variable |
Description |
{TASKNAME} |
Task name |
{II} |
Index number (01, 02...) |
{EXT} |
File extension |
{SXX} |
Season (S01, S02...) |
{E} |
Episode number |
{DATE} |
Date (YYYYMMDD) |
Workflows
Add New Task
- Search:
python3 {baseDir}/scripts/qas_client.py search "MediaName" -d
- Verify & Get Details:
python3 {baseDir}/scripts/qas_client.py get-share "<shareurl>"
- Check if
shareurl is valid (not banned)
- Check file list for video files and select the subdir
- Analyze
pattern & replace: Ensure the final renamed filename matches the naming preferences in TOOLS.md.
- Source already matches →
"pattern": ".*", replace: "" (save as-is)
- Needs renaming → design
pattern to capture groups, replace with magic variables. E.g., source 01.mp4, TOOLS.md says Black Mirror.S01E01.mp4 → "pattern": "^(\\d+)\\.mp4$", "replace": "{TASKNAME}.S01E\\1.{EXT}"
- Execute:
- One-time (completed series, taskname contains
X集全, 全X集, 完结, 全集, single movie) → run-task
- Subscription (ongoing series that gets new episodes) →
add-task
# One-time (completed)
python3 {baseDir}/scripts/qas_client.py run-task '{"taskname": "MediaName", "shareurl": "...", "savepath": "...", "pattern": "...", "replace": "..."}'
# Subscription (ongoing)
python3 {baseDir}/scripts/qas_client.py add-task '{"taskname": "MediaName", "shareurl": "...", "savepath": "...", "pattern": "...", "replace": "..."}'
savepath and (pattern+replace) MUST follow the user's existing habits recorded in TOOLS.md
- After add-task: trigger
run-task "TaskName" immediately to execute the first save.
Check Invalid Tasks
- Get tasks:
python3 {baseDir}/scripts/qas_client.py get-config
- Identify invalid tasks: tasks with
shareurl_ban key in tasklist
- Check existing files:
python3 {baseDir}/scripts/qas_client.py check-path "<task_savepath>" — record the naming format and the latest episode number (e.g., E24) of already-saved files
- Find replacement:
python3 {baseDir}/scripts/qas_client.py search "<taskname>" -d to get candidate shareurls
- Verify & select shareurl:
python3 {baseDir}/scripts/qas_client.py get-share "<candidate_shareurl>" -a — check file list
- Step 1 — Pick by video format: prefer the shareurl whose file extension matches the existing files (e.g., existing
.mkv → pick .mkv source, existing .mp4 → pick .mp4 source)
- Step 2 — Prefer newer episodes: among candidates with matching format, pick the one whose episode range extends beyond the latest episode (e.g., existing up to E24 → pick shareurl containing E25+)
- Step 3 — Ensure naming consistency: analyze the source filenames against the existing file naming format. Update
pattern/replace so the final renamed result matches the existing naming. If source already matches, keep pattern/replace unchanged.
- Update task:
python3 {baseDir}/scripts/qas_client.py update-task "TaskName" '{"shareurl": "<verified_url>", "shareurl_ban": "", "pattern": "...", "replace": "..."}' — include pattern/replace if they were adjusted
- Trigger run:
python3 {baseDir}/scripts/qas_client.py run-task "TaskName" — execute immediately after fixing the link.
Delete Task
python3 {baseDir}/scripts/qas_client.py delete-task "TaskName"
Update Task
# Partial update (only specified fields are changed)
python3 {baseDir}/scripts/qas_client.py update-task "TaskName" '{"savepath": "/new/path"}'
python3 {baseDir}/scripts/qas_client.py update-task "TaskName" '{"pattern": "$TV_MAGIC", "runweek": [1,3,5]}'
Update Config
# Update global config (allowed keys: cookie, crontab, push_config, tasklist, magic_regex, plugins, source)
python3 {baseDir}/scripts/qas_client.py update-config '{"crontab": "0 9 * * *"}'
Run Tasks
python3 {baseDir}/scripts/qas_client.py run-task # All tasks
python3 {baseDir}/scripts/qas_client.py run-task "TaskName" # Specific task
python3 {baseDir}/scripts/qas_client.py run-task '{"taskname": "Test", ...}' # Direct task
Output Format
All commands output text. First word indicates status:
- OK — success, no data
- OK {json} — success with data (JSON on same line)
- ERROR: message — failure
- run-task:
OK on first line, followed by log lines
1---2name: quark-auto-save3description: Manage quark-auto-save tasks via CLI. (QAS, 夸克自动转存, 夸克转存, 夸克订阅, 管理任务, 运行任务, 修复失效链接, pan.quark.cn)4---56# quark-auto-save78Manage quark-auto-save tasks via CLI.910QAS, 夸克自动转存, 夸克转存, 夸克订阅, 管理任务, 运行任务, 修复失效链接1112When user send message like `https://pan.quark.cn/s/***`, get detail, add a QAS task.1314## ⚠️ Prerequisites1516**Env:**17- `QAS_BASE_URL` - User provided, e.g., http://192.168.1.x:500518- `QAS_TOKEN` - User provided1920> Set in the skill's env config (e.g., `openclaw.json` → `skills.entries.quark-auto-save.env.QAS_BASE_URL`). Restart gateway after editing.2122## First Configuration: Analyze User Habits2324After the user sets the token, the following analysis must be performed and recorded in TOOLS.md:25261. **Get Current Configuration**:27 ```bash28 python3 {baseDir}/scripts/qas_client.py get-config29 ```30312. **Analyze Saving Habits**:32 - Extract `savepath` directory patterns from existing tasks (e.g., `/video/tv/`, `/video/anime/`, `/video/movie/`)33 - For `pattern` + `replace`: deduce the **final renamed filename** format by applying the regex to a sample source file (e.g., `01.mp4` → `Black Mirror.S01E01.mp4`). Record the result pattern, not the raw regex.34 - Note which `magic_regex` key the user prefers (e.g. `$TV_MAGIC`)35363. **Record to TOOLS.md**:37 The following is just an example, not specific values, everything is analyzed based on user configuration.38 ```markdown39 ### quark-auto-save habits40 #### TV Series41 - Directory: `/video/tv/{name}`42 - naming preferences: `$TV_MAGIC `(e.g., {TASKNAME}.{SXX}E{E}.{EXT})43 #### Anime44 - Directory: `/video/anime/{name}`45 - naming preferences: `Rick and Morty.S01E01.mp4`46 #### Movie47 - Directory: `/video/movie/{name} {year}`48 - naming preferences: `{TASKNAME}.mp4`49 -50 ...51 ```5253## Python Client5455Use `{baseDir}/scripts/qas_client.py` for all operations:5657```bash58python3 {baseDir}/scripts/qas_client.py get-config # Get all config & tasks59python3 {baseDir}/scripts/qas_client.py search "query" [-d] # Search resources60python3 {baseDir}/scripts/qas_client.py get-share "<shareurl>" [-a] # Get share detail (-a for all files)61python3 {baseDir}/scripts/qas_client.py check-path "/path" # Check savepath62python3 {baseDir}/scripts/qas_client.py delete-file "/path/to/file" # Delete cloud file63python3 {baseDir}/scripts/qas_client.py rename-file "/path/to/file" "new_name" # Rename cloud file64python3 {baseDir}/scripts/qas_client.py add-task '{"taskname": "Name", ...}' # Add task65python3 {baseDir}/scripts/qas_client.py run-task [taskname|json] # Run task(s)66python3 {baseDir}/scripts/qas_client.py update-task "TaskName" '{"savepath": "/new"}' # Update task67python3 {baseDir}/scripts/qas_client.py delete-task "TaskName" # Delete task68python3 {baseDir}/scripts/qas_client.py update-config '{"key": "value"}' # Update config69```7071## Task Schema7273```json74{75 "taskname": "MediaName",76 "shareurl": "https://pan.quark.cn/s/xxx#/list/share/fid",77 "savepath": "/video/tv/MediaName",78 "pattern": "$TV_MAGIC",79 "replace": "",80 "update_subdir": "",81 "ignore_extension": false,82 "runweek": [1,2,3,4,5,6,7]83}84```8586**Required Fields:** `taskname`, `shareurl`, `savepath`8788**Optional Fields:** `pattern`, `replace`, `update_subdir`, `ignore_extension`, `runweek`, `addition`8990> `add-task` auto-detects zip/rar/7z files and enables `auto_unarchive` plugin automatically. No manual `addition` config needed for this.9192## Configuration Rules9394### `shareurl` Format95- `https://pan.quark.cn/s/{abc123}`96- `https://pan.quark.cn/s/{abc123}#/list/share/{fid}`9798### Subdirectory Priority991. Video files (mp4, mkv, avi)1002. Resolution: 4K > 1080P > 720P101102> Archive files (zip, rar, 7z) are also supported — auto-unarchive is enabled automatically by `add-task` `run-task`.103104**Get subdir info:**105```bash106python3 {baseDir}/scripts/qas_client.py get-share "<shareurl>"107```108109**Add task example:**110```bash111python3 {baseDir}/scripts/qas_client.py add-task '{"taskname": "Black Mirror", "shareurl": "https://pan.quark.cn/s/xxx", "savepath": "/video/tv/Black Mirror", "pattern": "$TV_MAGIC"}'112```113114## `pattern` & `replace`115116**WIKI:**117- RegexRename: https://github.com/Cp0204/quark-auto-save/wiki/正则处理教程118- MagicRegex: https://github.com/Cp0204/quark-auto-save/wiki/魔法匹配和魔法变量119120| Pattern | Replace | Result |121|---|---|---|122| `.*` | | Save all files |123| `\.(mp4\|mkv)$` | | Save video files only |124| `^(\d+)\.mp4` | `S02E\1.mp4` | 01.mp4 → S02E01.mp4 |125| `$TV_MAGIC` | | Use custom magic regex |126127### `replace` Magic Variables128129| Variable | Description |130|---|---|131| `{TASKNAME}` | Task name |132| `{II}` | Index number (01, 02...) |133| `{EXT}` | File extension |134| `{SXX}` | Season (S01, S02...) |135| `{E}` | Episode number |136| `{DATE}` | Date (YYYYMMDD) |137138## Workflows139140### Add New Task1411. **Search**: `python3 {baseDir}/scripts/qas_client.py search "MediaName" -d`1422. **Verify & Get Details**: `python3 {baseDir}/scripts/qas_client.py get-share "<shareurl>"`143 - Check if `shareurl` is valid (not banned)144 - Check file list for video files and select the subdir1453. **Analyze `pattern` & `replace`**: Ensure the **final renamed filename** matches the naming preferences in TOOLS.md.146 - Source already matches → `"pattern": ".*"`, `replace: ""` (save as-is)147 - Needs renaming → design `pattern` to capture groups, `replace` with magic variables. E.g., source `01.mp4`, TOOLS.md says `Black Mirror.S01E01.mp4` → `"pattern": "^(\\d+)\\.mp4$", "replace": "{TASKNAME}.S01E\\1.{EXT}"`1484. **Execute**:149 - **One-time** (completed series, taskname contains `X集全`, `全X集`, `完结`, `全集`, single movie) → `run-task`150 - **Subscription** (ongoing series that gets new episodes) → `add-task`151 ```bash152 # One-time (completed)153 python3 {baseDir}/scripts/qas_client.py run-task '{"taskname": "MediaName", "shareurl": "...", "savepath": "...", "pattern": "...", "replace": "..."}'154 # Subscription (ongoing)155 python3 {baseDir}/scripts/qas_client.py add-task '{"taskname": "MediaName", "shareurl": "...", "savepath": "...", "pattern": "...", "replace": "..."}'156 ```157 - `savepath` and (`pattern`+`replace`) MUST follow the user's existing habits recorded in TOOLS.md158 - **After add-task**: trigger `run-task "TaskName"` immediately to execute the first save.159160### Check Invalid Tasks1611. **Get tasks**: `python3 {baseDir}/scripts/qas_client.py get-config`1622. **Identify invalid tasks**: tasks with `shareurl_ban` key in tasklist1633. **Check existing files**: `python3 {baseDir}/scripts/qas_client.py check-path "<task_savepath>"` — record the naming format and the **latest episode number** (e.g., E24) of already-saved files1644. **Find replacement**: `python3 {baseDir}/scripts/qas_client.py search "<taskname>" -d` to get candidate shareurls1655. **Verify & select shareurl**:166 - `python3 {baseDir}/scripts/qas_client.py get-share "<candidate_shareurl>" -a` — check file list167 - **Step 1 — Pick by video format**: prefer the shareurl whose file extension matches the existing files (e.g., existing `.mkv` → pick `.mkv` source, existing `.mp4` → pick `.mp4` source)168 - **Step 2 — Prefer newer episodes**: among candidates with matching format, pick the one whose episode range extends **beyond the latest episode** (e.g., existing up to E24 → pick shareurl containing E25+)169 - **Step 3 — Ensure naming consistency**: analyze the source filenames against the existing file naming format. Update `pattern`/`replace` so the **final renamed result** matches the existing naming. If source already matches, keep `pattern`/`replace` unchanged.1706. **Update task**: `python3 {baseDir}/scripts/qas_client.py update-task "TaskName" '{"shareurl": "<verified_url>", "shareurl_ban": "", "pattern": "...", "replace": "..."}'` — include `pattern`/`replace` if they were adjusted1717. **Trigger run**: `python3 {baseDir}/scripts/qas_client.py run-task "TaskName"` — execute immediately after fixing the link.172173### Delete Task174```bash175python3 {baseDir}/scripts/qas_client.py delete-task "TaskName"176```177178### Update Task179```bash180# Partial update (only specified fields are changed)181python3 {baseDir}/scripts/qas_client.py update-task "TaskName" '{"savepath": "/new/path"}'182python3 {baseDir}/scripts/qas_client.py update-task "TaskName" '{"pattern": "$TV_MAGIC", "runweek": [1,3,5]}'183```184185### Update Config186```bash187# Update global config (allowed keys: cookie, crontab, push_config, tasklist, magic_regex, plugins, source)188python3 {baseDir}/scripts/qas_client.py update-config '{"crontab": "0 9 * * *"}'189```190191### Run Tasks192```bash193python3 {baseDir}/scripts/qas_client.py run-task # All tasks194python3 {baseDir}/scripts/qas_client.py run-task "TaskName" # Specific task195python3 {baseDir}/scripts/qas_client.py run-task '{"taskname": "Test", ...}' # Direct task196```197198## Output Format199200All commands output text. First word indicates status:201202- **OK** — success, no data203- **OK {json}** — success with data (JSON on same line)204- **ERROR: message** — failure205- **run-task**: `OK` on first line, followed by log lines