I have an m3u8 file which goes something like this:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:15084
#EXT-X-TARGETDURATION:4
#EXTINF:4.004,
radio002live-15084.ts
#EXTINF:4.004,
radio002live-15085.ts
(and so on)
What I ideally want to happen is to have all of those file names prefixed with a URL, but only if they don’t start with HTTP(S) already. Then URL encode those, add another thing in front of them, and then return that so ideally the file looks like this:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:15084
#EXT-X-TARGETDURATION:4
#EXTINF:4.004,
proxy.php?http%3A%2F%2Fsomeurl.tld%2Fpath%2Fradio002live-15084.ts
#EXTINF:4.004,
proxy.php?http%3A%2F%2Fsomeurl.tld%2Fpath%2Fradio002live-15085.ts
(and so on)
So far, I’ve tried turning the thing into an array (one line = one key) but I realized this might not cover every m3u8 I need to parse (what if one has the URL on the same line?) and I can’t seem to get past detecting what doesn’t start with what regardless.
Ideally, this should work in PHP 5-ish.