iptv-proxy
iptv-proxy copied to clipboard
Losing track of URLs from m3u8s with redirects to other hosts
Hi!
I'm trying to use iptv-proxy with MATT HUISMAN's m3u8s (https://www.matthuisman.nz/).
e.g. with https://i.mjh.nz/nz/raw-tv.m3u8 for the free tv channels from New Zealand.
Situation without proxy
At the source it looks something like this:
https://i.mjh.nz/nz/raw-tv.m3u8
has a list of channels:
[...]
#EXTINF:-1 channel-id="mjh-tvnz-1" tvg-id="mjh-tvnz-1" tvg-logo="https://i.mjh.nz/.images/tvnz-1.png " tvg-chno="1" group-title="Nz" , TVNZ 1
https://i.mjh.nz/tvnz-1.m3u8
[...]
The individual channel e.g.: https://i.mjh.nz/tvnz-1.m3u8
then does a redirect e.g. to: "https://dz1g25geip0uq.cloudfront.net/master.m3u8"
(Hint: The hostname is changing all the time, the url only works in New Zealand)
master.m3u8 then has various relative urls for the different qualities of the stream:
[...]
#EXT-X-STREAM-INF:BANDWIDTH=640996,AVERAGE-BANDWIDTH=581245,RESOLUTION=480x270,FRAME-RATE=25,000,CODECS="avc1.640015,mp4a.40.2"
master_33.m3u8
[...]
master_33.m3u8:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:8
#EXT-X-MEDIA-SEQUENCE:22873182
#EXT-X-KEY:METHOD=AES-128,URI="https://d2k40ydor517br.cloudfront.net/Tvnz1-2019/b3596451-61c5-47de-bded-3965a51969c5"
#EXTINF:4.480,
master_33_22873182.ts?m=1689112883
#EXTINF:4.480,
master_33_22873183.ts?m=1689112883
#EXTINF:4.480,
master_33_22873184.ts?m=1689112883
[...]
Situation with proxy
Let's say this is the URL to my iptv proxy:
https://iptvnz.myserver.nz/iptv.m3u?username=demo&password=test
then it is first correctly rewritten as:
[...]
#EXTINF:-1 channel-id="mjh-tvnz-1" tvg-id="mjh-tvnz-1" tvg-logo="https://i.mjh.nz/.images/tvnz-1.png " tvg-chno="1" group-title="Nz", TVNZ 1
http://iptvnz.myserver.nz/c2a34a52/demo/test/5/tvnz-1.m3u8
[...]
the content of tvnz-1.m3u8 is:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-INDEPENDENT SEGMENTS
#EXT-X-STREAM-INF:BANDWIDTH=640996,AVERAGE-BANDWIDTH=581245,RESOLUTION=480x270,FRAME-RATE=25,000,CODECS="avc1.640015,mp4a.40.2"
master_33.m3u8
[...]
However, if you retrieve master_33.m3u8 from iptvnz.myserver.nz you will end up with a 404 error.
Is there already a solution to this problem?
Possible solution outline
Obviously the IPTV proxy already follows the redirect. But the result is missing any reference to the redirect.
In my opinion, redirects would have to be recognized and then relative urls would have to be eliminated first:
e.g. master_33.m3u8 => https://dz1g25geip0uq.cloudfront.net/master_33.m3u8
In a second step, the new URL would then have to be rewritten. E.g. like ttp://iptvnz.myserver.nz/c2a34a52/demo/test/dz1g25geip0uq.cloudfront.net/master_33.m3u8
Also the #EXT-X-KEY:METHOD=AES-128,URI="https://d2k40ydor517br.cloudfront.net/Tvnz1-2019/b3596451-61c5-47de-bded-3965a51969c5" needs to be rewritten/proxyed.
Have you found a workaround for this?
iptv-proxy works with hls and doesn't work with m3u8 so the url should be https://iptvnz.myserver.nz/iptv.m3u?username=demo&password=test&type=m3u_plus&output=hls
Using hls still isn't working for me. Same issue as the other ticket