Advertisement
Guest User

NHL Streams

a guest
Mar 13th, 2014
579
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # This file must be in the same place as the JAR file:
  2. # http://www.reddit.com/r/hockey/comments/1q58xv/how_to_get_vlc_links/cf8zxx8?sort=confidence
  3. #
  4. # Edit this next line to match your VLC binary: ( \ = escape char, so double it for literal \ )
  5. vlcbin = "C:\\Program Files\\VideoLAN\\VLC\\vlc.exe"
  6. # Add this line to your hosts file (minus the comment #)
  7. # 127.0.0.1 nlsk.neulion.com
  8.  
  9. import json, urllib2, os, time
  10.  
  11. r = urllib2.urlopen("http://live.nhl.com/GameData/SeasonSchedule-20132014.json")
  12. h = r.read()
  13. d = json.loads(h)
  14.  
  15. #date = raw_input("Enter date of game [YYYYMMDD]: ")
  16. date = time.strftime("%Y%m%d")
  17.  
  18. games = []
  19. for entry in d:
  20. if entry['est'][:8] == date:
  21. games.append({"id":str(entry['id'])[-4:],"home":entry['h'],"away":entry['a']})
  22.  
  23. if not games:
  24. print "I couldn't find any games for that date. Sorry."
  25. os._exit(0)
  26.  
  27. for (i,game) in enumerate(games):
  28. print "{}: {} at {}".format(i+1,game['away'],game['home'])
  29.  
  30. c = raw_input("Which game would you like to start (#)? ")
  31.  
  32. gameid = games[int(c)-1]['id']
  33.  
  34. url = "http://smb.cdnak.neulion.com/fs/nhl/mobile/feed_new/data/streams/2013/ipad/02_{}.json".format(gameid)
  35. try:
  36. r = urllib2.urlopen(url)
  37. h = r.read()
  38. d = json.loads(h)
  39.  
  40. home = d['gameStreams']['ipad']['home']['live']['bitrate0']
  41. away = d['gameStreams']['ipad']['away']['live']['bitrate0']
  42. except:
  43. print "It appears that game hasn't started yet. Sorry."
  44. os._exit(0)
  45.  
  46. if not home or not away:
  47. print "I couldn't find any streams for this game. Sorry."
  48. os._exit(0)
  49.  
  50. if "mp4" in home or "mp4" in away:
  51. print "It appears that game has ended already. Sorry."
  52. os._exit(0)
  53.  
  54. print "Here are the URLs I found for this game:"
  55. bitrates = [1600,3000,4500]
  56. urls = [home,away]
  57. urllist = []
  58. i = 0
  59. for url in urls:
  60. url = url[:-9]
  61. for bitrate in bitrates:
  62. i += 1
  63. string = "{}{}.m3u8".format(url,bitrate)
  64. urllist.append(string)
  65. print "{}: {}".format(i,string)
  66.  
  67. #~ print urllist
  68.  
  69. urlnum = raw_input("Choose a game (#): ")
  70. url = str(urllist[int(urlnum)-1])
  71.  
  72. import subprocess, threading
  73.  
  74. def run_java(url):
  75. process = "java -jar FuckNeulionV1.jar " + url
  76. subprocess.call(process,shell=True)
  77. return
  78.  
  79. def run_vlc(url):
  80. process = '"' + vlcbin + '" ' + url + ' :http-user-agent=iTunesAppleTV/4.1'
  81. subprocess.call(process,shell=True)
  82. return
  83.  
  84. t1 = threading.Thread(target=run_java,args=(url,))
  85. t1.start()
  86. t2 = threading.Thread(target=run_vlc,args=(url,))
  87. t2.start()
  88.  
  89. t2.join()
  90. print "Hit CTRL-C to stop the java process."
  91. t1.join()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement