Skip to content

媒体下载工具 Cobalt

与之前的 OpenManus 一样,为了方便用户使用,我依然做了整合包,关注本公众号,回复 cobalt 获取下载链接。

作用

下载视频/图片/音频,简单直接,可本地部署。支持众多主流网站:xiaohongshu/bilibili/youtube/Instagram/facebook/x 等。

安装

有两种安装方式:docker 和源码安装,此处以源码安装为例。

前提:要求本机安装如下软件。

  • node.js >= 18,安装方式见 安装 NodeJS
  • pnpm:npm install pnpm -g
shell
git clone https://github.com/imputnet/cobalt
cd cobalt/api/src
pnpm install

创建 .env 文件,放置到 cobalt/api 目录下,内容如下:

text
API_URL=http://localhost:9000
API_EXTERNAL_PROXY=http://127.0.0.1:7890
COOKIE_PATH=./cookies.json

核心配置项如上,完整的配置项见 官网

  • API_URL:服务端地址
  • API_EXTERNAL_PROXY:代理地址,如果需要下载 youtube/instagram 等国外网站的资源,则需要配置该选项
  • COOKIE_PATH:对于需要 cookie 才能使用的网站,需要在 cookies.json 文件中配置 cookie 才可以进行下载,例如,instagram。此处 cookie.json 文件放置在 cobalt/api 目录下

cookie.js 文件内容模板如下:(cookie 相关数据需要在访问网站时打开开发者工具进行查找)

shell
{
    "instagram": [
        "mid=<replace>; ig_did=<with>; csrftoken=<your>; ds_user_id=<own>; sessionid=<cookies>"
    ],
    "instagram_bearer": [
        "token=<token_with_no_bearer_in_front>", "token=IGT:2:<looks_like_this>"
    ],
    "reddit": [
        "client_id=<replace_this>; client_secret=<replace_this>; refresh_token=<replace_this>"
    ],
    "twitter": [
        "auth_token=<replace_this>; ct0=<replace_this>"
    ],
    "youtube": [
        "cookie=<replace_this>; b=<replace_this>"
    ]
}

启动后端服务:

shell
cd cobalt/api/src
pnpm start

cmd 中出现如下日志表示成功:

shell
url: http://localhost:9000
port: 9000

[✓] cookies loaded successfully!

浏览器访问:http://localhost:9000,输出 json 串如下,则服务端安装成功。其中 services 表示支持的渠道。

json
{
  "cobalt": {
    "version": "10.7.5",
    "url": "http://localhost:9000",
    "startTime": "1740219978238",
    "durationLimit": 10800,
    "services": [
      "bilibili",
      "bluesky",
      "dailymotion",
      "facebook",
      "instagram",
      "loom",
      "ok",
      "pinterest",
      "reddit",
      "rutube",
      "snapchat",
      "soundcloud",
      "streamable",
      "tiktok",
      "tumblr",
      "twitch",
      "twitter",
      "vimeo",
      "vk",
      "xiaohongshu",
      "youtube"
    ]
  },
  "git": {
    "branch": "main",
    "commit": "82f30627591bb4d8e838208d3f6cceb9079f2a50",
    "remote": "imputnet/cobalt"
  }
}

其中 bilibili 只能下载 480p 得到视频,具体见 issue

启动前端:

shell
cd cobalt/web
npm run dev

终端输出日志如下,则表示成功:

text
  VITE v5.4.8  ready in 8238 ms

  ➜  Local:   https://localhost:5173/
  ➜  Network: use --host to expose
  ➜  press h + enter to show help

使用

浏览器访问 https://localhost:5173/ ,UI 界面显示如下:

img_1.png