🎵 Agent-ready music CLI — JSON output, batch pipe, zero config
- 🎯 Multi-source — YouTube, Bilibili, SoundCloud, Bandcamp, Netease
- 📝 Lyrics embedded — Auto-fetch and write ID3 USLT into MP3
- ⚡ Sequential probing — Tries sources in order, stops at first hit
- 🔧 Self-diagnosis —
doctorchecks yt-dlp, ffmpeg, network - 📦 Zero config — Works out of the box
- 🤖 Scriptable — All commands support
--jsonfor structured output
npm install -g @aimtao/music-cliOr build from source:
git clone <repo-url>
cd music-cli
bash setup.shRequires yt-dlp. ffmpeg is optional.
# Download a song
music-cli download "Song Name" "Artist Name"
# JSON output
music-cli download "Song Name" "Artist Name" --json
# List downloaded
music-cli list
# Diagnose environment
music-cli doctor| Command | Description |
|---|---|
download |
Download songs |
list |
List downloaded songs |
lyrics |
Fetch lyrics |
doctor |
Diagnose environment |
sources |
List available sources |
info |
Show system info |
./config.json
{
"outputDir": "~/Music/music-cli",
"sources": ["youtube", "bilibili", "soundcloud", "bandcamp", "netease"],
"timeout": 10,
"concurrency": 2,
"embedLyrics": true
}MIT
All commands support --json for structured output.
music-cli download "Song Name" "Artist" --jsonBatch via stdin:
echo '[{"name":"Song 1","artist":"Artist 1"},{"name":"Song 2","artist":"Artist 2"}]' | music-cli download --jsonSuccess:
{
"success": true,
"file": "/Users/.../Music/music-cli/Song Name Artist.mp3",
"source": "youtube",
"size": 3856029,
"lyrics": { "success": true }
}Failure:
{
"success": false,
"error": "All sources failed",
"tried": ["youtube", "bilibili", "soundcloud", "bandcamp", "netease"]
}Sources are tried sequentially: YouTube → Bilibili → SoundCloud → Bandcamp → Netease.
music-cli list --json{
"success": true,
"total": 5,
"totalSize": 19281920,
"songs": [
{ "name": "Song Name Artist", "file": "/path/to/song.mp3", "size": 3856029, "hasLyrics": true }
]
}music-cli doctor --json{
"success": true,
"tools": { "node": "v20.0.0", "npm": "9.0.0", "yt-dlp": "2024.01.01", "ffmpeg": "6.0" },
"network": { "youtube": { "reachable": true, "latency": 120 } }
}| Key | Type | Default | Description |
|---|---|---|---|
outputDir |
string | ~/Downloads/music-cli |
Download directory |
sources |
string[] | all 5 | Enabled sources |
timeout |
number | 10 | Per-source timeout (seconds) |
concurrency |
number | 2 | Parallel probe count |
embedLyrics |
boolean | true | Auto-embed lyrics into MP3 |
MUSIC_OUTPUT_DIR env var overrides outputDir.
- MP3:
{outputDir}/{song} {artist}.mp3 - Lyrics: embedded as ID3v2.4 USLT (UTF-8),
.lrcdeleted after embedding
0— Success1— Failure (check JSON for details)