Advertisement
Guest User

prety version

a guest
Oct 10th, 2013
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. If you have issues using this, try changing all occurances of `add_subnode` to `add_node`.
  13. Older versions of VLC use `add_node`, but recent updates have switched to `add_subnode`.
  14. --]]
  15. require "simplexml"
  16.  
  17. function descriptor()
  18. return { title="/r/hockey" }
  19. end
  20.  
  21. function main()
  22. local quality = {400, 800, 1200, 1600, 2400, 3000, 4500}
  23. local games = simplexml.parse_url("http://208.92.36.37/nlds/as3/get_games.php?client=nhl&playerclient=hop")
  24. for _, game in ipairs( games.children ) do
  25. if(game.name == "game") then
  26. simplexml.add_name_maps( game )
  27. local game_date = game.attributes["game_date"]
  28. local game_time = date_to_time(game_date)
  29. local home_team = full_name(game.children_map['home_team'][1].children[1])
  30. local away_team = full_name(game.children_map['away_team'][1].children[1])
  31. local game_title = game_time .. " " .. away_team .. " @ " .. home_team
  32. if not string.find(home_team,"^T%d%d$") and not string.find (away_team,"^T%d%d$") then
  33. local node = vlc.sd.add_node( { title = game_title } )
  34. for _, ass in ipairs(game.children_map['assignments'][1].children) do
  35. local feed = ass.attributes["feed_display_name"]
  36. local feed_title = home_team
  37. if(feed == "away") then
  38. feed_title = away_team
  39. end
  40. local feed_node = node:add_subnode({ title = feed_title })
  41. local ipad = ass.children_map['ipad_url'][1].children[1]
  42. for _, q in ipairs(quality) do
  43. local url = string.gsub(ipad, "ipad", q)
  44. feed_node:add_subitem({ path = url,
  45. title = q .. ' kbps',
  46. options = { "http-user-agent=AppleCoreMedia/1.0.0.8C148 (iPad; U; CPU OS 4_2_1 like Mac OS X; en_us)" }
  47. })
  48. end
  49. end
  50. end
  51. end
  52. end
  53. end
  54.  
  55. function date_to_time(game_date)
  56. -- TIME_OFFSET hours from Eastern time zone (moving westward). ie: Pacific should be 3
  57. local TIME_OFFSET = 3
  58. -- Change this so that the proper time is displayed for you.
  59. -- If you do not live in North America, you can add your timezone abreviation to the if statement below.
  60. local tz = "ET"
  61. if TIME_OFFSET == 1 then
  62. tz = "CT"
  63. elseif TIME_OFFSET == 2 then
  64. tz = "MT"
  65. elseif TIME_OFFSET == 3 then
  66. tz = "PT"
  67. end
  68. local game_time = string.gsub(game_date, "^.-%s(%d?%d):(%d%d):%d%d", "%1:%2 PM " .. tz)
  69. local _, _, hour = string.find(game_time, "^(%d?%d)")
  70. hour24 = tonumber(hour)
  71. local local_noon = (12 + TIME_OFFSET)
  72. local hour12 = tostring(hour24 - TIME_OFFSET)
  73. if hour24 < (local_noon) then
  74. game_time = string.gsub(game_time, "PM", "AM")
  75. elseif hour24 > (local_noon) then
  76. hour12 = tostring(hour24 - (local_noon))
  77. end
  78. game_time = string.gsub(game_time, "^%d?%d", hour12)
  79. return (game_time)
  80. end
  81.  
  82. function full_name(abr)
  83. local all_names = {
  84. BOS = "Boston Bruins",
  85. BUF = "Buffalo Sabres",
  86. CGY = "Calgary Flames",
  87. CHI = "Chicago Blackhawks",
  88. DET = "Detroit Red Wings",
  89. EDM = "Edmonton Oilers",
  90. CAR = "Carolina Hurricanes",
  91. LOS = "Los Angeles Kings",
  92. MON = "Montreal Canadiens",
  93. DAL = "Dallas Stars",
  94. NJD = "New Jersey Devils",
  95. NYI = "New York Islanders",
  96. NYR = "New York Rangers",
  97. PHI = "Philadelphia Flyers",
  98. PIT = "Pittsburgh Penguins",
  99. COL = "Colorado Avalanche",
  100. STL = "St. Louis Blues",
  101. TOR = "Toronto Maple Leafs",
  102. VAN = "Vancouver Canucks",
  103. WSH = "Washington Capitals",
  104. PHX = "Phoenix Coyotes",
  105. SAN = "San Jose Sharks",
  106. OTT = "Ottawa Senators",
  107. TAM = "Tampa Bay Lightning",
  108. ANA = "Anaheim Ducks",
  109. FLA = "Florida Panthers",
  110. CMB = "Columbus Blue Jackets",
  111. MIN = "Minnesota Wild",
  112. NSH = "Nashville Predators",
  113. WPG = "Winnipeg Jets"
  114. }
  115. local name = all_names[abr]
  116. if name == nil then
  117. name = abr
  118. end
  119. return(name)
  120. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement