--[[ DISCLAIMER: SCRIPT IS PROVIDED AS IS USE AT YOUR OWN RISK! Save this script as "hockey.lua" Place this script in: - Windows (all users): %ProgramFiles%\VideoLAN\VLC\lua\sd\ - Windows (current user): %APPDATA%\VLC\lua\sd\ - Linux (all users): /usr/share/vlc/lua/sd/ - Linux (current user): ~/.local/share/vlc/lua/sd/ - Mac OS X (all users): VLC.app/Contents/MacOS/share/lua/sd/ --]] require "simplexml" function descriptor() return { title="/r/hockey" } end function main() local games = simplexml.parse_url("http://breadwinka.com/get_games.php?client=nhl&playerclient=hop") local test_games = {} for _, game in ipairs( games.children ) do if(game.name == "game") then simplexml.add_name_maps( game ) local game_date, home_team, away_team, title = getInfoForGame(game) if string.find(home_team,"^T%d+$") or string.find (away_team,"^T%d+$") then table.insert(test_games, game) else local node = vlc.sd.add_node( { path = "", title = title } ) addNodeForGame(node, game, home_team, away_team) end end end if table.getn(test_games) > 0 then local test_node = vlc.sd.add_node( { path = "", title = "Test Streams" } ) for _, game in ipairs(test_games) do local game_date, home_team, away_team, title = getInfoForGame(game) node = test_node:add_subnode({ title = title }) addNodeForGame(node, game, home_team, away_team) end end end function getInfoForGame(game) local game_date = game.attributes["game_date"] local home_team = full_name(game.children_map['home_team'][1].children[1]) local away_team = full_name(game.children_map['away_team'][1].children[1]) local title = game_date .. " " .. away_team .. " @ " .. home_team return game_date, home_team, away_team, title end function addNodeForGame(parentNode, game, home_team, away_team) local quality = {400, 800, 1200, 1600, 2400, 3000, 4500} for _, ass in ipairs(game.children_map['assignments'][1].children) do local feed = ass.attributes["feed_display_name"] local feed_title = home_team if(feed == "away") then feed_title = away_team end local feed_node = parentNode:add_subnode({ title = feed_title }) local ipad = ass.children_map['ipad_url'][1].children[1] for _, q in ipairs(quality) do local url = string.gsub(ipad, "ipad", q) feed_node:add_subitem({ path = url, title = q .. ' kbps', options = { "http-user-agent=iTunes-AppleTV/4.1" } }) end end end function full_name(abr) local all_names = { BOS = "Boston Bruins", BUF = "Buffalo Sabres", CGY = "Calgary Flames", CHI = "Chicago Blackhawks", DET = "Detroit Red Wings", EDM = "Edmonton Oilers", CAR = "Carolina Hurricanes", LAK = "Los Angeles Kings", MTL = "Montreal Canadiens", DAL = "Dallas Stars", NJD = "New Jersey Devils", NYI = "New York Islanders", NYR = "New York Rangers", PHI = "Philadelphia Flyers", PIT = "Pittsburgh Penguins", COL = "Colorado Avalanche", STL = "St. Louis Blues", TOR = "Toronto Maple Leafs", VAN = "Vancouver Canucks", WSH = "Washington Capitals", PHX = "Phoenix Coyotes", SJS = "San Jose Sharks", OTT = "Ottawa Senators", TBL = "Tampa Bay Lightning", ANA = "Anaheim Ducks", FLA = "Florida Panthers", CBJ = "Columbus Blue Jackets", MIN = "Minnesota Wild", NSH = "Nashville Predators", WPG = "Winnipeg Jets" } local name = all_names[abr] if name == nil then name = abr end return(name) end