mk-youtube-get-audio
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseYouTube Audio Download
YouTube音频下载
Download video audio file (best available format, no conversion).
下载视频音频文件(采用可用的最佳格式,无需转换)。
Quick Start
快速开始
/mk-youtube-get-audio <URL> [output_dir] [browser] [--force]/mk-youtube-get-audio <URL> [output_dir] [browser] [--force]Parameters
参数
| Parameter | Required | Default | Description |
|---|---|---|---|
| URL | Yes | - | YouTube video URL |
| output_dir | No | /tmp/monkey_knowledge/youtube/audio | Output directory for audio file |
| browser | No | auto | Browser for cookies (chrome, firefox, safari, edge, brave) |
| --force | No | false | Force re-download even if cached file exists |
| 参数 | 是否必填 | 默认值 | 描述 |
|---|---|---|---|
| URL | 是 | - | YouTube视频链接 |
| output_dir | 否 | /tmp/monkey_knowledge/youtube/audio | 音频文件的输出目录 |
| browser | 否 | auto | 用于获取Cookie的浏览器(chrome, firefox, safari, edge, brave) |
| --force | 否 | false | 即使存在缓存文件,强制重新下载 |
Examples
示例
- - Download with auto cookie fallback
/mk-youtube-get-audio https://youtube.com/watch?v=xxx - - Save to custom directory
/mk-youtube-get-audio https://youtube.com/watch?v=xxx ~/Music - - Use Chrome cookies
/mk-youtube-get-audio https://youtube.com/watch?v=xxx /tmp chrome
- - 使用自动Cookie回退机制下载
/mk-youtube-get-audio https://youtube.com/watch?v=xxx - - 保存到自定义目录
/mk-youtube-get-audio https://youtube.com/watch?v=xxx ~/Music - - 使用Chrome的Cookie
/mk-youtube-get-audio https://youtube.com/watch?v=xxx /tmp chrome
How it Works
工作原理
- Execute:
{baseDir}/scripts/audio.sh "<URL>" "<output_dir>" "<browser>" - First attempt: download without authentication
- If failed: retry with browser cookies (auto-detect or specified)
- Parse JSON output to get file path
┌─────────────────────────────┐
│ First attempt (no auth) │
└──────────────┬──────────────┘
│
┌───────┴───────┐
│ │
Success Failed
│ │
▼ ▼
[Return] ┌─────────────────────┐
│ Retry with cookies │
│ chrome → firefox → │
│ safari → edge → │
│ brave │
└──────────┬──────────┘
│
┌───────┴───────┐
│ │
Success Failed
│ │
▼ ▼
[Return] [Error]- 执行命令:
{baseDir}/scripts/audio.sh "<URL>" "<output_dir>" "<browser>" - 首次尝试:无需认证直接下载
- 如果失败:使用浏览器Cookie重试(自动检测或指定浏览器)
- 解析JSON输出获取文件路径
┌─────────────────────────────┐
│ 首次尝试(无认证) │
└──────────────┬──────────────┘
│
┌───────┴───────┐
│ │
成功 失败
│ │
▼ ▼
[返回结果] ┌─────────────────────┐
│ 使用Cookie重试 │
│ chrome → firefox → │
│ safari → edge → │
│ brave │
└──────────┬──────────┘
│
┌───────┴───────┐
│ │
成功 失败
│ │
▼ ▼
[返回结果] [返回错误]Output Format
输出格式
Success:
json
{
"status": "success",
"file_path": "/tmp/monkey_knowledge/youtube/audio/20091025__VIDEO_ID.m4a",
"file_size": "5.2M",
"cached": false,
"video_id": "dQw4w9WgXcQ",
"title": "Video Title",
"channel": "Channel Name",
"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"duration_string": "3:32"
}Cache hit (returns existing file):
json
{
"status": "success",
"file_path": "/tmp/monkey_knowledge/youtube/audio/20091025__VIDEO_ID.m4a",
"file_size": "5.2M",
"cached": true,
...
}Error:
json
{
"status": "error",
"message": "Download failed (tried with and without cookies)"
}成功:
json
{
"status": "success",
"file_path": "/tmp/monkey_knowledge/youtube/audio/20091025__VIDEO_ID.m4a",
"file_size": "5.2M",
"cached": false,
"video_id": "dQw4w9WgXcQ",
"title": "视频标题",
"channel": "频道名称",
"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"duration_string": "3:32"
}命中缓存(返回已存在的文件):
json
{
"status": "success",
"file_path": "/tmp/monkey_knowledge/youtube/audio/20091025__VIDEO_ID.m4a",
"file_size": "5.2M",
"cached": true,
...
}错误:
json
{
"status": "error",
"message": "下载失败(已尝试带Cookie和不带Cookie的方式)"
}Filename Format
文件名格式
Files use unified naming with date prefix:
{YYYYMMDD}__{video_id}.{ext}Example:
20091025__dQw4w9WgXcQ.m4a文件采用统一命名格式,带有日期前缀:
{YYYYMMDD}__{video_id}.{ext}示例:
20091025__dQw4w9WgXcQ.m4aBrowser Cookie Fallback
浏览器Cookie回退机制
When download fails (e.g., member-only or age-restricted content), the script automatically:
- Tries each browser: chrome → firefox → safari → edge → brave
- For Chrome: tries all profiles (Default, Profile 1, Profile 2, ...)
- Uses first successful browser/profile combination
Supported browsers:
| Browser | Parameter | Chrome Profile Support |
|---|---|---|
| Chrome | | Yes (auto-detect all profiles) |
| Firefox | | Default profile only |
| Safari | | Default profile only |
| Edge | | Default profile only |
| Brave | | Default profile only |
当下载失败时(例如会员专属或年龄限制内容),脚本会自动:
- 尝试每个浏览器:chrome → firefox → safari → edge → brave
- 对于Chrome:尝试所有配置文件(Default, Profile 1, Profile 2, ...)
- 使用第一个成功的浏览器/配置文件组合
支持的浏览器:
| 浏览器 | 参数值 | Chrome配置文件支持 |
|---|---|---|
| Chrome | | 是(自动检测所有配置文件) |
| Firefox | | 仅默认配置文件 |
| Safari | | 仅默认配置文件 |
| Edge | | 仅默认配置文件 |
| Brave | | 仅默认配置文件 |
Use Cases
使用场景
- Download audio for speech-to-text when video has no subtitles
- Podcast or music download
- Member-only or age-restricted content (with browser cookies)
- 当视频没有字幕时,下载音频用于语音转文字
- 播客或音乐下载
- 会员专属或年龄限制内容(需借助浏览器Cookie)
Notes
注意事项
- File caching: If audio file already exists for this video, it will be reused (returns )
cached: true - Force refresh: Use flag to re-download even if cached file exists
--force - Uses system yt-dlp/jq if available, otherwise auto-downloads on first run
- No ffmpeg required (uses best available format without conversion)
- Output format depends on source (typically m4a, webm, or opus)
- Cookie fallback only activates when initial download fails
- Using cookies may risk YouTube account suspension - use secondary account if needed
- 文件缓存:如果该视频的音频文件已存在,将直接复用(返回)
cached: true - 强制刷新:使用标志可强制重新下载,即使缓存文件存在
--force - 如果系统中已安装yt-dlp/jq则直接使用,否则首次运行时自动下载
- 无需ffmpeg(采用可用的最佳格式,无需转换)
- 输出格式取决于源文件(通常为m4a、webm或opus)
- 仅当初始下载失败时,Cookie回退机制才会激活
- 使用Cookie可能导致YouTube账号被封禁 - 如有需要请使用次要账号
Next Step
下一步操作
After downloading the audio, invoke with the from the output:
/mk-youtube-audio-transcribefile_path/mk-youtube-audio-transcribe <file_path> [model] [language]Tip: If you know the video's language from , pass it as the language parameter for better model auto-selection (e.g., → belle-zh, → kotoba-ja).
/mk-youtube-get-infozhja下载音频后,使用输出中的调用命令:
file_path/mk-youtube-audio-transcribe/mk-youtube-audio-transcribe <file_path> [model] [language]提示:如果通过了解到视频的语言,可将其作为language参数传入,以获得更好的模型自动选择效果(例如: → belle-zh, → kotoba-ja)。
/mk-youtube-get-infozhja