]> git.sesse.net Git - vlc/blobdiff - share/lua/sd/appletrailers.lua
lua: improve the apple trailer sd:
[vlc] / share / lua / sd / appletrailers.lua
index eea68cf94acd14189f2a2c8434b58e87758348bd..244f30e5d66e8e98de2f180a65b6ef2aa6763b46 100644 (file)
@@ -30,20 +30,25 @@ function find( haystack, needle )
 end
 
 function main()
-    fd = vlc.stream( "http://trailers.apple.com/trailers/iphone/home/feeds/just_added.json" )
+    fd = vlc.stream( "http://trailers.apple.com/trailers/home/feeds/just_hd.json" )
     if not fd then return nil end
-    options = {":http-user-agent='iPhone'"}
-    while true
+    line = fd:readline()
+    while line ~= nil
     do
-         line = fd:readline()
-         if not line then break end
-         if string.match( line, "title" ) and string.match( line, "hd\":true")then
+         if string.match( line, "title" ) then 
             title = vlc.strings.resolve_xml_special_chars( find( line, "title\":\"(.-)\""))
             art = find( line, "poster\":\"(.-)\"")
-            url = find( line, "url\":\"(.-)\"")
-            url = string.gsub( url, "trailers/","trailers/iphone/")
-            url = "http://trailers.apple.com"..url.."trailer/"
-            vlc.sd.add_item( { path = url, name=title, title=title, options=options, arturl=art})
+            if string.match( art, "http://" ) then
+            else
+                art = "http://trailers.apple.com"..art
+            end
+
+            url = find( line, "location\":\"(.-)\"")
+            node = vlc.sd.add_item( {title  = title,
+                                     path   = "http://trailers.apple.com"..url.."includes/playlists/web.inc",
+                                     arturl = art})
+
          end
+         line = fd:readline()
     end
 end