Created
February 18, 2019 01:30
-
-
Save thanley11/4b03fec75d64dddc78918cef497d6a7f to your computer and use it in GitHub Desktop.
Play b64 encoded stream in mpv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import base64 | |
import argparse | |
from subprocess import run, PIPE | |
parser = argparse.ArgumentParser() | |
parser.add_argument("b64", help="b64 string for stream", type=str) | |
args = parser.parse_args() | |
parsed = args.b64.split('streamenhancer://', 1)[1] | |
decoded = base64.b64decode(parsed) | |
subscriber = json.loads(decoded) | |
url = subscriber['request']['url'] | |
result= "" | |
for x in subscriber['request']['headers']: | |
result += " --http-header \"%s=%s\"" %(x.pop('name'), x.pop('value')) | |
p = run(["streamlink", "-p mpv", url, "best"], stdout=PIPE, input=result, encoding='ascii') | |
print(p.returncode) | |
print(p.stdout) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment