m3u8
Python m3u8 parser.
Documentation
Loading a playlist
To load a playlist into an object from uri, file path or directly from string, use the load/loads functions:
import m3u8
playlist = m3u8.load('http://videoserver.com/playlist.m3u8') # this could also be an absolute filename
print(playlist.segments)
print(playlist.target_duration)
# if you already have the content as string, use
playlist = m3u8.loads('#EXTM3U8 ... etc ... ')
Dumping a playlist
To dump a playlist from an object to the console or a file, use the dump/dumps functions:
import m3u8
playlist = m3u8.load('http://videoserver.com/playlist.m3u8')
print(playlist.dumps())
# if you want to write a file from its content
playlist.dump('playlist.m3u8')
Supported tags
Encryption keys
The segments may be or not encrypted. The keys attribute list will be a list with all the different keys as described with #EXT-X-KEY:
Each key has the next properties:
method: ex.: "AES-128"
iv: the initialization vector, if available. Otherwise None.
If no #EXT-X-KEY is found, the keys list will have a unique element None. Multiple keys are supported.
If unencrypted and encrypted segments are mixed in the M3U8 file, then the l