YouTube Chapter Splitter
A simple and powerful Rust CLI tool to download YouTube videos, extract audio to MP3, and automatically split them into individual tracks based on chapters.
โจ Features
- ๐ต Download YouTube audio in high-quality MP3 format (192 kbps)
- ๐ผ๏ธ Download album artwork automatically with embedded cover art in MP3 tags
- ๐ Automatic chapter detection from YouTube video metadata
- ๐ Silence detection fallback for videos without chapters
- โ๏ธ Smart audio splitting with complete ID3 metadata tags (title, artist, album, track number, cover art)
- โ๏ธ Persistent configuration with customizable defaults (NEW in v0.8.1)
- ๐ Customizable filename format with placeholders (%n, %t, %a, %A)
- ๐ Customizable directory format for organized music library
- ๐จ Clean folder names with intelligent formatting (removes brackets, pipes, capitalizes)
- ๐ Progress bars for download and splitting operations
- ๐ฏ Force artist/album names with CLI options
- โก Dependency checking with automatic installation prompts
- ๐งน URL cleaning - automatically removes playlist and extra parameters
- ๐ชถ Lightweight binary (8.5 MB) with minimal dependencies
- ๐ถ Playlist support (NEW in v0.8.2)
- ๐ Retry mechanism for failed downloads (NEW in v0.8.2)
- ๋ฎ์ด์ฐ๊ธฐ Overwrite option for existing files (NEW in v0.8.2)
๐ Quick Start
Prerequisites
The application will check for dependencies at startup and offer to install them:
- yt-dlp:
pip install yt-dlp - ffmpeg:
- Linux:
sudo apt install ffmpeg - macOS:
brew install ffmpeg - Windows: Download from ffmpeg.org
- Linux:
Installation
Option 1: From crates.io (Recommended)
The ytcs binary will be installed in ~/.cargo/bin/ (make sure it's in your PATH).
Option 2: From source
# Clone the repository
# Build and install
Usage
Simple syntax:
Options:
-o, --output <DIR>- Output directory (overrides config)-a, --artist <ARTIST>- Force artist name (overrides auto-detection)-A, --album <ALBUM>- Force album name (overrides auto-detection)--no-cover- Skip downloading cover art--playlist- Force playlist download
Configuration commands:
ytcs config- Show current configurationytcs set <key> <value>- Set a configuration valueytcs reset- Reset configuration to defaults
Examples:
# Download and split a YouTube video (saves to ~/Music)
# Download a playlist
# Specify custom output directory
# Force artist and album names
# Skip cover art download
# Configure default output directory
# Customize filename format
# Show current configuration
Important: Always put URLs in quotes to avoid shell interpretation of special characters:
โ๏ธ Configuration
YouTube Chapter Splitter uses a persistent configuration file stored at:
- Linux/macOS:
~/.config/ytcs/config.toml - Windows:
%APPDATA%\ytcs\config.toml
Available Settings
| Setting | Default | Description |
|---|---|---|
default_output_dir |
~/Music |
Default download directory |
download_cover |
true |
Download album artwork |
filename_format |
"%n - %t" |
Filename format with placeholders |
directory_format |
"%a - %A" |
Directory format with placeholders |
audio_quality |
192 |
MP3 quality (128 or 192 kbps) |
overwrite_existing |
false |
Overwrite existing files |
max_retries |
3 |
Retries on download failure |
create_playlist |
false |
Create .m3u playlist file |
Format Placeholders
Filename format:
%n- Track number (01, 02, etc.)%t- Track title%a- Artist name%A- Album name
Directory format:
%a- Artist name%A- Album name
Configuration Examples
# Organize by artist, then album
# Result: ~/Music/Marigold/Oblivion Gate/
# Simple filenames without track numbers
# Result: Oblivion Gate.mp3
# Include artist in filename
# Result: Marigold - Oblivion Gate.mp3
# Disable cover art download by default
See CONFIGURATION_GUIDE.md for detailed configuration documentation.
๐ Example Output
=== YouTube Chapter Splitter ===
Fetching video information...
Title: Marigold - Oblivion Gate
Duration: 29m 29s
Tracks found: 5
Downloading album artwork...
โ Artwork saved: /home/user/Music/Marigold - Oblivion Gate/cover.jpg
โ Downloading audio from YouTube...
โ Audio downloaded: /home/user/Music/Marigold - Oblivion Gate/temp_audio.mp3
Using YouTube tracks
Tracks to create:
1. Oblivion Gate [5m 54s]
2. Obsidian Throne [5m 35s]
3. Crimson Citadel [5m 47s]
4. Silver Spire [6m 30s]
5. Eternal Pyre [5m 43s]
โ [โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ] 5/5 Track 5: Eternal Pyre
โ Splitting completed successfully!
โ Processing completed successfully!
Files created: 5
Directory: /home/user/Music/Marigold - Oblivion Gate
๐งช Testing
The project includes a comprehensive test suite with 172 tests covering:
# Run all tests
# Run tests with output
# Run specific test
๐ Changelog
v0.8.2 (2024)
- ๐ถ Added playlist support
- ๐ Added retry mechanism for failed downloads
- ๋ฎ์ด์ฐ๊ธฐ Added overwrite option for existing files
- ๐ง Added audio quality option (128/192 kbps)
v0.8.1 (2024)
- โ๏ธ Added persistent configuration system with TOML
- ๐ Customizable filename and directory formats
- ๐ Progress bars for download and splitting operations
- ๐จ Improved UX with colored output
- ๐ Comprehensive configuration documentation
v0.8.0 (2024)
- ๐๏ธ Removed TUI interface (simplified to CLI only)
- ๐งน Cleaned up dependencies
- โก Improved compilation time (-62%)
- ๐ฆ Reduced binary size to 7.8 MB
v0.7.0 (2024)
- ๐ฅ๏ธ Added TUI (Text User Interface) with ratatui
- ๐ฏ Interactive chapter selection
- โ๏ธ Metadata editing in TUI
v0.6.0 (2024)
- ๐งช Added 139 comprehensive tests (85% coverage)
- ๐ฏ Performance benchmarks with Criterion
- ๐ Unicode and emoji support in metadata
- โ Validation and edge case handling
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.