📦 Beatport

v1.0.0

使用无头浏览器工具 openclaw(CDP)从 Beatport 下载已购曲目,处理登录与 NextAuth 认证,支持在 hea... 中启用下载

0· 21·0 当前·0 累计
下载技能包
最后更新
2026/4/27
0

运行时依赖

无特殊依赖

版本

latestv1.0.02026/4/27

初始版本:通过 headless 浏览器 CDP 下载已购曲目

安装命令

点击复制
官方npx clawhub@latest install beatport-dl-with-browser-tool
镜像加速npx clawhub@latest install beatport-dl-with-browser-tool --registry https://cn.longxiaskill.com

技能文档

通过 openclaw headless 浏览器(CDP)下载已购 Beatport 曲目。

前置条件

  • openclaw 浏览器运行于 127.0.0.1:9222
  • Beatport 账号(用户名+密码)
  • ws 模块路径 /opt/homebrew/lib/node_modules/openclaw/node_modules/ws
  • Node.js 运行环境

认证流程

Beatport 双认证:
  • account.beatport.com — Django session(sessionid cookie)
  • www.beatport.com — NextAuth(__Secure-next-auth.session-token cookie)

登录步骤

  • CDP Page.navigatehttps://account.beatport.com/
  • Runtime.evaluate 填入用户名/密码(用原生 setter 绕过 React 受控输入)
  • 提交登录表单
  • 在 www.beatport.com 标签页通过 NextAuth 登录:
fetch("/api/auth/csrf").then(r => r.json()).then(csrf => {
  const fd = new URLSearchParams();
  fd.append("csrfToken", csrf.csrfToken);
  fd.append("username", "USER");
  fd.append("password", "PASS");
  fd.append("callbackUrl", "https://www.beatport.com/");
  const form = document.createElement("form");
  form.method = "POST";
  form.action = "/api/auth/signin/beatport";
  form.style.display = "none";
  for (const [k, v] of Object.entries(Object.fromEntries(fd))) {
    const inp = document.createElement("input");
    inp.type = "hidden"; inp.name = k; inp.value = v;
    form.appendChild(inp);
  }
  document.body.appendChild(form); form.submit();
});
  • 验证登录:导航栏出现“Account menu”按钮(无“Create Account or Log In”)。

关键 URL

| 页面 | URL | 用途 | |------|-----|------| | 购物车 | https://www.beatport.com/cart | 待购买商品 | | 曲库 | https://www.beatport.com/library | 已购曲目(免费账户可能提示升级) | | 下载队列 | https://www.beatport.com/library/downloads | 下载队列 | | 结账 | https://www.beatport.com/checkout | 支付页 | 注:/my-beatport/downloads/my-beatport/collection 返回 404,正确路径为 /library/library/downloads

在 headless Chrome 启用下载

headless Chrome 默认取消下载。通过 browser-level WebSocket 开启:
// Browser-level WS: ws://127.0.0.1:9222/devtools/browser/
ws.send(JSON.stringify({
  id: 1,
  method: "Browser.setDownloadBehavior",
  params: {
    behavior: "allowAndName",
    downloadPath: "/path/to/download/dir/",
    eventsEnabled: true
  }
}));
浏览器 ID 从 http://127.0.0.1:9222/json/versionwebSocketDebuggerUrl 获取。

下载曲目

步骤 1:加入下载队列

/library,点击每个曲目的重新下载图标(svg[data-testid='icon-re-download']):
var icons = document.querySelectorAll("svg[data-testid='icon-re-download']");
icons.forEach((icon, i) => setTimeout(() => icon.closest("button, div").click(), i  500));

步骤 2:前往下载队列

跳转至 /library/downloads,所有排队曲目显示“Download All”按钮。

步骤 3:点击“Download All”

先启用浏览器下载(见上),再执行:
const btn = [...document.querySelectorAll("button")].find(b => b.innerText.includes("Download All"));
if (btn) btn.click();
下载为 zip 文件,如 beatport_tracks_2026-04.zip

步骤 4:解压并清理

cd /path/to/download/dir
unzip -o beatport_tracks_.zip -d tmp/
mv tmp/.mp3 .
rm -rf tmp/ beatport_tracks_.zip

下载 URL 格式

https://zips.beatport.com/v1/download?token=
token 一次性且快速过期,务必从 Page.downloadWillBegin 事件实时捕获。

API 访问

Access Token

curl -s -H "Cookie: " \
  "https://www.beatport.com/_next/data//en/library/downloads.json" \
  | jq -r '.pageProps.accessToken'

曲库数据

curl -s -H "Cookie: " \
  "https://www.beatport.com/_next/data//en/library.json" \
  | jq '.pageProps.dehydratedState.queries[].state.data.results[]'
数据来源ClawHub ↗ · 中文优化:龙虾技能库