Skip to content

Python files to download Youtube Videos, Playlists and Songs

License

Notifications You must be signed in to change notification settings

ArindamTripathi619/youtubePython

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

youtubePython

License: MIT
A comprehensive YouTube video and audio downloader with both command-line and GUI interfaces. Built with Python and tkinter, featuring download progress tracking, error handling, and comprehensive logging for seamless media extraction from YouTube.

πŸš€ Features

πŸŽ₯ Core Features

  • Multiple Download Modes: Single videos, multiple videos, and entire playlists/channels
  • Format Options: Download as MP4 (video) or MP3 (audio) with customizable quality
  • GUI Interface: User-friendly tkinter-based graphical interface with loading animations
  • Command Line Tools: Lightweight CLI versions for automation and scripting
  • Song Search: Search and download songs by name using YouTube search integration
  • Batch Processing: Download multiple videos simultaneously with queue management

πŸ”§ Advanced Features

  • Progress Tracking: Real-time download progress with animated loading indicators
  • Error Handling: Robust error handling with user-friendly error messages
  • Rate Limit Management: Built-in YouTube rate limiting detection and handling
  • Comprehensive Logging: Detailed logging system for debugging and monitoring
  • Cross-Platform: Works on Windows, Linux, and macOS
  • Thread Safety: Non-blocking downloads with background processing

πŸ› οΈ Technologies Used

Component Technology
GUI Framework tkinter (Python built-in)
YouTube Integration yt-dlp 2023.x, youtube-search-python
Media Processing FFmpeg
Logging Python logging module
Threading Python threading for non-blocking operations
Cross-Platform Python 3.8+ compatible

πŸ“‚ Project Structure

youtubePython/
β”œβ”€β”€ link_gui.py                # GUI version with tkinter interface
β”œβ”€β”€ link.py                    # Command-line video/playlist downloader
β”œβ”€β”€ song.py                    # Song search and download tool
β”œβ”€β”€ view_logs.py              # Log viewer utility
β”œβ”€β”€ install.sh                # Linux/macOS installation script
β”œβ”€β”€ install.ps1               # Windows PowerShell installation script
β”œβ”€β”€ logs/                     # Application logs directory
β”‚   └── youtube_downloader_YYYYMMDD.log
β”œβ”€β”€ .venv/                    # Python virtual environment
β”œβ”€β”€ .gitignore                # Git ignore rules
β”œβ”€β”€ requirements.txt          # Python dependencies
β”œβ”€β”€ README.md                 # Project documentation
β”œβ”€β”€ LOGGING.md               # Detailed logging guide
β”œβ”€β”€ TODO.md                  # Development roadmap
└── LICENSE                  # MIT License

✨ How It Works

  1. URL Processing: Accepts YouTube video, playlist, or channel URLs
  2. Format Selection: User chooses between MP4 (video) or MP3 (audio) output
  3. Quality Optimization: Automatically selects best available quality for chosen format
  4. Download Processing: Uses yt-dlp for robust video extraction and FFmpeg for conversion
  5. Progress Feedback: Real-time progress updates with loading animations
  6. Error Recovery: Automatic retry mechanisms and user-friendly error reporting
  7. File Organization: Organized output with playlist folders and proper naming

βš™οΈ Installation & Setup

Prerequisites

  • Python 3.8 or higher
  • FFmpeg (for audio conversion)
  • Git

Quick Start (Linux/macOS)

  1. Clone the repository:

    git clone https://github.com/ArindamTripathi619/youtubePython.git
    cd youtubePython
  2. Run automated installation:

    chmod +x install.sh
    ./install.sh

    Or manual setup:

  3. Set up virtual environment:

    python3 -m venv .venv
    source .venv/bin/activate  # On Windows: .venv\Scripts\activate
  4. Install dependencies:

    pip install yt-dlp youtube-search-python
  5. Install FFmpeg:

    # Ubuntu/Debian
    sudo apt install ffmpeg
    
    # macOS (with Homebrew)
    brew install ffmpeg
    
    # Arch Linux
    sudo pacman -S ffmpeg
  6. Run the application:

    # GUI Version
    python link_gui.py
    
    # Command Line Version
    python link.py
    
    # Song Search Tool
    python song.py

Windows Installation

  1. Install Python 3.8+:

    • Download from python.org
    • Make sure to check "Add Python to PATH" during installation
  2. Clone the repository:

    git clone https://github.com/ArindamTripathi619/youtubePython.git
    cd youtubePython
  3. Run automated installation:

    PowerShell -ExecutionPolicy Bypass -File install.ps1

    Or manual setup:

  4. Install FFmpeg:

    winget install ffmpeg

    Or follow the official FFmpeg Windows guide

  5. Create virtual environment:

    python -m venv .venv
    .venv\Scripts\activate
  6. Install dependencies:

    pip install -r requirements.txt
  7. Run the application:

    # GUI Version
    python link_gui.py
    
    # Command Line Version
    python link.py
    
    # Song Search Tool
    python song.py

🎯 Usage Examples

GUI Application

python link_gui.py
  • Enter YouTube URL in the text field
  • Select download type (Single Video or Playlist/Channel)
  • Choose format (MP3 or MP4)
  • Click "Download" and monitor progress

Command Line Interface

# Single video download
python link.py
# Follow prompts to enter URL and select format

# Song search and download
python song.py
# Enter song names and select from search results

Log Monitoring

# View recent activity
python view_logs.py

# Search for errors
python view_logs.py search ERROR

# View specific number of lines
python view_logs.py 100

πŸ” Logging & Debugging

Comprehensive Logging System

  • Daily log rotation: logs/youtube_downloader_YYYYMMDD.log
  • Multiple log levels: INFO, WARNING, ERROR with detailed context
  • Thread-safe logging: Safe for concurrent download operations
  • UTF-8 encoding: Supports international characters in video titles

Log Viewer Utility

# Basic usage
python view_logs.py                    # Last 50 lines
python view_logs.py 200                # Last 200 lines
python view_logs.py list               # List all log files
python view_logs.py search "429"       # Search for rate limiting
python view_logs.py search "ERROR"     # Find all errors

Common Error Patterns

  • Rate Limiting (429): YouTube temporary blocks - wait and retry
  • Bot Detection: May require cookies or VPN
  • Video Unavailable: Private, deleted, or geo-restricted content
  • Network Issues: Check internet connection and firewall settings

πŸ“š Configuration Options

Download Quality Settings

# In link_gui.py or link.py - modify ydl_opts
ydl_opts = {
    'format': 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4',  # Best quality MP4
    'format': 'bestaudio/best',  # Best quality audio for MP3 conversion
    'postprocessors': [{
        'key': 'FFmpegExtractAudio',
        'preferredcodec': 'mp3',
        'preferredquality': '192'  # Adjust quality (128, 192, 320)
    }]
}

Output Template Customization

'outtmpl': '%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s'  # Playlist organization
'outtmpl': '%(uploader)s - %(title)s.%(ext)s'                     # Include uploader name

πŸ§ͺ Testing

Manual Testing Checklist

  • Single video download (MP4 and MP3)
  • Playlist download with folder organization
  • Search functionality for songs
  • Error handling for invalid URLs
  • GUI responsiveness during downloads
  • Log file creation and content
  • Cross-platform compatibility

Automated Testing

# Test core functionality
python -m pytest tests/  # If test suite available

# Test imports and dependencies
python -c "import yt_dlp, tkinter; print('All dependencies working')"

πŸ”§ Troubleshooting

Common Issues

"Module not found" errors:

# Ensure virtual environment is activated
source .venv/bin/activate  # Linux/macOS
.venv\Scripts\activate     # Windows

# Reinstall dependencies
pip install --upgrade yt-dlp youtube-search-python

FFmpeg not found:

# Verify FFmpeg installation
ffmpeg -version

# Add FFmpeg to PATH (Windows)
# Add C:\ffmpeg\bin to system PATH environment variable

YouTube rate limiting (429 errors):

  • Wait 10-15 minutes before retrying
  • Use VPN if consistently blocked
  • Consider using cookies (see yt-dlp documentation)

GUI not starting:

# Check tkinter availability
python -c "import tkinter; print('tkinter available')"

# On Linux, install tkinter
sudo apt install python3-tk  # Ubuntu/Debian
sudo pacman -S tk             # Arch Linux

πŸ§‘β€πŸ’» Contributing

Contributions are welcome! Please follow these guidelines:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Development Guidelines

  • Follow PEP 8 Python style guidelines
  • Add logging for new features
  • Test on multiple platforms when possible
  • Update documentation for new features
  • Ensure error handling is comprehensive

πŸ“ License

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


πŸ“§ Contact

Created by Arindam Tripathi
For any inquiries, bug reports, or feature requests, feel free to reach out!

Social Links

Instagram Facebook LinkedIn YouTube


πŸ™ Acknowledgments


⚠️ Disclaimer

This tool is for educational and personal use only. Please respect YouTube's Terms of Service and copyright laws. Only download content you have permission to download or content that is in the public domain. The developers are not responsible for any misuse of this software.

Thanks for using youtubePython! 😊
Hope You Like It! 😊

BYEEEEE πŸ‘‹

About

Python files to download Youtube Videos, Playlists and Songs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published