5bc15d1855
storage/quark/v1/usage.md: 转存前必须先遍历所有相关目录 确认资源是否已存在,不能只看一个目录就下结论 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
198 lines
5.9 KiB
Markdown
198 lines
5.9 KiB
Markdown
# 夸克网盘 — 使用
|
||
|
||
## 目录浏览
|
||
|
||
```bash
|
||
# 根目录
|
||
mcporter call 'netdisk.list(cloud: "quark", path: "/")'
|
||
|
||
# 子目录
|
||
mcporter call 'netdisk.list(cloud: "quark", path: "/动漫")'
|
||
mcporter call 'netdisk.list(cloud: "quark", path: "/动漫/国漫2024")'
|
||
```
|
||
|
||
列表输出中包含每项的 `(ID: xxx)`,即 FID(文件夹/文件唯一标识),后续操作需要用到。
|
||
|
||
## 查看分享链接
|
||
|
||
```bash
|
||
# 查看完整内容
|
||
mcporter call 'netdisk.view(share_link: "https://pan.quark.cn/s/xxx")'
|
||
|
||
# 按格式过滤
|
||
mcporter call 'netdisk.view(share_link: "https://pan.quark.cn/s/xxx", file_pattern: "*.mp4")'
|
||
mcporter call 'netdisk.view(share_link: "https://pan.quark.cn/s/xxx", file_pattern: "*.mkv")'
|
||
```
|
||
|
||
## 转存文件
|
||
|
||
### 第一步:确认目标目录存在
|
||
|
||
转存前必须**先搜索夸克网盘中所有相关目录**,确认资源是否已存在:
|
||
|
||
```bash
|
||
# 遍历所有可能的目录,不能只看一个
|
||
mcporter call 'netdisk.list(cloud: "quark", path: "/动漫/国漫2024")'
|
||
mcporter call 'netdisk.list(cloud: "quark", path: "/动漫/国漫2025")'
|
||
mcporter call 'netdisk.list(cloud: "quark", path: "/动漫/国漫2026")'
|
||
```
|
||
|
||
> 例如:斗破苍穹可能在 `/动漫/国漫2024/斗破苍穹`,只在 `/动漫/国漫2026` 找就会漏掉。
|
||
|
||
确认目录已存在后再进入第二步。
|
||
|
||
如果目录不存在,先创建(见下方"创建文件夹")。
|
||
|
||
### 第二步:转存
|
||
|
||
```bash
|
||
# 转存分享中所有文件
|
||
mcporter call 'netdisk.transfer(share_link: "https://pan.quark.cn/s/xxx", source_pattern: "/*", target_path: "/目标目录")'
|
||
|
||
# 按文件名匹配转存
|
||
mcporter call 'netdisk.transfer(share_link: "https://pan.quark.cn/s/xxx", source_pattern: "/文件夹名/*.mp4", target_path: "/目标目录")'
|
||
```
|
||
|
||
### 第三步:验证
|
||
|
||
```bash
|
||
mcporter call 'netdisk.list(cloud: "quark", path: "/目标目录")'
|
||
```
|
||
|
||
---
|
||
|
||
## Quark API 补全操作
|
||
|
||
以下操作 MCP 工具不支持,通过直接调用 Quark API 实现。
|
||
|
||
### 通用准备
|
||
|
||
```bash
|
||
# 从文件读取避免泄露(推荐)
|
||
COOKIE=$(cat cookie/quark.txt)
|
||
|
||
# 或直接写入(注意命令行历史)
|
||
# COOKIE="你的夸克Cookie"
|
||
```
|
||
|
||
### 获取 FID
|
||
|
||
方式一:从 `netdisk.list` 输出中提取
|
||
```
|
||
3. [dir] 遮.天(2023) (ID: 1ffc622be174429fa36de460856cad05)
|
||
```
|
||
|
||
方式二:API 递归查询
|
||
|
||
```bash
|
||
# 列出指定目录下的内容(含 FID)
|
||
curl -s "https://drive-h.quark.cn/1/clouddrive/file/sort?pr=ucpro&fr=pc&pdir_fid=<父FID>&_page=1&_size=200" \
|
||
-H "cookie: $COOKIE" | python -X utf8 -c "
|
||
import json,sys
|
||
data=json.load(sys.stdin)
|
||
for item in data.get('data',{}).get('list',[]):
|
||
t='📁' if item.get('file_type')==0 else '📄'
|
||
print(f'{t} {item[\"file_name\"]} -> FID: {item[\"fid\"]}')
|
||
"
|
||
```
|
||
|
||
### 创建文件夹
|
||
|
||
```bash
|
||
curl -s -X POST "https://drive-h.quark.cn/1/clouddrive/file?pr=ucpro&fr=pc&__t=$(date +%s)000" \
|
||
-H "cookie: $COOKIE" \
|
||
-H "content-type: application/json" \
|
||
-H "origin: https://pan.quark.cn" \
|
||
-H "referer: https://pan.quark.cn/" \
|
||
-d '{"pdir_fid":"<父FID>","file_name":"<文件夹名>","file_type":0,"dir_init":true}'
|
||
```
|
||
|
||
- `pdir_fid`:父目录 FID(根目录为 `0`)
|
||
- 返回 `data.fid` 即新文件夹的 FID
|
||
|
||
### 移动文件
|
||
|
||
```bash
|
||
curl -s -X POST "https://drive-h.quark.cn/1/clouddrive/file/move?pr=ucpro&fr=pc&__t=$(date +%s)000" \
|
||
-H "cookie: $COOKIE" \
|
||
-H "content-type: application/json" \
|
||
-H "origin: https://pan.quark.cn" \
|
||
-H "referer: https://pan.quark.cn/" \
|
||
-d '{"action_type":1,"filelist":["<FID1>","<FID2>"],"to_pdir_fid":"<目标FID>"}'
|
||
```
|
||
|
||
- `filelist` 建议 ≤30 个 FID 一批
|
||
- 返回 `data.finish: true` 表示完成
|
||
|
||
### 删除文件
|
||
|
||
```bash
|
||
curl -s -X POST "https://drive-h.quark.cn/1/clouddrive/file/delete?pr=ucpro&fr=pc&__t=$(date +%s)000" \
|
||
-H "cookie: $COOKIE" \
|
||
-H "content-type: application/json" \
|
||
-H "origin: https://pan.quark.cn" \
|
||
-H "referer: https://pan.quark.cn/" \
|
||
-d '{"action_type":2,"filelist":["<FID1>","<FID2>"]}'
|
||
```
|
||
|
||
---
|
||
|
||
## 文件整理流程
|
||
|
||
### 场景:按集数分段归类
|
||
|
||
```bash
|
||
# 1. 列出目标目录,获取所有文件 FID
|
||
mcporter call 'netdisk.list(cloud: "quark", path: "/要整理的目录")'
|
||
|
||
# 2. 创建分段子目录
|
||
for name in "101-120" "121-140" "141-150"; do
|
||
curl -s -X POST "https://drive-h.quark.cn/1/clouddrive/file?pr=ucpro&fr=pc" \
|
||
-H "cookie: $COOKIE" -H "content-type: application/json" \
|
||
-H "origin: https://pan.quark.cn" -H "referer: https://pan.quark.cn/" \
|
||
-d "{\"pdir_fid\":\"<父FID>\",\"file_name\":\"$name\",\"file_type\":0,\"dir_init\":true}"
|
||
done
|
||
|
||
# 3. 移动文件到对应子目录
|
||
curl -s -X POST "https://drive-h.quark.cn/1/clouddrive/file/move?pr=ucpro&fr=pc" \
|
||
-H "cookie: $COOKIE" -H "content-type: application/json" \
|
||
-H "origin: https://pan.quark.cn" -H "referer: https://pan.quark.cn/" \
|
||
-d '{"action_type":1,"filelist":["<FID1>","<FID2>",...],"to_pdir_fid":"<目标子目录FID>"}'
|
||
|
||
# 4. 验证
|
||
mcporter call 'netdisk.list(cloud: "quark", path: "/要整理的目录")'
|
||
mcporter call 'netdisk.list(cloud: "quark", path: "/要整理的目录/101-120")'
|
||
```
|
||
|
||
### 场景:转存后清理杂文件
|
||
|
||
转存的 `source_pattern` 匹配是**跨文件夹全局匹配**的,会混入不相关的文件。
|
||
|
||
```bash
|
||
# 1. 转存
|
||
mcporter call 'netdisk.transfer(...)'
|
||
|
||
# 2. 列出目标目录,找到杂文件
|
||
mcporter call 'netdisk.list(cloud: "quark", path: "/目标目录")'
|
||
|
||
# 3. 获取杂文件的 FID,删除
|
||
curl -s -X POST "https://drive-h.quark.cn/1/clouddrive/file/delete?pr=ucpro&fr=pc" \
|
||
-H "cookie: $COOKIE" -H "content-type: application/json" \
|
||
-H "origin: https://pan.quark.cn" -H "referer: https://pan.quark.cn/" \
|
||
-d '{"action_type":2,"filelist":["<杂文件FID1>","<杂文件FID2>"]}'
|
||
```
|
||
|
||
---
|
||
|
||
## 调用语法注意事项
|
||
|
||
**必须使用函数式语法**,`key=value` 形式会报路径错误:
|
||
|
||
```bash
|
||
# ✅ 正确
|
||
mcporter call 'netdisk.list(cloud: "quark", path: "/")'
|
||
|
||
# ❌ 错误
|
||
mcporter call netdisk.list cloud=quark path=/
|
||
```
|