Closed Connum closed 4 years ago
Indeed, currently all values are passed directly from the M3U8 files. I was using this program on files with absolute paths, so I didn't notice, sorry about that.
Using Node's URL class should be more than enough to fix the issue, as long as a proper "base" URL is provided. It should handle protocol detection and everything properly.
I just pushed a fix (b3c89c16d72b5632d13a092b02d1a47de3dd91ad), and I'll add more tests and make a new release (1.1.0) this week-end. 👍
Thanks for the quick reaction, I'll give it a try soon!
Looks very promising, but it failed for the first HLS stream that I tried. Quite often, files in the m3u8 (and any m3u8 files nested inside the main playlist) are referenced by a relative instead of an absolute URL:
example: The content of a playlist
https:/some.example.com/playlist.m3u8
may simply beSo the script would need to require the file at
https:/some.example.com/chunklist.m3u8
. That file might include something along the lines ofThe .ts files would then need to be requested from
https:/some.example.com/media_0.ts
.However, currently the script fails with relative paths, resulting in an error message like this:
To fix this, the script would have to check if it encounters a relative URL (anything without a protocol should to...) and in this case prepend the full URL of the previous file (not only the first URL, so that if the first playlist had listed a file in
chunks/chunklist.m3u
, the file should be requested athttps://some.example.com/chunks/chunklist.m3u8
accordingly, and if that list had the files listed astsfiles/001.ts
, it should be handled correctly ashttps://some.example.com/chunks/tsfiles/001.ts
, etc.)