Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- 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/
- If you have issues using this, try changing all occurances of `add_subnode` to `add_node`.
- Older versions of VLC use `add_node`, but recent updates have switched to `add_subnode`.
- --]]
- require "simplexml"
- function descriptor()
- return { title="/r/hockey" }
- end
- function main()
- local quality = {400, 800, 1200, 1600, 2400, 3000, 4500}
- local games = simplexml.parse_url("http://208.92.36.37/nlds/as3/get_games.php?client=nhl&playerclient=hop")
- for _, game in ipairs( games.children ) do
- if(game.name == "game") then
- simplexml.add_name_maps( game )
- local game_date = game.attributes["game_date"]
- local game_time = date_to_time(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 game_title = game_time .. " " .. away_team .. " @ " .. home_team
- if not string.find(home_team,"^T%d%d$") and not string.find (away_team,"^T%d%d$") then
- local node = vlc.sd.add_node( { title = game_title } )
- 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 d = node: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)
- d:add_subitem({ path = url, title = q .. ' kbps' })
- end
- end
- end
- end
- end
- end
- function date_to_time(game_date)
- -- TIME_OFFSET hours from Eastern time zone (moving westward). ie: Pacific should be 3
- local TIME_OFFSET = 3
- -- Change this so that the proper time is displayed for you.
- -- If you do not live in North America, you can add your timezone abreviation to the if statement below.
- local tz = "ET"
- if TIME_OFFSET == 1 then
- tz = "CT"
- elseif TIME_OFFSET == 2 then
- tz = "MT"
- elseif TIME_OFFSET == 3 then
- tz = "PT"
- end
- local game_time = string.gsub(game_date, "^.-%s(%d?%d):(%d%d):%d%d", "%1:%2 PM " .. tz)
- local _, _, hour = string.find(game_time, "^(%d?%d)")
- hour24 = tonumber(hour)
- local local_noon = (12 + TIME_OFFSET)
- local hour12 = tostring(hour24 - TIME_OFFSET)
- if hour24 < (local_noon) then
- game_time = string.gsub(game_time, "PM", "AM")
- elseif hour24 > (local_noon) then
- hour12 = tostring(hour24 - (local_noon))
- end
- game_time = string.gsub(game_time, "^%d?%d", hour12)
- return (game_time)
- 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",
- LOS = "Los Angeles Kings",
- MON = "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",
- SAN = "San Jose Sharks",
- OTT = "Ottawa Senators",
- TAM = "Tampa Bay Lightning",
- ANA = "Anaheim Ducks",
- FLA = "Florida Panthers",
- CMB = "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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement