Skip to content

Repository files navigation

fetch-anything

从带反爬的互联网来源抓取内容的 Agent Skill 与 Python 包。当前支持 YouTube 与 Bilibili;后续扩展 X/Twitter 等。

Agent Skills License: MIT

fetch-anything 把 YouTube、Bilibili 等难抓来源封装成可复用的 Agent Skills skill。编码 Agent 读取 skill 后,通过 CLI 获取视频简介、字幕,并按需下载媒体文件。

能做什么

来源 简介 字幕 下载视频 状态
YouTube ✅ 原始语言(yt-dlp → API → watch 页) 显式 --download stable
Bilibili ✅ 默认 ai-zh AI/CC 字幕 显式 --download stable
X / Twitter planned
Generic URL planned

本地 Mac 默认自动使用 Chrome cookies,无需先配 .env。付费/大会员内容依赖浏览器中已登录的同一账号。

完整 skill 规范见 skills/fetch-anything/SKILL.md

安装

方式 A — 交互式安装(推荐)

git clone <repo-url> fetch-anything && cd fetch-anything
pip install -e ".[dev]"
./scripts/install-skills.sh --interactive

向导会询问:

  1. 安装范围 — 仅当前项目,或全局(~/.cursor~/.claude 等)
  2. 目标 Agent — Cursor、Claude Code、OpenCode、Codex、CodeBuddy、GitHub Copilot

方式 B — 指定 Agent

# 只装到 Cursor 和 Claude Code(当前项目)
./scripts/install-skills.sh --agent cursor --agent claude

# 全局安装到 Cursor
./scripts/install-skills.sh --global --agent cursor

# 查看支持的 Agent 列表
./scripts/install-skills.sh --list-agents

方式 C — 安装到所有 Agent

./scripts/install-skills.sh              # 当前项目,全部 Agent
./scripts/install-skills.sh --global     # 全局,全部 Agent(Copilot 仅项目级)

方式 D — 生态工具

若目标项目只需 skill 文件、不需要完整 Python 包:

npx skills add <owner>/fetch-anything

方式 E — 作为子模块引入其他项目

git submodule add <repo-url> vendor/fetch-anything
cd vendor/fetch-anything && pip install -e ".[dev]"
./scripts/install-skills.sh --agent cursor

快速开始

1. 安装依赖

pip install -e ".[dev]"

本地 Mac 可直接抓取(自动读 Chrome cookies)。可选:

cp .env.example .env   # 服务器/Docker 才需要显式配置 cookies 文件
skills/fetch-anything/scripts/check-env.sh

YouTube 需要 Node.js(yt-dlp n-challenge);Bilibili 不需要。

2. 用 Agent 抓取

在已安装 skill 的 Agent 中:

抓取这个 YouTube 视频的字幕:https://www.youtube.com/watch?v=VIDEO_ID
抓取这个 B 站视频的简介和字幕:https://www.bilibili.com/video/BVxxx

3. 用 CLI 抓取

# 自动识别来源
fetch "https://www.youtube.com/watch?v=VIDEO_ID" --content
fetch "https://www.bilibili.com/video/BVxxx" --json -o data/fetches/

# 显式来源
fetch youtube VIDEO_ID --json -o data/fetches/
fetch bilibili BVxxx --json -o data/fetches/
fetch bilibili BVxxx --download --output-dir data/ytdlp-downloads

# 查看来源
fetch list
fetch detect "https://www.bilibili.com/video/BVxxx"

兼容别名:fetch-youtubefetch-bilibili

4. Python API

from fetch_anything.fetch import fetch
from fetch_anything.types import FetchOptions

result = await fetch("https://www.bilibili.com/video/BVxxx")
result = await fetch("VIDEO_ID", FetchOptions(download_media=True), source="youtube")
print(result.to_content())

工具兼容性

本 skill 遵循 agentskills.io 开放标准:

工具 安装命令
Cursor ./scripts/install-skills.sh --agent cursor
Claude Code ./scripts/install-skills.sh --agent claude
OpenCode ./scripts/install-skills.sh --agent opencode
Codex CLI ./scripts/install-skills.sh --agent codex
CodeBuddy ./scripts/install-skills.sh --agent codebuddy
GitHub Copilot ./scripts/install-skills.sh --agent copilot
全部 Agent ./scripts/install-skills.sh --interactive

全局安装加 --global。详细路径约定见 skills/fetch-anything/references/agents.md

目录结构

fetch-anything/
├── skills/fetch-anything/     ← Skill 源(SKILL.md、references/)
├── commands/                  ← Agent slash commands(/fetch、/fetch:bilibili 等)
├── src/fetch_anything/        ← Python 包(youtube/、bilibili/)
├── scripts/
│   ├── install-skills.sh
│   ├── export_youtube_cookies.sh
│   └── export_bilibili_cookies.sh
└── .cursor/skills -> ../skills

常见问题

安装后 Agent 找不到 skill?

  • 项目级安装:用 Agent 打开本仓库根目录
  • 全局安装:重启 Agent,或运行 ./scripts/install-skills.sh --global --agent <name>
  • Cursor:Settings → Rules → 查看 Skills 列表

YouTube:Sign in to confirm you're not a bot

本地:在 Chrome 打开 youtube.com 并登录,然后重新 fetch
Docker/服务器:./scripts/export_youtube_cookies.sh,见 .env.example

Bilibili:HTTP 412 / 无字幕只有弹幕?

本地:在 Chrome 打开 bilibili.com 并刷新登录态(大会员/已购课程需同一账号),然后重新 fetch
Docker/服务器:./scripts/export_bilibili_cookies.sh

只需要 skill,不需要 Python 包?

可以用 npx skills add,但实际抓取仍依赖本仓库的 fetch CLI 与 yt-dlp,建议完整安装。

开发

pip install -e ".[dev]"
pytest

Agent 开发指引见 AGENTS.md
YouTube / Bilibili 细节见 references/youtube.mdreferences/bilibili.md

License

MIT

About

抓取一切url,方便用于总结摘要

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages