you can monkey-patch streamlink to change the key retrival url, tho it works fine even without doing it
Code:
import sys
import struct
import streamlink
from Crypto.Cipher import AES
from streamlink.exceptions import StreamError
from base64 import b64encode
session = streamlink.session.Streamlink()
def num_to_iv(n):
return struct.pack(">8xq", n)
def new_create_decryptor(self, key, sequence):
if key.method != "AES-128":
raise StreamError("Unable to decrypt cipher {0}", key.method)
if not key.uri:
raise StreamError("Missing URI to decryption key")
if self.key_uri != key.uri:
new_uri = b'http://www.zoomtv.me/k.php?q='+b64encode(b'p=mlb&id=1&v=tv&vw=1&s='+b64encode(bytes(key.uri,'utf8')))
res = self.session.http.get(new_uri.decode('utf-8'), exception=StreamError,
retries=self.retries,
**self.reader.request_params)
self.key_data = res.content
self.key_uri = key.uri
iv = key.iv or num_to_iv(sequence)
# Pad IV if needed
iv = b"\x00" * (16 - len(iv)) + iv
return AES.new(self.key_data, AES.MODE_CBC, iv)
streamlink.stream.hls.HLSStreamWriter.create_decryptor = new_create_decryptor
session.set_option("http-headers", {'Referer':'http://www.zoomtv.me/kembed.php?p=mlb&id=1&v=tv'})
streams = session.streams('hlsvariant://http://mlblive-akc.mlb.com/ls01/mlbam/mlb_network/NETWORK_LINEAR_1/master_wired.m3u8')
stream = streams["worst"]
fd = stream.open()
while True:
sys.stdout.buffer.write(fd.read(100 * 1024))
python player.py | vlc -