5d296ee38b
- storage/quark/v1/usage.md: 新增重命名操作
- ref/quark-netdisk-helper/SKILL.md: 新增重命名操作
- ref/resource-pipeline/quark-api.md: 端点表新增重命名
POST /1/clouddrive/file/rename {"fid":"...","file_name":"..."}
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
8.3 KiB
8.3 KiB
夸克网盘 — 使用
目录浏览
# 根目录
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(文件夹/文件唯一标识),后续操作需要用到。
查看分享链接
# 查看完整内容
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")'
转存文件
第一步:确认目标目录存在
转存前必须先搜索夸克网盘中所有相关目录,确认资源是否已存在:
# 遍历所有可能的目录,不能只看一个
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找就会漏掉。
确认目录已存在后再进入第二步。
如果目录不存在,先创建(见下方"创建文件夹")。
第二步:转存
# 转存分享中所有文件
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: "/目标目录")'
第三步:验证
mcporter call 'netdisk.list(cloud: "quark", path: "/目标目录")'
Quark API 补全操作
以下操作 MCP 工具不支持,通过直接调用 Quark API 实现。
通用准备
# 从文件读取避免泄露(推荐)
COOKIE=$(cat tmp/cookie_quark.txt)
# 或直接写入(注意命令行历史)
# COOKIE="你的夸克Cookie"
获取 FID
方式一:从 netdisk.list 输出中提取
3. [dir] 遮.天(2023) (ID: 1ffc622be174429fa36de460856cad05)
方式二:API 递归查询
# 列出指定目录下的内容(含 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\"]}')
"
创建文件夹
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
移动文件
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表示完成
重命名文件
curl -s -X POST "https://drive-h.quark.cn/1/clouddrive/file/rename?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 '{"fid":"<文件FID>","file_name":"<新文件名>"}'
fid:要重命名的文件 FIDfile_name:新文件名(含扩展名)
删除文件
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>"]}'
文件整理流程
场景:按集数分段归类
# 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 匹配是跨文件夹全局匹配的,会混入不相关的文件。
# 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>"]}'
刮削器命名规范
如果文件最终要交给 Jellyfin / Emby / Plex / Kodi 等刮削器识别,文件名必须符合特定格式,否则无法自动匹配元数据。
电视剧 / 动漫
| 刮削器 | 推荐格式 | 示例 |
|---|---|---|
| Jellyfin / Emby / Plex | 剧名 S01E01.ext |
遮天 S01E151.mp4 |
| Kodi | 剧名 S01E01.ext 或 剧名 - 001.ext |
遮天 - 151.mp4 |
| 通用(按集数) | 剧名 - 集数.ext |
遮天 - 151.mp4 |
电影
| 格式 | 示例 |
|---|---|
片名 (年份).ext |
流浪地球 (2019).mp4 |
片名 (年份) 画质.ext |
流浪地球 (2019) 4K.mp4 |
当前文件的问题
从分享链接转存后的文件命名通常刮削器无法识别:
❌ 151.mp4 → 无剧名,无法识别
❌ Z 4K 130.mp4 → 前缀混乱
❌ 148.4k.mp4 → 格式混乱,无剧名
❌ 遮天 4K 162.mkv → 格式不规范,刮削器可能不认
建议命名策略
当前夸克 API 不支持重命名,以下为下载到本地后的处理参考。
下载后用批量重命名工具(如 PowerRename、ReNamer、Python 脚本)统一:
# Python 批量重命名示例(本地执行)
python -X utf8 -c "
import os, re
path = '/下载的/遮天目录'
for f in os.listdir(path):
# 提取数字:151.mp4, 148.4k.mp4 → 151, 148
match = re.search(r'(\d+)', f)
if match:
ep = match.group(1)
ext = os.path.splitext(f)[1]
new_name = f'遮天 S01E{ep.zfill(3)}{ext}'
os.rename(os.path.join(path, f), os.path.join(path, new_name))
print(f'{f} → {new_name}')
"
刮削器目录结构要求
动漫/
├── 遮天 (2023)/
│ ├── Season 01/
│ │ ├── 遮天 S01E101.mp4
│ │ ├── 遮天 S01E102.mp4
│ └── Season 02/
│ ├── 遮天 S02E151.mp4
│ └── ...
注:整理在夸克网盘内是为了存储和下载方便。刮削器识别需要下载到本地或挂载到 NAS 后按上述规范重新命名。
调用语法注意事项
必须使用函数式语法,key=value 形式会报路径错误:
# ✅ 正确
mcporter call 'netdisk.list(cloud: "quark", path: "/")'
# ❌ 错误
mcporter call netdisk.list cloud=quark path=/