# Proxy Configuration for YouTube Predownloader The YouTube Predownloader now supports SOCKS5, HTTP, and HTTPS proxies for all download operations, with special support for PIA (Private Internet Access) SOCKS5 proxies. ## Supported Proxy Types 1. **PIA SOCKS5 Proxy** (Integrated configuration) 2. **SOCKS5 Proxy** (General) 3. **HTTP Proxy** 4. **HTTPS Proxy** ## Configuration Methods ### Method 1: PIA Configuration File (Recommended for PIA users) 1. Edit `proxy_config.py` and set your PIA credentials: ```python # PIA SOCKS5 Proxy Server Details PROXY_ADDRESS = "proxy-nl.privateinternetaccess.com" # Choose your server PROXY_PORT = 1080 PROXY_USER = "your_pia_username" # Your actual PIA username PROXY_PASS = "your_pia_password" # Your actual PIA password ``` 2. Available PIA servers: - Netherlands: `proxy-nl.privateinternetaccess.com` - US East: `proxy-us-east.privateinternetaccess.com` - US West: `proxy-us-west.privateinternetaccess.com` - UK: `proxy-uk.privateinternetaccess.com` - Germany: `proxy-de.privateinternetaccess.com` - Canada: `proxy-ca.privateinternetaccess.com` - Australia: `proxy-au.privateinternetaccess.com` 3. Test your configuration: ```bash python3 proxy_config.py python3 test_proxy.py ``` ### Method 2: Environment Variables Set environment variables before running the script: ```bash # SOCKS5 Proxy (highest priority) export SOCKS5_PROXY="socks5://username:password@proxy.example.com:1080" # HTTP Proxy (medium priority) export HTTP_PROXY="http://proxy.example.com:8080" # HTTPS Proxy (lowest priority) export HTTPS_PROXY="https://proxy.example.com:8080" # Then run the script python3 main.py ``` ### Method 3: Direct Code Configuration Edit the proxy configuration section in `main.py`: ```python # Override all other configurations HTTP_PROXY = "http://proxy.example.com:8080" HTTPS_PROXY = "https://proxy.example.com:8080" SOCKS5_PROXY = "socks5://127.0.0.1:1080" ``` ## Priority Order The script uses proxies in this priority order: 1. **PIA Configuration** (`proxy_config.py` if configured) 2. **SOCKS5_PROXY** (environment variable) 3. **HTTP_PROXY** (environment variable) 4. **HTTPS_PROXY** (environment variable) 5. **Direct connection** (no proxy) ## Examples ### Using PIA SOCKS5 Proxy 1. Edit `proxy_config.py`: ```python PROXY_ADDRESS = "proxy-us-east.privateinternetaccess.com" PROXY_USER = "p1234567" PROXY_PASS = "your_password" ``` 2. Run the downloader: ```bash python3 main.py ``` ### Using Tor SOCKS5 Proxy ```bash export SOCKS5_PROXY="socks5://127.0.0.1:9050" python3 main.py ``` ### Using SSH SOCKS5 Tunnel ```bash # Create SSH SOCKS5 tunnel ssh -D 1080 -C -N user@your-server.com & # Configure and run export SOCKS5_PROXY="socks5://127.0.0.1:1080" python3 main.py ``` ### Using HTTP Proxy with Authentication ```bash export HTTP_PROXY="http://username:password@proxy.example.com:8080" python3 main.py ``` ## Testing Proxy Configuration ### Test PIA Configuration ```bash # Test PIA proxy settings python3 proxy_config.py # Comprehensive proxy test python3 test_proxy.py ``` The script will log the active proxy configuration on startup: ``` 2025-08-31 10:30:15 - INFO - PIA SOCKS5 Proxy: proxy-nl.privateinternetaccess.com:1080 (user: p1234567) ``` During downloads, you'll see: ``` 2025-08-31 10:30:30 - INFO - 🌐 Using PIA SOCKS5 proxy: proxy-nl.privateinternetaccess.com:1080 ``` ## Troubleshooting ### Common Issues 1. **Proxy not working**: Check if the proxy server is running and accessible 2. **Authentication errors**: Ensure username/password are correctly encoded in the URL 3. **Slow downloads**: SOCKS5 proxies may add latency depending on the route ### Testing Proxy Connectivity Test your proxy with yt-dlp directly: ```bash # Test PIA proxy (replace with your credentials) yt-dlp --proxy socks5://username:password@proxy-nl.privateinternetaccess.com:1080 --simulate "https://www.youtube.com/watch?v=dQw4w9WgXcQ" # Test SOCKS5 proxy yt-dlp --proxy socks5://127.0.0.1:1080 --simulate "https://www.youtube.com/watch?v=dQw4w9WgXcQ" # Test HTTP proxy yt-dlp --proxy http://proxy.example.com:8080 --simulate "https://www.youtube.com/watch?v=dQw4w9WgXcQ" ``` ## Disabling Proxy To disable proxy usage: ```bash # Remove environment variables unset SOCKS5_PROXY unset HTTP_PROXY unset HTTPS_PROXY # Disable PIA configuration in proxy_config.py python3 main.py ``` Or rename/delete the proxy configuration file: ```bash mv proxy_config.py proxy_config.py.disabled python3 main.py ``` ## Security Notes - Always use HTTPS URLs when possible - Be cautious with proxy authentication credentials in environment variables - Consider using encrypted proxy protocols like SOCKS5 over SSH tunnels - Test proxy configuration before running long download sessions