A Node.js server that extracts the best possible HLS (m3u8) streaming URLs from YouTube Live streams using yt-dlp. Perfect for IPTV applications, media players, and streaming integrations.
- 🎥 Extract HLS streaming URLs from YouTube Live channels
- 📺 Support for quality selection (target height and minimum height)
- 🔄 Multiple output formats (direct URL, M3U playlist, redirect)
- 🎯 Smart quality selection with H.264 preference for TV compatibility
- 🐳 Docker support with health checks
- 🌐 CORS enabled for web applications
- ⚡ Fast and lightweight Express.js server
# Using pre-built image (recommended)
docker pull su14iman/yt-hls-server:latest
docker run -p 8000:8000 -e TZ=Europe/Berlin su14iman/yt-hls-server:latest
# Or clone and use docker-compose
git clone https://github.com/su14iman/yt-hls-server.git
cd yt-hls-server
docker-compose up -d
# Or build and run manually
docker build -t yt-hls-server .
docker run -p 8000:8000 yt-hls-server# Install dependencies
npm install
# Make sure yt-dlp is installed
pip3 install -U yt-dlp
# Start the server
node index.jsThe server will start on http://localhost:8000
GET /hls_url?url=<youtube_url>&h=<target_height>&min=<min_height>
Parameters:
url(required): YouTube Live stream URLh(optional): Target height (e.g., 720, 1080)min(optional): Minimum acceptable height
Example:
curl "http://localhost:8000/hls_url?url=https://www.youtube.com/@AlekhbariahSY/live&h=720"GET /playlist.m3u?url=<youtube_url>&name=<channel_name>&logo=<logo_url>&group=<group_name>&tvg_id=<id>&h=<height>&min=<min_height>
Parameters:
url(required): YouTube Live stream URLname(optional): Channel display name (default: "YouTube Live")logo(optional): Channel logo URLgroup(optional): IPTV group name (default: "YouTube")tvg_id(optional): TVG ID for EPGh(optional): Target heightmin(optional): Minimum height
Example:
curl "http://localhost:8000/playlist.m3u?url=https://www.youtube.com/@AlekhbariahSY/live&name=Al%20Ekhbariah&h=720"GET /redirect.m3u8?url=<youtube_url>&h=<height>&min=<min_height>
Returns a 302 redirect directly to the HLS stream URL.
Example:
curl -L "http://localhost:8000/redirect.m3u8?url=https://www.youtube.com/@AlekhbariahSY/live&h=1080"GET /
Returns "OK" for health monitoring.
The server uses intelligent quality selection:
- Target Height (
h): Prefers streams at or below the target resolution - Minimum Height (
min): Filters out streams below this resolution - Codec Preference: Prioritizes H.264 streams for better TV compatibility
- Bitrate: Higher bitrate streams are preferred when resolution is equal
h=720: Get best stream ≤ 720pmin=480: Only streams ≥ 480ph=1080&min=720: Prefer 1080p, but accept 720p+ if 1080p unavailable
#EXTM3U
#EXTINF:-1 tvg-id="news1" tvg-logo="https://example.com/logo.png" group-title="News",News Channel
http://your-server:8000/redirect.m3u8?url=https://www.youtube.com/@newschannel/live&h=720# VLC
vlc "http://localhost:8000/redirect.m3u8?url=https://www.youtube.com/@channel/live"
# FFmpeg
ffmpeg -i "http://localhost:8000/hls_url?url=https://www.youtube.com/@channel/live" output.mp4const response = await fetch('/hls_url?url=https://www.youtube.com/@channel/live&h=720');
const hlsUrl = await response.text();
// Use with HLS.js or similar playerPORT: Server port (default: 8000)TZ: Timezone for Docker container (default: Europe/Berlin)
The included docker-compose.yml provides:
- Health checks every 30 seconds
- Automatic restart unless stopped
- Log rotation (10MB max, 3 files)
- Timezone configuration
- Node.js 18+
- yt-dlp (automatically installed in Docker)
- Python 3 (for yt-dlp)
- FFmpeg (for some stream processing)