Skip to main content

Download music from YouTube with proper metadata and album art, featuring parallel processing

Project description

YouTube Music Extractor

A Python tool to download music from YouTube/YouTube Music with proper metadata and album art, featuring parallel processing for albums and playlists.

Features

  • 🎵 Download music from YouTube or YouTube Music URLs
  • 📀 Support for both single tracks and full albums/playlists
  • 🚀 Parallel processing for faster album downloads
  • 🎧 Convert to high-quality M4A format with 256k bitrate
  • 🏷️ Extract and embed metadata (title, artist, album, genre, track numbers)
  • 🖼️ Process album artwork to perfect 1:1 aspect ratio (500x500px)
  • 📁 Organized folder structure for albums and single tracks
  • 🧹 Automatic cleanup of temporary files
  • 🎮 Optimize for VLC and other media players

Requirements

  • Python 3.7+
  • Dependencies listed in requirements.txt

Installation

Option 1: Clone and Install

git clone https://github.com/yourusername/youtube-music-extractor.git
cd youtube-music-extractor

Option 2: Install as Package

pip install -e .

Set up Virtual Environment (Recommended)

python -m venv .venv
# Windows
.venv\Scripts\activate
# macOS/Linux
source .venv/bin/activate

Install Dependencies

pip install -r requirements.txt

Usage

Basic Usage

python main.py

As Installed Package

yt-music-extractor

The script will prompt you for a YouTube/YouTube Music URL and then:

  1. Analyze the URL to determine if it's a single track or album/playlist
  2. Download the best audio quality using yt-dlp
  3. Convert to M4A format with AAC codec (256k bitrate)
  4. Process cover art (crop to square, resize to 500x500px)
  5. Embed metadata and cover art into audio files
  6. Organize files into appropriate folders
  7. Clean up temporary files

Examples

Single Track

Enter the YouTube URL: https://music.youtube.com/watch?v=dQw4w9WgXcQ

Creates: Single - Song Title/Song Title.m4a

Album/Playlist

Enter the YouTube URL: https://music.youtube.com/playlist?list=OLAK5uy_xyz

Creates: Album Title/Track 1.m4a, Album Title/Track 2.m4a, etc.

Features in Detail

Parallel Processing

  • Albums and playlists are processed using ThreadPoolExecutor
  • Up to 4 concurrent downloads (configurable in config.py)
  • Real-time progress tracking

Metadata Handling

  • Title: Song title from YouTube
  • Artist: Channel name or extracted artist
  • Album: Playlist/album title or song title for singles
  • Genre: "YouTube Music" (default)
  • Track Numbers: Automatic numbering for album tracks
  • Cover Art: Embedded as MP4Cover format

File Organization

Project Root/
├── Album Title/
│   ├── Track 1.m4a
│   ├── Track 2.m4a
│   ├── cover.jpg
│   └── Track 1.jpg (external cover for VLC)
└── Single - Song Title/
    ├── Song Title.m4a
    └── cover.jpg

Image Processing

  • Automatically crops images to 1:1 aspect ratio
  • Resizes to 500x500px for optimal compatibility
  • Converts to JPEG format (95% quality)
  • Creates both embedded and external cover art

Configuration

Modify settings in config.py:

# Audio quality
AUDIO_BITRATE = "256k"

# Image processing
IMAGE_TARGET_SIZE = 500
IMAGE_QUALITY = 95

# Threading
MAX_WORKERS = 4

Troubleshooting

Common Issues

  1. Missing audio files: Check if the URL is accessible and not geo-blocked
  2. Conversion errors: Ensure FFmpeg is installed and accessible
  3. Metadata errors: Some files may not support M4A metadata format

Debug Mode

Add verbose logging by modifying the yt-dlp options in the script.

Dependencies

  • yt-dlp: YouTube download functionality
  • moviepy: Audio conversion and processing
  • mutagen: Audio metadata handling
  • Pillow: Image processing and manipulation
  • requests: HTTP requests for thumbnail downloads

License

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

Contributing

Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.

Acknowledgments

  • yt-dlp for robust YouTube download functionality
  • MoviePy for audio conversion capabilities
  • Mutagen for comprehensive metadata handling
  • Pillow for advanced image processing

Changelog

v1.0.1 (Latest)

  • 🚀 Initial PyPI release
  • 📦 Fixed packaging issues
  • All features from v1.0.0 included

v1.0.0

  • 🚀 Added parallel processing for albums and playlists
  • 📁 Improved file organization with dedicated folders
  • 🖼️ Enhanced image processing with 1:1 aspect ratio cropping
  • 🧹 Automatic cleanup of temporary files
  • 📊 Better error handling and progress tracking
  • 🎮 VLC-optimized output with external cover art files

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_extractor-1.0.1.tar.gz (13.1 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_extractor-1.0.1-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: yt_music_extractor-1.0.1.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for yt_music_extractor-1.0.1.tar.gz
Algorithm Hash digest
SHA256 c28c6dd91e060f7a3289fb9541b6cbf01ca650b613a782f0ebb0e8b30d4ed76f
MD5 e9df54923949e87de6950770451ee9a8
BLAKE2b-256 f1130e0b54de15f0ceb83d6c111534e2a3bb455b4ea8beefd567180c29bc2adb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for yt_music_extractor-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 23e22672a51c8e917b07abea0f9734881c45af5f0dacd75bec2acd3eb736494a
MD5 b48748040442c40c0c4fcbea951094d8
BLAKE2b-256 48589fac1e88cc425b6ff4551a5b13be6ac3847f995fdb99d0032d7c4631d104

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