Skip to main content

A production-ready YouTube music playlist manager and synchronizer (YT Music Manager CLI)

Project description

YT Music Manager CLI (YTMM CLI)

Python Version License

A production-ready YouTube & YouTube music playlist manager that downloads and keeps your music playlists in sync. No API keys or authentication required for public playlists! (YT Music Manager CLI)

๐ŸŽต Features

  • ๐Ÿ“ Zero Setup: Works immediately with public playlists - no API keys needed!
  • ๐Ÿ”„ Automatic Playlist Sync: Download and sync multiple YouTube playlists
  • ๐ŸŽง High-Quality Audio: Downloads in MP3 format with configurable quality
  • ๐Ÿ“ Organized Storage: Creates subfolders for each playlist automatically
  • โšก Smart Updates: Only downloads new songs and removes deleted ones
  • ๐Ÿ” Flexible Authentication: Public playlists (no auth), bundled OAuth (zero setup), or custom OAuth credentials
  • ๐Ÿ›ก๏ธ Production Ready: Comprehensive error handling, logging, and recovery
  • ๐Ÿ–ฅ๏ธ Easy CLI: Simple command-line interface with rich progress display
  • โš™๏ธ Configurable: Customizable download paths, quality settings, and more
  • ๐Ÿ“Š Progress Tracking: Real-time download progress and sync statistics

๐Ÿ“‹ Requirements

  • Python 3.8+
  • Internet connection
  • Optional: Google OAuth for private playlists

๐Ÿš€ Quick Start

1. Installation

# Install from PyPI (Recommended)
pip install yt-music-manager-cli

# OR:

# Clone the repository
git clone https://github.com/sukarth/yt-music-manager-cli.git
cd yt-music-manager-cli

# and innstall the package
pip install -e .

2. Start Using Immediately!

No configuration needed for public playlists:

# Add a public playlist and start downloading
ytmm add-playlist "https://www.youtube.com/playlist?list=PLrAXtmRdnEQy6nuLMt9xrTwCcEcPvQv51"

# Sync all playlists
ytmm sync

That's it! The app works out of the box with public YouTube playlists.

3. Authentication and private playlists

For private playlists or advanced features, you can set up authentication:

Option A: Use bundled Google Sign-In (Recommended, zero setup)

# Sign in with your Google account in your browser when prompted:
ytmm auth mode auto_oauth -y

Option B: Custom OAuth Credentials

# Use your own OAuth credentials
ytmm auth mode manual_oauth -y

# Follow the interactive setup process

4. Configuration

The app works with default settings, but you can customize everything:

# Initialize configuration file
ytmm init

# View current settings
ytmm config

Edit config/settings.toml:

[youtube]
auth_method = "no_auth"  # Options: "no_auth", "auto_oauth", "manual_oauth"

[download]
base_path = "~/Music/YouTube Playlists"
audio_format = "mp3" 
audio_quality = "192"

[sync]
max_concurrent_downloads = 3
auto_sync_interval = 3600

Or change specific values:

ytmm config set download.audio_quality '320'

# Result:
# [OK] Set download.audio_quality = 320
# Please restart the application for changes to take effect.

5. Add and Sync Playlists

# Add a public playlist (works immediately, no setup needed)
ytmm add-playlist "https://www.youtube.com/playlist?list=PLrAXtmRdnEQy6nuLMt9xrTwCcEcPvQv51"

# Add a playlist with a custom name
ytmm add-playlist "https://youtube.com/playlist?list=..." --name "My Favorites"

# Sync all playlists
ytmm sync --all

# Sync specific playlist
ytmm sync "My Playlist Name"

# Add and sync immediately
ytmm add-playlist "https://youtube.com/playlist?list=..." 
# (Will ask if you want to sync right away)

# Preview changes without downloading
ytmm sync --all --dry-run

๐Ÿ” Authentication Management

YT Music Manager CLI supports three authentication modes:

No Authentication (Default)

  • Access: Public playlists only
  • Setup: None required - works immediately
  • Limitations: Cannot access private/unlisted playlists
# Check current authentication status
ytmm auth status

# Switch to no-auth mode
ytmm auth mode no_auth -y

Bundled Google Sign-In (auto_oauth)

  • Access: All your playlists (public and private)
  • Setup: None required - uses bundled OAuth credentials
  • Benefits: Full access, zero setup, no API quotas
# Switch to bundled OAuth (and follow process to login with Google)
ytmm auth mode auto_oauth -y

# Sign out/remove account
ytmm auth remove login

Custom OAuth (manual_oauth)

  • Access: All your playlists (public and private)
  • Setup: Your own OAuth app configuration
  • Benefits: Full access, your own credentials
# Switch to custom OAuth mode
ytmm auth mode manual_oauth -y

# Sign out/remove creds
ytmm auth remove creds

๐Ÿ“– Usage Guide

Commands

Command Description
ytmm init Initialize configuration and setup
ytmm add-playlist <url> Add a YouTube playlist to track
ytmm list-playlists Show all tracked playlists
ytmm sync [playlist] Sync playlists (download new, remove old)
ytmm sync --all Sync all tracked playlists
ytmm remove-playlist <name> Stop tracking a playlist
ytmm status Show sync status and statistics
ytmm config Show current configuration
ytmm auth status Show authentication status
ytmm auth mode <mode> Switch authentication mode (no_auth/auto_oauth/manual_oauth)
ytmm auth remove <arg> Sign out and remove credentials (login/creds)
ytmm config Show config status
ytmm config list List full config
ytmm config list <section.key> List specific config value
ytmm config set <section.key> <value> Set configuration value

Examples

# Add multiple playlists
ytmm add-playlist "https://www.youtube.com/playlist?list=PLrAXtmRdnEQy5lVX..."
ytmm add-playlist "https://www.youtube.com/watch?v=abc&list=PLxyz..."

# List all tracked playlists
ytmm list-playlists --detailed

# Sync with custom options
# Preview changes
ytmm sync --all --dry-run
# Sync specific playlist
ytmm sync "Chill Music"

# Check status and statistics
ytmm status

# Remove a playlist (keep files)
ytmm remove-playlist "Old Playlist" --keep-files

โš™๏ธ Configuration

The configuration file is located at config/settings.toml:

[youtube]
auth_method = "no_auth"  # no_auth, auto_oauth, or manual_oauth

[download]
base_path = "~/Music/YouTube Playlists"
audio_format = "mp3"              # mp3, aac, ogg, wav, flac
audio_quality = "192"             # 64-320 kbps

[sync]
auto_sync_interval = 3600         # Auto-sync every hour
max_concurrent_downloads = 3      # Parallel downloads
check_for_updates_on_start = true
preserve_deleted_locally = false  # Delete files removed from playlist

[logging]
level = "INFO"                    # DEBUG, INFO, WARNING, ERROR
log_file = "logs/yt_music_manager_cli.log"
max_log_size = "10MB"
backup_count = 5

๐Ÿ“ Local Downloaded Playlists File Organization

~/Music/YouTube Playlists/
โ”œโ”€โ”€ My Chill Playlist/
โ”‚   โ”œโ”€โ”€ Song 1.mp3
โ”‚   โ”œโ”€โ”€ Song 2.mp3
โ”‚   โ””โ”€โ”€ Song 3.mp3
โ”œโ”€โ”€ Workout Music/
โ”‚   โ”œโ”€โ”€ High Energy Track.mp3
โ”‚   โ””โ”€โ”€ Motivational Song.mp3
โ””โ”€โ”€ Study Focus/
    โ””โ”€โ”€ Ambient Track.mp3

๐Ÿ”ง Advanced Usage

Automation with Cron

Set up automatic syncing with cron:

# Edit crontab
crontab -e

# Add line to sync every 6 hours
0 */6 * * * /path/to/ytmm sync --all

Environment Variables

You can override settings with environment variables:

export YT_MUSIC_MANAGER_CLI_YOUTUBE__AUTH_METHOD="auto_oauth"
export YT_MUSIC_MANAGER_CLI_DOWNLOAD__BASE_PATH="/custom/path"
ytmm sync --all

Custom Download Templates

Customize file naming in settings.toml:

[download]
naming_template = "%(playlist_index)s - %(title)s.%(ext)s"

๐Ÿšจ Troubleshooting

Common Issues

"Authentication required for private playlists"

  • Use bundled OAuth and sign in with Google: ytmm auth mode auto_oauth -y

"Permission denied" errors

  • Check write permissions for download directory
  • On Windows, avoid special characters in paths
  • Run as administrator if needed

"No module named 'yt_dlp'"

  • Ensure dependencies are installed!

Downloads failing

  • Check internet connection
  • Some videos may be region-restricted or unavailable in general to download

Getting Help

  1. Check the logs: tail -f logs/yt_music_manager_cli.log
  2. Run with debug mode: ytmm --debug sync --all
  3. Check configuration: ytmm config
  4. Create an issue with logs and error messages

๐Ÿ“Š Performance

  • Download Speed: Configurable concurrent downloads (1-10 parallel)
  • Storage: Efficient file organization with duplicate detection
  • Memory: Streaming downloads with progress tracking
  • Reliability: Automatic retries and error recovery

๐Ÿ”’ Privacy & Security

  • Local Storage: All music files stored locally on your device
  • Secure OAuth: Tokens are encrypted using Fernet with machine-specific keys
  • No Tracking: No analytics or usage tracking
  • Open Source: Full source code available for review

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿค Contributing & Development

Contributions are welcome! Please read our Contributing Guide for details on contribution and development.

๐Ÿ› Reporting Bugs

When reporting bugs, please include:

  1. Environment Information

    • Python version
    • Operating system
    • YT Music Manager CLI (YTMM CLI) version
  2. Steps to Reproduce

    • Clear, numbered steps
    • Expected vs actual behavior
    • Screenshots if applicable
  3. Log Files

    • Include relevant logs from logs/yt_music_manager_cli.log
    • Use debug mode: ytmm --debug command

๐Ÿชถ Feature Requests

For new features, please:

  1. Check existing issues first
  2. Describe the use case clearly
  3. Explain why it would benefit users
  4. Consider implementation complexity

โญ Support

If you find this project helpful, please consider:

  • โญ Starring the repository
  • ๐Ÿ› Reporting bugs
  • ๐Ÿ’ก Suggesting new features
  • ๐Ÿ”€ Contributing code

๐Ÿ™ Acknowledgments

  • yt-dlp - Excellent YouTube downloading library
  • Rich - Beautiful terminal output and progress bars
  • Click - Powerful command-line interface framework
  • Google - YouTube Data API v3

Made with โค๏ธ by Sukarth, for music lovers who want their playlists always in sync

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yt_music_manager_cli-1.0.1.tar.gz (82.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yt_music_manager_cli-1.0.1-py3-none-any.whl (77.7 kB view details)

Uploaded Python 3

File details

Details for the file yt_music_manager_cli-1.0.1.tar.gz.

File metadata

  • Download URL: yt_music_manager_cli-1.0.1.tar.gz
  • Upload date:
  • Size: 82.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for yt_music_manager_cli-1.0.1.tar.gz
Algorithm Hash digest
SHA256 e3a57e6b4bed20d36a456a02ee26e23ad46c15f8fa053a265a60cd678b49bc90
MD5 ab4c4ad7f3fc4930cf662bfc257ca332
BLAKE2b-256 ea00cadd8cf3a1ae1e5edcb0b4383410b007822ba94597a950ccf8fee3db6f49

See more details on using hashes here.

File details

Details for the file yt_music_manager_cli-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for yt_music_manager_cli-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7e6a9edf749b3a1e3b9b81e10f80937ec0b69db5475f65e149643d38f4860f16
MD5 4c9ccc570ff977a4ebd82a5569585952
BLAKE2b-256 f3adead8d94af54584ed4f8965858b26948f742ea94e321ef4ed96d31767dfae

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page