Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This file must be in the same place as the JAR file:
- # http://www.reddit.com/r/hockey/comments/1q58xv/how_to_get_vlc_links/cf8zxx8?sort=confidence
- #
- # Edit this next line to match your VLC binary: ( \ = escape char, so double it for literal \ )
- vlcbin = "C:\\Program Files\\VideoLAN\\VLC\\vlc.exe"
- # Add this line to your hosts file (minus the comment #)
- # 127.0.0.1 nlsk.neulion.com
- import json, urllib2, os, time
- r = urllib2.urlopen("http://live.nhl.com/GameData/SeasonSchedule-20132014.json")
- h = r.read()
- d = json.loads(h)
- #date = raw_input("Enter date of game [YYYYMMDD]: ")
- date = time.strftime("%Y%m%d")
- games = []
- for entry in d:
- if entry['est'][:8] == date:
- games.append({"id":str(entry['id'])[-4:],"home":entry['h'],"away":entry['a']})
- if not games:
- print "I couldn't find any games for that date. Sorry."
- os._exit(0)
- for (i,game) in enumerate(games):
- print "{}: {} at {}".format(i+1,game['away'],game['home'])
- c = raw_input("Which game would you like to start (#)? ")
- gameid = games[int(c)-1]['id']
- url = "http://smb.cdnak.neulion.com/fs/nhl/mobile/feed_new/data/streams/2013/ipad/02_{}.json".format(gameid)
- try:
- r = urllib2.urlopen(url)
- h = r.read()
- d = json.loads(h)
- home = d['gameStreams']['ipad']['home']['live']['bitrate0']
- away = d['gameStreams']['ipad']['away']['live']['bitrate0']
- except:
- print "It appears that game hasn't started yet. Sorry."
- os._exit(0)
- if not home or not away:
- print "I couldn't find any streams for this game. Sorry."
- os._exit(0)
- if "mp4" in home or "mp4" in away:
- print "It appears that game has ended already. Sorry."
- os._exit(0)
- print "Here are the URLs I found for this game:"
- bitrates = [1600,3000,4500]
- urls = [home,away]
- urllist = []
- i = 0
- for url in urls:
- url = url[:-9]
- for bitrate in bitrates:
- i += 1
- string = "{}{}.m3u8".format(url,bitrate)
- urllist.append(string)
- print "{}: {}".format(i,string)
- #~ print urllist
- urlnum = raw_input("Choose a game (#): ")
- url = str(urllist[int(urlnum)-1])
- import subprocess, threading
- def run_java(url):
- process = "java -jar FuckNeulionV1.jar " + url
- subprocess.call(process,shell=True)
- return
- def run_vlc(url):
- process = '"' + vlcbin + '" ' + url + ' :http-user-agent=iTunesAppleTV/4.1'
- subprocess.call(process,shell=True)
- return
- t1 = threading.Thread(target=run_java,args=(url,))
- t1.start()
- t2 = threading.Thread(target=run_vlc,args=(url,))
- t2.start()
- t2.join()
- print "Hit CTRL-C to stop the java process."
- t1.join()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement