Skip to content

Instantly share code, notes, and snippets.

@blha303 blha303/stream2vlc.py Secret
Last active Dec 19, 2015

Embed
What would you like to do?
from urllib2 import urlopen
import json
from sys import argv, exit
def getswfaddr(channelname):
return urlopen("http://www.justin.tv/widgets/live_embed_player.swf?channel=" + channelname).geturl().split("&userAgent")[0]
def getstreaminfo(channelname):
data = json.loads(urlopen("http://usher.justin.tv/find/%s.json?type=any" % channelname.lower()).read())
newd = {}
for i in data:
newd[i['display']] = i
return newd
def buildcmdline(channelname, data, quality="360p"):
data = data[quality]
if not "live-cdn" in data["connect"] and not "justintvlivefs" in data["connect"]:
justinlegacyparams = '-j "%s"' % data["token"].replace('"', r'\"')
else:
justinlegacyparams = ""
out = '-r "%s/%s" %s --swfVfy "%s" -v -o -' % (data["connect"], data["play"], justinlegacyparams, getswfaddr(channelname))
return out
def main():
if len(argv) < 2:
print "Usage: %s channelname [quality]"
exit(2)
if len(argv) > 2:
quality = argv[2]
else:
quality = "360p"
channelname = argv[1]
data = getstreaminfo(channelname)
print buildcmdline(channelname, data, quality=quality)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.