Skip to main content

A Python library for downloading YouTube Mix playlists

Project description

YouTube Downloader

A Python library for downloading videos from YouTube and YouTube Mix playlists.

View on GitHub

Downloads Downloads Downloads

Installation

pip install youtube-mix-dl==0.1.4

Dependencies

pip install selenium>=4.0.0 webdriver-manager>=3.8.0 yt-dlp>=2023.0.0

System Requirements

FFmpeg Installation

  • Windows: winget install FFmpeg

  • Linux: sudo apt update && sudo apt install ffmpeg

  • macOS: brew install ffmpeg

  • Google Chrome/Chromium browser

  • ChromeDriver (auto-installed by webdriver-manager)

Usage Examples

Test Script (test.py)

from youtube_mix_dl import YouTubeDownloader

def progress_callback(message):
    print(message)

# Initialize downloader
downloader = YouTubeDownloader(
    output_path="downloads",
    progress_callback=progress_callback
)

# 1. Download single video
video_url = "https://www.youtube.com/watch?v=Mude7cCSs9s"
print("\nDownloading single video...")
success = downloader.download_video(video_url)
print(f"Single video download {'successful' if success else 'failed'}")

# 2. Download audio only
print("\nDownloading audio only...")
audio_options = {
    'format': 'bestaudio[ext=m4a]',
    'postprocessors': [{'key': 'FFmpegExtractAudio'}]
}
success = downloader.download_video(video_url, audio_options)
print(f"Audio download {'successful' if success else 'failed'}")

# 3. Download from music mix playlist
mix_url = "https://www.youtube.com/watch?v=Mude7cCSs9s&list=RDMude7cCSs9s&start_radio=1"
print("\nDownloading from music mix playlist...")
mix_downloads = downloader.download_mix(mix_url, num_videos=3)
print(f"Downloaded {mix_downloads} videos from mix")

# 4. Download from normal playlist
playlist_url = "https://www.youtube.com/playlist?list=PLPTV0NXA_ZSgsLAr8YCgCwhPIJNNtexWu"
print("\nDownloading from normal playlist...")
playlist_downloads = downloader.download_playlist(playlist_url, num_videos=3)
print(f"Downloaded {playlist_downloads} videos from playlist")

# 5. Get video information
print("\nGetting video information...")
info = downloader.get_video_info(video_url)
if info:
    print(f"Video title: {info.get('title')}")
    print(f"Duration: {info.get('duration')} seconds")
    print(f"View count: {info.get('view_count')}")

Run the test script:

python test.py

Individual Features

1. Single Video Download

from youtube_mix_dl import YouTubeDownloader

downloader = YouTubeDownloader(output_path="downloads")
success = downloader.download_video("https://www.youtube.com/watch?v=Mude7cCSs9s")

2. Audio Only Download

options = {
    'format': 'bestaudio[ext=m4a]',
    'postprocessors': [{'key': 'FFmpegExtractAudio'}]
}
success = downloader.download_video("https://www.youtube.com/watch?v=Mude7cCSs9s", options)

3. Music Mix Playlist Download

downloader = YouTubeDownloader(
    output_path="downloads",
    progress_callback=lambda msg: print(msg)
)
successful_downloads = downloader.download_mix(
    "https://www.youtube.com/watch?v=Mude7cCSs9s&list=RDMude7cCSs9s&start_radio=1",
    num_videos=5
)

4. Normal Playlist Download

successful_downloads = downloader.download_playlist(
    "https://www.youtube.com/playlist?list=PLPTV0NXA_ZSgsLAr8YCgCwhPIJNNtexWu",
    num_videos=5
)

Features

  • Single video and playlist downloads (music mix and normal playlists)
  • Audio-only downloads
  • Progress tracking with callbacks
  • High-quality video/audio
  • Automatic stream merging
  • Error handling
  • Video information retrieval

Troubleshooting

Common Issues

  1. No Audio

    • Verify FFmpeg: ffmpeg -version
    • Check PATH settings
  2. ChromeDriver Issues

    • Update Chrome
    • Let webdriver-manager handle installation
  3. Permission Issues

    • Check output directory permissions
    • Run with appropriate privileges

Development

# Setup
git clone https://github.com/benny-png/YOUR_YOUTUBE_MUSIC_MIX_DOWNLOADER.git
cd YOUR_YOUTUBE_MUSIC_MIX_DOWNLOADER
python -m venv venv
source venv/bin/activate  # Linux/macOS
venv\Scripts\activate     # Windows

# Install dev dependencies
pip install build twine pytest black isort mypy
pip install -e .

License

MIT License

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

youtube_mix_dl-0.1.4.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

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

youtube_mix_dl-0.1.4-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file youtube_mix_dl-0.1.4.tar.gz.

File metadata

  • Download URL: youtube_mix_dl-0.1.4.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for youtube_mix_dl-0.1.4.tar.gz
Algorithm Hash digest
SHA256 7bc01e350acf95466982cf665c45c93daafefd348efae15cf6bddbbff97a0cd9
MD5 e968500873850eeb9ceed2e055bf1d88
BLAKE2b-256 e00de08cc54a5e573ea072172bd792fdd2a0a89ae40650725ac0724d05e3be85

See more details on using hashes here.

File details

Details for the file youtube_mix_dl-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: youtube_mix_dl-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for youtube_mix_dl-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a66802c4ef158085b038a5653ffbea85c9466aca7a87d79dafa80d556c13e41a
MD5 d88165f96170951e8db4845b165955e4
BLAKE2b-256 f8a253ddc876700c38c7c1e7bfacaa296753f80be0669e86d91129fa5bc196c6

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