CLI tool to download YouTube playlists as audio with metadata
Project description
ytmusic
CLI tool to download YouTube playlists as audio with metadata.
A command-line tool that downloads YouTube playlists as audio files, automatically identifies songs using the iTunes API, and embeds rich metadata (artist, album, cover art) directly into the audio files.
Background
This tool was created to solve the problem of downloading music from YouTube playlists while maintaining proper metadata. Many existing tools download videos or audio without proper tagging, resulting in a disorganized music library. This tool:
- Automatically identifies songs using the iTunes API
- Downloads only audio streams (no video)
- Embeds cover art and metadata directly into audio files
- Names files consistently as "Artist - Song Title"
- Skips songs with poor metadata matches
Install
# Install from PyPI
pip install ytmusic
# Or with pipx (recommended for CLI tools)
pipx install ytmusic
# Or install from source with uv
uv sync
Dependencies
- Python 3.10+
- pytubefix (YouTube downloading)
- mutagen (audio metadata)
- rich (CLI output)
- requests (API calls)
See pyproject.toml for full dependency list.
Usage
# Run via the installed CLI
ytmusic "PLAYLIST_URL"
# Or module execution
python -m ytmusic "PLAYLIST_URL"
CLI
usage: ytmusic [-h] [-o DIR] [-t 0.0-1.0] [--dry-run] [--version] url
Download YouTube playlists as audio with rich metadata
positional arguments:
url YouTube playlist URL or ID
options:
-h, --help show this help message and exit
-o DIR, --output DIR Output directory (default: music_library)
-t 0.0-1.0, --threshold 0.0-1.0
Similarity threshold 0.0-1.0 (default: 0.5)
--dry-run Preview what would be downloaded
--version show program's version number and exit
Examples:
# Basic usage
ytmusic "https://www.youtube.com/playlist?list=PLAYLIST_ID"
# Custom output with stricter matching
ytmusic "PLAYLIST_URL" -o "my_music" -t 0.7
# Preview without downloading
ytmusic "PLAYLIST_URL" --dry-run
How It Works
- Playlist Fetching - Retrieves all video URLs from the playlist
- Title Parsing - Extracts "Artist - Song" from YouTube titles
- Metadata Search - Queries iTunes API for matching songs
- Similarity Check - Compares YouTube title with iTunes result
- Download - Gets audio-only stream (skips if similarity < threshold)
- Tagging - Embeds metadata and cover art into audio file
- Naming - Saves as "Artist - Song Title.m4a"
Configuration
Similarity Threshold
The threshold controls how strictly songs must match metadata:
| Threshold | Result |
|---|---|
| 0.3 | Lenient - More songs, less accurate |
| 0.5 | Balanced - (default) |
| 0.7 | Strict - Fewer songs, more accurate |
| 0.9 | Very strict - Only exact matches |
Output Organization
music_library/
└── Playlist Name/
├── Artist - Song Title.m4a
├── Artist - Song Title.m4a
└── ...
License
MIT © 2026
Releases
Prebuilt executables are available on GitHub Releases (Linux/macOS/Windows).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ytmusic_cli-1.1.0.tar.gz.
File metadata
- Download URL: ytmusic_cli-1.1.0.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a312943b2efdb61c9f80c698faedb04afbc25b1bd5b16d1b7a95b7f38ffd46c
|
|
| MD5 |
ef59d41917f83316caa24675b74a4abc
|
|
| BLAKE2b-256 |
cca969e557be28d10e61344b7a5799279edc550dc61dea7e01a5d11129130bb8
|
Provenance
The following attestation bundles were made for ytmusic_cli-1.1.0.tar.gz:
Publisher:
release.yml on ilyeshdz/ytmusic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ytmusic_cli-1.1.0.tar.gz -
Subject digest:
9a312943b2efdb61c9f80c698faedb04afbc25b1bd5b16d1b7a95b7f38ffd46c - Sigstore transparency entry: 1243635780
- Sigstore integration time:
-
Permalink:
ilyeshdz/ytmusic@6bce1573039e3a0b3b9c98840716dd42ce4e3096 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/ilyeshdz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6bce1573039e3a0b3b9c98840716dd42ce4e3096 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ytmusic_cli-1.1.0-py3-none-any.whl.
File metadata
- Download URL: ytmusic_cli-1.1.0-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de573899085ddad3752d49bb83471b0d4f14f99db9d6f58c163453ab45df792b
|
|
| MD5 |
c22242e3171508cea9d5fdbda048cbf9
|
|
| BLAKE2b-256 |
72ba752b7a0da39c7e00ec19fb33271f2dd20e513233c851c5cc3d7368131aa4
|
Provenance
The following attestation bundles were made for ytmusic_cli-1.1.0-py3-none-any.whl:
Publisher:
release.yml on ilyeshdz/ytmusic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ytmusic_cli-1.1.0-py3-none-any.whl -
Subject digest:
de573899085ddad3752d49bb83471b0d4f14f99db9d6f58c163453ab45df792b - Sigstore transparency entry: 1243635789
- Sigstore integration time:
-
Permalink:
ilyeshdz/ytmusic@6bce1573039e3a0b3b9c98840716dd42ce4e3096 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/ilyeshdz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6bce1573039e3a0b3b9c98840716dd42ce4e3096 -
Trigger Event:
push
-
Statement type: