|
| 1 | + |
| 2 | + |
| 3 | +# `yutu` |
| 4 | + |
| 5 | +[](https://gitmoji.dev) |
| 6 | +[](https://goreportcard.com/report/github.com/eat-pray-ai/yutu) |
| 7 | +[](https://github.com/eat-pray-ai/yutu?tab=Apache-2.0-1-ov-file) |
| 8 | +[](https://pkg.go.dev/github.com/eat-pray-ai/yutu) |
| 9 | +[](https://raw.githack.com/wiki/eat-pray-ai/yutu/coverage.html) |
| 10 | + |
| 11 | +[](https://github.com/eat-pray-ai/yutu/stargazers) |
| 12 | +[](https://github.com/eat-pray-ai/yutu/releases/latest) |
| 13 | +[](https://github.com/eat-pray-ai/yutu/actions/workflows/publish.yml) |
| 14 | +[](https://github.com/eat-pray-ai/yutu/actions/workflows/codeql.yml) |
| 15 | +[](https://github.com/eat-pray-ai/yutu/actions/workflows/test.yml) |
| 16 | +[](https://archestra.ai/mcp-catalog/eat-pray-ai__yutu) |
| 17 | + |
| 18 | +[](https://github.com/eat-pray-ai/yutu/releases/latest) |
| 19 | +[](https://formulae.brew.sh/formula/yutu) |
| 20 | +[](https://winstall.app/apps/eat-pray-ai.yutu) |
| 22 | + |
| 23 | +[](https://www.producthunt.com/posts/yutu?embed=true&utm_source=badge-featured&utm_medium=badge&utm_souce=badge-yutu) |
| 24 | + |
| 25 | +`yutu` 是一个全功能的 MCP 服务器和 YouTube CLI 工具,用于自动化您的 YouTube 工作流程。它可以操作几乎所有的 YouTube 资源,如视频、播放列表、频道、评论、字幕等。 |
| 26 | + |
| 27 | +[](https://asciinema.org/a/wXIHU4ciFBAKrHfaFNkMoIs12) |
| 28 | + |
| 29 | +## 目录 |
| 30 | + |
| 31 | +- [前提条件](#前提条件) |
| 32 | +- [安装](#安装) |
| 33 | + - [GitHub Actions](#github-actions) |
| 34 | + - [Docker](#docker) |
| 35 | + - [Gopher](#gopher) |
| 36 | + - [Linux](#linux) |
| 37 | + - [macOS](#macos) |
| 38 | + - [Windows](#windows) |
| 39 | + - [验证安装](#验证安装) |
| 40 | +- [MCP 服务器](#mcp-服务器) |
| 41 | +- [使用方法](#使用方法) |
| 42 | +- [功能特性](#功能特性) |
| 43 | +- [贡献](#贡献) |
| 44 | + |
| 45 | +## 前提条件 |
| 46 | + |
| 47 | +开始之前,您需要在 [Google Cloud Platform](https://console.cloud.google.com/) 上创建一个账户来创建**项目**,并为该项目启用以下 API,位置在 `APIs & Services -> Enable APIs and services -> + ENABLE APIS AND SERVICES` |
| 48 | + |
| 49 | +- [YouTube Data API v3(必需)](https://console.cloud.google.com/apis/api/youtubeanalytics.googleapis.com/overview) |
| 50 | +- [YouTube Analytics API(可选)](https://console.cloud.google.com/apis/api/youtubeanalytics.googleapis.com/overview) |
| 51 | +- [YouTube Reporting API(可选)](https://console.cloud.google.com/apis/api/youtubereporting.googleapis.com/overview) |
| 52 | + |
| 53 | +启用 API 后,创建一个 `OAuth content screen`,将您自己设置为测试用户,然后创建一个类型为 `Web Application` 的 `OAuth Client ID`,将 `http://localhost:8216` 作为重定向 URI。 |
| 54 | + |
| 55 | +将此凭据下载到本地机器,命名为 `client_secret.json`,它应该看起来像这样: |
| 56 | + |
| 57 | +```json |
| 58 | +{ |
| 59 | + "web": { |
| 60 | + "client_id": "11181119.apps.googleusercontent.com", |
| 61 | + "project_id": "yutu-11181119", |
| 62 | + "auth_uri": "https://accounts.google.com/o/oauth2/auth", |
| 63 | + "token_uri": "https://oauth2.googleapis.com/token", |
| 64 | + "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", |
| 65 | + "client_secret": "XXXXXXXXXXXXXXXX", |
| 66 | + "redirect_uris": [ |
| 67 | + "http://localhost:8216" |
| 68 | + ] |
| 69 | + } |
| 70 | +} |
| 71 | +``` |
| 72 | + |
| 73 | +要验证此凭据,请运行以下命令: |
| 74 | + |
| 75 | +```shell |
| 76 | +❯ yutu auth --credential client_secret.json |
| 77 | +``` |
| 78 | + |
| 79 | +浏览器窗口将打开,要求您授权访问您的 YouTube 账户。授权后,将生成一个令牌并保存到 `youtube.token.json`。 |
| 80 | + |
| 81 | +```json |
| 82 | +{ |
| 83 | + "access_token": "ya29.XXXXXXXXX", |
| 84 | + "token_type":"Bearer", |
| 85 | + "refresh_token":"1//XXXXXXXXXX", |
| 86 | + "expiry":"2024-05-26T18:49:56.1911165+08:00" |
| 87 | +} |
| 88 | +``` |
| 89 | + |
| 90 | +默认情况下,`yutu` 将从当前目录读取 `client_secret.json` 和 `youtube.token.json`,`--credential/-c` 和 `--cacheToken/-t` 标志仅在 `auth` 子命令中可用。要在所有子命令中修改默认路径,请设置这些环境变量: |
| 91 | + |
| 92 | +```shell |
| 93 | +❯ export YUTU_CREDENTIAL=client_secret.json |
| 94 | +❯ export YUTU_CACHE_TOKEN=youtube.token.json |
| 95 | +# 或 |
| 96 | +❯ YUTU_CREDENTIAL=client_secret.json YUTU_CACHE_TOKEN=youtube.token.json yutu subcommand --flag value |
| 97 | +``` |
| 98 | + |
| 99 | +## 安装 |
| 100 | + |
| 101 | +您可以直接从[发布页面](https://github.com/eat-pray-ai/yutu/releases/latest)下载 `yutu`,或使用以下您喜欢的方法。 |
| 102 | + |
| 103 | +### GitHub Actions |
| 104 | + |
| 105 | +yutu 有两个可用的 action,一个是通用 action,另一个专用于上传视频到 YouTube。更多信息请参考 [youtube-action](https://github.com/eat-pray-ai/youtube-action) 和 [youtube-uploader](https://github.com/eat-pray-ai/youtube-uploader)。 |
| 106 | + |
| 107 | +### Docker |
| 108 | + |
| 109 | +```shell |
| 110 | +❯ docker pull ghcr.io/eat-pray-ai/yutu:latest |
| 111 | +❯ docker run --rm ghcr.io/eat-pray-ai/yutu:latest |
| 112 | +# 确保 client_secret.json 在当前目录中 |
| 113 | +❯ docker run --rm -it -u $(id -u):$(id -g) -v $(pwd):/app ghcr.io/eat-pray-ai/yutu:latest auth |
| 114 | +``` |
| 115 | + |
| 116 | +### Gopher |
| 117 | + |
| 118 | +```shell |
| 119 | +❯ go install github.com/eat-pray-ai/yutu@latest |
| 120 | +``` |
| 121 | + |
| 122 | +### Linux |
| 123 | + |
| 124 | +```shell |
| 125 | +❯ curl -sSfL https://raw.githubusercontent.com/eat-pray-ai/yutu/main/scripts/install.sh | bash |
| 126 | +``` |
| 127 | + |
| 128 | +### macOS |
| 129 | + |
| 130 | +使用 [Homebrew🍺](https://brew.sh/) 安装 `yutu`(推荐),或运行 shell 脚本。 |
| 131 | + |
| 132 | +```shell |
| 133 | +❯ brew install yutu |
| 134 | + |
| 135 | +# 或 |
| 136 | +❯ curl -sSfL https://raw.githubusercontent.com/eat-pray-ai/yutu/main/scripts/install.sh | bash |
| 137 | +``` |
| 138 | + |
| 139 | +### Windows |
| 140 | + |
| 141 | +```shell |
| 142 | +❯ winget install yutu |
| 143 | +``` |
| 144 | + |
| 145 | +### 验证安装 |
| 146 | + |
| 147 | +使用其关联的加密签名证明来验证 `yutu` 的完整性和来源。 |
| 148 | + |
| 149 | +```shell |
| 150 | +# Docker |
| 151 | +❯ gh attestation verify oci://ghcr.io/eat-pray-ai/yutu:latest --repo eat-pray-ai/yutu |
| 152 | + |
| 153 | +# Linux 和 macOS(如果使用 shell 脚本安装) |
| 154 | +❯ gh attestation verify $(which yutu) --repo eat-pray-ai/yutu |
| 155 | + |
| 156 | +# Windows |
| 157 | +❯ gh attestation verify $(where.exe yutu.exe) --repo eat-pray-ai/yutu |
| 158 | +``` |
| 159 | + |
| 160 | +## MCP 服务器 |
| 161 | + |
| 162 | +[](https://insiders.vscode.dev/redirect/mcp/install?name=yutu&config=%7B%22type%22%3A%20%22stdio%22%2C%22command%22%3A%20%22yutu%22%2C%22args%22%3A%20%5B%22mcp%22%5D%2C%22env%22%3A%20%7B%22YUTU_CREDENTIAL%22%3A%20%22%2Fabsolute%2Fpath%2Fto%2Fclient_secret.json%22%2C%22YUTU_CACHE_TOKEN%22%3A%20%22%2Fabsolute%2Fpath%2Fto%2Fyoutube.token.json%22%7D%7D) |
| 163 | +[](https://cursor.com/install-mcp?name=yutu&config=JTdCJTIyY29tbWFuZCUyMiUzQSUyMnl1dHUlMjBtY3AlMjIlMkMlMjJlbnYlMjIlM0ElN0IlMjJZVVRVX0NSRURFTlRJQUwlMjIlM0ElMjIlMkZhYnNvbHV0ZSUyRnBhdGglMkZ0byUyRmNsaWVudF9zZWNyZXQuanNvbiUyMiUyQyUyMllVVFVfQ0FDSEVfVE9LRU4lMjIlM0ElMjIlMkZhYnNvbHV0ZSUyRnBhdGglMkZ0byUyRnlvdXR1YmUudG9rZW4uanNvbiUyMiU3RCU3RA%3D%3D) |
| 164 | + |
| 165 | +作为一个 [MCP 服务器](https://modelcontextprotocol.io/introduction),`yutu` 可以在 MCP 客户端中使用,如 [Claude Desktop](https://modelcontextprotocol.io/quickstart/user)、[VS Code](https://code.visualstudio.com/) 或 [Cursor](https://docs.cursor.com/) 等,这允许您通过聊天的形式与 YouTube 资源进行交互。 |
| 166 | + |
| 167 | +在将 `yutu` 用作 MCP 服务器之前,请确保已安装 `yutu`(参见[安装](#安装)部分),并且您有有效的 `client_secret.json` 和 `youtube.token.json` 文件(参考[前提条件](#前提条件)部分)。 |
| 168 | + |
| 169 | +您可以通过点击上面相应的徽章将 `yutu` 添加为 VS Code 或 Cursor 中的 MCP 服务器,或手动将以下配置添加到您的 MCP 客户端。记得将 `YUTU_CREDENTIAL` 和 `YUTU_CACHE_TOKEN` 的值替换为您本地机器上的正确路径。 |
| 170 | + |
| 171 | +```json |
| 172 | +{ |
| 173 | + "yutu": { |
| 174 | + "type": "stdio", |
| 175 | + "command": "yutu", |
| 176 | + "args": [ |
| 177 | + "mcp" |
| 178 | + ], |
| 179 | + "env": { |
| 180 | + "YUTU_CREDENTIAL": "/absolute/path/to/client_secret.json", |
| 181 | + "YUTU_CACHE_TOKEN": "/absolute/path/to/youtube.token.json" |
| 182 | + } |
| 183 | + } |
| 184 | +} |
| 185 | +``` |
| 186 | + |
| 187 | +## 使用方法 |
| 188 | + |
| 189 | +```shell |
| 190 | +❯ yutu |
| 191 | +yutu is a fully functional MCP server and CLI for YouTube, which can manipulate almost all YouTube resources |
| 192 | + |
| 193 | +Usage: |
| 194 | + yutu [flags] |
| 195 | + yutu [command] |
| 196 | + |
| 197 | +Available Commands: |
| 198 | + activity List YouTube activities |
| 199 | + auth Authenticate with YouTube API |
| 200 | + caption Manipulate YouTube captions |
| 201 | + channel Manipulate YouTube channels |
| 202 | + channelBanner Insert Youtube channel banner |
| 203 | + channelSection Manipulate YouTube channel sections |
| 204 | + comment Manipulate YouTube comments |
| 205 | + commentThread Manipulate YouTube comment threads |
| 206 | + completion Generate the autocompletion script for the specified shell |
| 207 | + help Help about any command |
| 208 | + i18nLanguage List YouTube i18n languages |
| 209 | + i18nRegion List YouTube i18n regions |
| 210 | + mcp Start MCP server |
| 211 | + member List channel's members' info |
| 212 | + membershipsLevel List memberships levels' info |
| 213 | + playlist Manipulate YouTube playlists |
| 214 | + playlistImage Manipulate YouTube playlist images |
| 215 | + playlistItem Manipulate YouTube playlist items |
| 216 | + search Search for YouTube resources |
| 217 | + subscription Manipulate YouTube subscriptions |
| 218 | + superChatEvent List Super Chat events for a channel |
| 219 | + thumbnail Set thumbnail for a video |
| 220 | + version Show the version of yutu |
| 221 | + video Manipulate YouTube videos |
| 222 | + videoAbuseReportReason List YouTube video abuse report reasons |
| 223 | + videoCategory List YouTube video categories |
| 224 | + watermark Manipulate YouTube watermarks |
| 225 | +
|
| 226 | +Flags: |
| 227 | + -h, --help help for yutu |
| 228 | +
|
| 229 | +Use "yutu [command] --help" for more information about a command. |
| 230 | +``` |
| 231 | +
|
| 232 | +## 功能特性 |
| 233 | +
|
| 234 | +请参考 [FEATURES.md](docs/FEATURES.md) 获取更多信息。 |
| 235 | +
|
| 236 | +## 贡献 |
| 237 | +
|
| 238 | +请参考 [CONTRIBUTING.md](docs/CONTRIBUTING.md) 获取更多信息。 |
| 239 | +
|
| 240 | +## Star 历史 |
| 241 | +
|
| 242 | +[](https://star-history.com/#eat-pray-ai/yutu&Date) |
0 commit comments