34e49c0d9f7afbc21f500c41815005c7fe4c1184
yt-dlp HLS Proxy
A simple Flask proxy server that uses yt-dlp to fetch HLS streams and serves them through a web player.
Features
- HLS stream proxying via yt-dlp
- In-memory caching (365 days TTL by default)
- URL validation with allowed domains
- HTML5 video player with hls.js
- Configurable via environment variables
Quick Start
pip install -r requirements.txt
cp .env.example .env
python app.py
Visit http://localhost:5000 and enter a video URL.
Configuration
| Variable | Default | Description |
|---|---|---|
| PORT | 5000 | Server port |
| LOG_LEVEL | INFO | Logging level |
| CACHE_TTL | 31536000 | Cache TTL in seconds (365 days) |
| SOCKET_TIMEOUT | 30 | Socket timeout for requests |
| VALIDATION_ENABLED | true | Enable URL validation |
| ALLOWED_DOMAINS | youtube.com,youtu.be,pornhub.com,xvideos.com | Allowed video domains |
| ALLOW_LOCAL | true | Allow localhost/127.0.0.1 URLs (for testing) |
Routes
/- Home page with video URL input/player?url=VIDEO_URL- Video player page/hls/<query>/index.m3u8- HLS playlist proxy/hls/<query>/<segment>.ts- HLS segment proxy
Running with Gunicorn
gunicorn -w 4 -b 0.0.0.0:5000 app:app
Testing
pytest tests/test_proxy.py -v
License
MIT
Languages
Python
71.1%
HTML
27.6%
Dockerfile
1.3%