Lightweight HLS restream toolkit for self-hosted media servers (Jellyfin, Emby, Plex).
Many free IPTV/HLS sources require specific HTTP headers (User-Agent, Referer) that media servers don't send. This proxy sits between your media server and the upstream, injecting the required headers and rewriting m3u8 playlists so all segment requests also go through the proxy.
Components
File Purpose hls-proxy.py HTTP reverse proxy that adds headers to upstream HLS requests refresh-m3u.sh Scrapes source pages, extracts m3u8 URLs, writes M3U playlist detect-headers.sh Auto-detects which HTTP headers a stream requires channels.conf Your channel list (slug, name, logo, group, source URL)
How it works
┌──────────┐ ┌───────────┐ ┌──────────────┐ ┌──────────┐ │ Jellyfin │────▶│ hls-proxy │────▶│ upstream HLS │────▶│ segments │ │ │ │ :8089 │ │ server │ │ (.ts) │ └──────────┘ └───────────┘ └──────────────┘ └──────────┘ adds headers: • User-Agent • Referer
refresh-m3u.sh generates an M3U file with stable /channel/<slug> URLs pointing to the proxy When Jellyfin requests /channel/sporttv1 , the proxy scrapes a fresh m3u8 URL on the fly (cached for 1 hour) The proxy injects the required headers and rewrites the playlist so .ts segments also go through it The proxy auto-learns the correct Referer for each upstream host — no manual configuration needed
No more expired tokens — the M3U URLs never change, the proxy handles token refresh transparently.
Requirements
Python 3.8+ (stdlib only, no pip packages)
... continue reading