m3u8
m3u8 copied to clipboard
the behavior of M3U8(builtins.object).files
>>> import m3u8
>>> p=m3u8.load('http://qv.gaiamount.com/playlist/u116/v810_mp4.m3u8?e=1477373423&token=_6yhTpZI-AHtfULMSiW7eOCvrNEnOS_YcLV9GNfH:a6ZdAsiLXdfy10QBiWguUyq26yU=')
>>> p.files
['http://www.gaiamount.com/keys/3958/4k', '/seg/u116/v810_mp4_0000.ts', '/seg/u116/v810_mp4_0001.ts', '/seg/u116/v810_mp4_0002.ts', '/seg/u116/v810_mp4_0003.ts', '/seg/u116/v810_mp4_0004.ts', '/seg/u116/v810_mp4_0005.ts', '/seg/u116/v810_mp4_0006.ts', '/seg/u116/v810_mp4_0007.ts', '/seg/u116/v810_mp4_0008.ts', '/seg/u116/v810_mp4_0009.ts', '/seg/u116/v810_mp4_0010.ts', '/seg/u116/v810_mp4_0011.ts', '/seg/u116/v810_mp4_0012.ts', '/seg/u116/v810_mp4_0013.ts', '/seg/u116/v810_mp4_0014.ts', '/seg/u116/v810_mp4_0015.ts', '/seg/u116/v810_mp4_0016.ts', '/seg/u116/v810_mp4_0017.ts', '/seg/u116/v810_mp4_0018.ts', '/seg/u116/v810_mp4_0019.ts', '/seg/u116/v810_mp4_0020.ts', '/seg/u116/v810_mp4_0021.ts', '/seg/u116/v810_mp4_0022.ts', '/seg/u116/v810_mp4_0023.ts', '/seg/u116/v810_mp4_0024.ts', '/seg/u116/v810_mp4_0025.ts', '/seg/u116/v810_mp4_0026.ts', '/seg/u116/v810_mp4_0027.ts', '/seg/u116/v810_mp4_0028.ts', '/seg/u116/v810_mp4_0029.ts', '/seg/u116/v810_mp4_0030.ts']
>>>
(1) what should I do to get the absolute URIs of all the segments?
(2) I think M3U8(builtins.object).files should return all the URIs of the segments , but why present the key uri along with them ? This makes the result difficult to use , for example if I want to use the returned result to download all the chunks, then I have to judge whether the first element is a key uri or not, so annoying! It would be better to create another method like M3U8(builtins.object).key_uri to specifically return the key uri .
- It should be the
base_uri - I think it's reasonable to keep all the files from the playlist on
.filesand you can filter only ts files
[x for x in m3u8.files if x endswith(".ts")]
Let's leave this open so more people can give their opinions.
also, it seems file segments returned by M3U8(builtins.object).files doesn't in the order they appear in the whole video, any solution to correct this ?
I think it is a semantic problem, right? files gives the feel it has only real files (chunks)
If we remove the key_uri we would break the current API for those who depend on having the key_uri inside files