Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ashutosh-aanand/ytd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

12 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

YouTube Downloader (ytd)

A powerful, feature-rich YouTube downloader built in Python with support for individual videos, playlists, and advanced audio merging capabilities.

๐Ÿš€ Features

โœจ Core Functionality

  • Individual Video Downloads: Download single YouTube videos with format selection
  • Playlist Support: Download entire playlists or specific video ranges
  • Audio Merging: Automatically merge separate video and audio streams for optimal quality
  • Format Selection: Choose from available video/audio formats with quality indicators
  • Smart Quality Detection: Prioritizes formats with both video and audio

๐ŸŽฏ Advanced Features

  • Quality Control: Select single format for entire playlist downloads
  • Clean Naming: Automatic filename sanitization and numbered playlist organization
  • Progress Tracking: Real-time download progress with speed and ETA
  • Error Handling: Robust error handling with graceful fallbacks
  • Cross-Platform: Works on Windows, macOS, and Linux

๐Ÿ“ Organization

  • Single Folder Structure: All playlist videos stored in organized parent folders
  • Numbered Naming: Videos named as "1. Title", "2. Title", etc.
  • Clean Titles: Removes quotes, extra spaces, and replaces problematic characters

๐Ÿ› ๏ธ Installation

Prerequisites

  • Python 3.7 or higher
  • pip (Python package installer)

Install Dependencies

pip install -r requirements.txt

Required Packages

  • yt-dlp: YouTube video extraction and downloading
  • click: Command-line interface framework
  • tqdm: Progress bars (optional)
  • colorama: Cross-platform colored output (optional)

๐Ÿ“– Usage

Basic Commands

Download a Single Video

python -m ytd "https://www.youtube.com/watch?v=VIDEO_ID"

Download with Specific Format

python -m ytd "https://www.youtube.com/watch?v=VIDEO_ID" --format 136

Download Audio Only

python -m ytd "https://www.youtube.com/watch?v=VIDEO_ID" --audio-only

Download Video Only

python -m ytd "https://www.youtube.com/watch?v=VIDEO_ID" --video-only

List Available Formats

python -m ytd "https://www.youtube.com/watch?v=VIDEO_ID" --list-formats

Playlist Downloads

Download Entire Playlist

python -m ytd "https://www.youtube.com/playlist?list=PLAYLIST_ID"

Force Playlist Mode

python -m ytd "https://www.youtube.com/playlist?list=PLAYLIST_ID" --playlist

List Playlist Videos

python -m ytd "https://www.youtube.com/playlist?list=PLAYLIST_ID" --list-formats

Advanced Options

Custom Output Directory

python -m ytd "URL" --output "custom_folder"

Quiet Mode

python -m ytd "URL" --quiet

Configuration File

python -m ytd "URL" --config "config.json"

๐ŸŽฎ Interactive Features

Format Selection

When downloading, the tool presents an interactive menu:

Available Formats for: Video Title
============================================================

Video Formats:
[1] 720p mp4 - 15.2 MB [AUDIO]
[2] 1080p mp4 - 45.8 MB [NO AUDIO]
[3] 480p mp4 - 8.1 MB [AUDIO]

Audio Formats:
[4] Audio Only (mp3) - 3.2 MB

[5] Download All Formats
[6] Show More Info
[0] Cancel

Playlist Options

For playlists, choose from:

Playlist Download Options:
============================================================
[1] Download entire playlist
[2] Download specific video range
[3] Download specific video
[4] Show detailed video list
[0] Cancel

๐Ÿ“ Output Structure

Single Video Downloads

downloads/
โ””โ”€โ”€ Video_Title_136.mp4

Playlist Downloads

downloads/
โ””โ”€โ”€ Playlist_Title/
    โ”œโ”€โ”€ 1. First Video Title.mp4
    โ”œโ”€โ”€ 2. Second Video Title.mp4
    โ”œโ”€โ”€ 3. Third Video Title.mp4
    โ””โ”€โ”€ ...

โš™๏ธ Configuration

Default Settings

  • Output Directory: downloads/
  • Format Priority: Combined video+audio streams first
  • File Extension: MP4 for video, original for audio
  • Progress Display: Enabled with speed and ETA

Custom Configuration

Create a config.json file:

{
    "output_dir": "my_downloads",
    "default_format": "136",
    "quiet_mode": false
}

๐Ÿ”ง Technical Details

Architecture

  • Modular Design: Separate modules for core, playlist, and CLI functionality
  • Error Handling: Comprehensive error handling with user-friendly messages
  • Logging: Detailed logging for debugging and monitoring
  • Memory Efficient: Streams data without loading entire files into memory

Supported Formats

  • Video: MP4, WebM, AVI, MOV
  • Audio: MP3, M4A, AAC, OGG
  • Quality: Up to 4K resolution (depending on source)
  • Codecs: H.264, VP9, AAC, Opus

๐Ÿšจ Troubleshooting

Common Issues

"Video unavailable" Error

  • Video may be private, deleted, or region-restricted
  • Check if the URL is accessible in your browser

"Sign in to confirm your age" Error

  • Some videos require age verification
  • Use browser cookies or try different videos

Format Selection Issues

  • Use --list-formats to see available options
  • Some formats may not be available for all videos

Download Failures

  • Check internet connection
  • Verify sufficient disk space
  • Try different format IDs

Debug Mode

Enable verbose logging:

python -m ytd "URL" --verbose

๐Ÿค Contributing

Development Setup

  1. Clone the repository
  2. Install development dependencies
  3. Run tests: python -m pytest
  4. Follow PEP 8 style guidelines

Project Structure

youtube-downloader/
โ”œโ”€โ”€ ytd/
โ”‚   โ”œโ”€โ”€ __init__.py      # Package initialization
โ”‚   โ”œโ”€โ”€ core.py          # Core download functionality
โ”‚   โ”œโ”€โ”€ playlist.py      # Playlist handling
โ”‚   โ”œโ”€โ”€ __main__.py      # CLI interface
โ”‚   โ””โ”€โ”€ config.py        # Configuration management
โ”œโ”€โ”€ dev-docs/            # Development documentation
โ”œโ”€โ”€ downloads/           # Default download directory
โ”œโ”€โ”€ requirements.txt     # Dependencies
โ””โ”€โ”€ README.md           # This file

๐Ÿ“„ License

This project is open source and available under the MIT License.

๐Ÿ™ Acknowledgments

  • yt-dlp: Core YouTube extraction functionality
  • Click: Command-line interface framework
  • Python Community: For excellent libraries and tools

๐Ÿ“ž Support

For issues, questions, or contributions:

  • Create an issue on GitHub
  • Check the troubleshooting section above
  • Review the development documentation

Happy Downloading! ๐ŸŽ‰

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages