globocom / m3u8

Python m3u8 Parser for HTTP Live Streaming (HLS) Transmissions
Other
2.03k stars 471 forks source link

Is there a way to get full URI of the m3u8 from the object directly? #317

Closed fireattack closed 1 year ago

fireattack commented 1 year ago

Say I loaded an URI into m3u8 object with:

import m3u8 

m = m3u8.load("https://example.com/live/something.m3u8?para=value")

Afterwards I cannot retrieve the original URL (https://example.com/live/something.m3u8?para=value) from m anymore. It only seems to have m.base_uri (which would be https://example.com/live/), not anything about path, query parameters, etc.

That makes processing m3u8 kinda complicated in certain scenarios since only passing the object around isn't enough.

bbayles commented 1 year ago

You're right that the only thing available is the base_uri. But since this is a Python object, you can solve your problem in one line:

>>> import m3u8 
>>> playlist_uri = "https://example.com/live/something.m3u8?para=value"
>>> m = m3u8.load(playlist_uri)
>>> m.original_uri = playlist_uri
>>> m.original_uri
'https://example.com/live/something.m3u8?para=value'
fireattack commented 1 year ago

thanks, that works.