Quote:
Originally Posted by Dune
Thank you very much for the Python port! I'm gonna try this ASAP.
|
I'm not sure what you mean by "port", it has nothing to do with the earlier ruby code (which only handle a classic HLS stream)
My code specifically and only address the problem of the encrypted .key file. (it even includes the secret - well not that secret anymore

- key !)
If you want a python port of the ruby code (to dump a classic HLS stream like ffmpeg would do) it's more like that :
Code:
import m3u8
from Crypto.Cipher import AES
f = open('file.ts','rb')
playlist = m3u8.loads(playlist)
key = urllib2.urlopen(playlist.key.uri).read() # <- swap that line with my earlier snippet to handle encrypted keys
iv = ('%x' % int(playlist.key.iv,16)).decode("hex")
aes = AES.new(key, AES.MODE_CBC, iv)
for x in playlist.segments :
r = urllib2.urlopen(x.uri)
d = r.read()
d = aes.decrypt(d)
f.write(d)
f.close()