Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

/r/hockey for vlc 2.1.0

By: a guest on Sep 26th, 2013  |  syntax: Lua  |  size: 1.97 KB  |  views: 9,114  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. --[[
  2.   DISCLAIMER: SCRIPT IS PROVIDED AS IS USE AT YOUR OWN RISK!
  3.  
  4.   Save this script as "hockey.lua"
  5.   Place this script in:
  6.     - Windows (all users):   %ProgramFiles%\VideoLAN\VLC\lua\sd\
  7.     - Windows (current user):   %APPDATA%\VLC\lua\sd\
  8.     - Linux (all users):     /usr/share/vlc/lua/sd/
  9.     - Linux (current user):  ~/.local/share/vlc/lua/sd/
  10.     - Mac OS X (all users):  VLC.app/Contents/MacOS/share/lua/sd/  
  11. --]]
  12. require "simplexml"
  13.  
  14. function descriptor()
  15.     return { title="/r/hockey" }
  16. end
  17.  
  18. function main()
  19.     local quality = {400, 800, 1200, 1600, 2400, 3000, 4500}
  20.     local games = simplexml.parse_url("http://208.92.36.37/nlds/as3/get_games.php?client=nhl&playerclient=hop")
  21.     for _, game in ipairs( games.children ) do              
  22.         if(game.name == "game") then          
  23.             simplexml.add_name_maps( game )
  24.             local game_date = game.attributes["game_date"]
  25.             local home_team = game.children_map['home_team'][1].children[1]
  26.             local away_team = game.children_map['away_team'][1].children[1]
  27.             local title = game_date .. " " .. away_team .. " @ " .. home_team
  28.             local node = vlc.sd.add_node( { path = "", title = title } )            
  29.             for _, ass in ipairs(game.children_map['assignments'][1].children) do
  30.                 local feed = ass.attributes["feed_display_name"]
  31.                 local feed_title = home_team
  32.                 if(feed == "away") then
  33.                     feed_title = away_team
  34.                 end
  35.                 local d = node:add_subnode({title = feed_title})                
  36.                 local ipad = ass.children_map['ipad_url'][1].children[1]
  37.                 for _, q in ipairs(quality) do
  38.                     local url = string.gsub(ipad, "ipad", q)
  39.                     d:add_subitem({path = url, title = away_team .. " @ " .. home_team .. '(' .. q .. ' kbps)'})
  40.                 end
  41.                
  42.             end
  43.         end
  44.     end
  45. end