]> git.sesse.net Git - vlc/blobdiff - share/lua/sd/appletrailers.lua
lua: improve the apple trailer sd:
[vlc] / share / lua / sd / appletrailers.lua
index 3675c5d9cbd7cec36d5f81eb84e124d9f53db1a6..244f30e5d66e8e98de2f180a65b6ef2aa6763b46 100644 (file)
@@ -32,7 +32,6 @@ end
 function main()
     fd = vlc.stream( "http://trailers.apple.com/trailers/home/feeds/just_hd.json" )
     if not fd then return nil end
-    options = {":http-user-agent=QuickTime/7.2",":demux=avformat,ffmpeg",":play-and-pause"}
     line = fd:readline()
     while line ~= nil
     do
@@ -45,31 +44,10 @@ function main()
             end
 
             url = find( line, "location\":\"(.-)\"")
-            playlist = vlc.stream( "http://trailers.apple.com"..url.."includes/playlists/web.inc" )
-            if not playlist then 
-                vlc.msg.info("Didn't get playlist...")
-            end
-
-            node = vlc.sd.add_node( {title=title,arturl=art} )
+            node = vlc.sd.add_item( {title  = title,
+                                     path   = "http://trailers.apple.com"..url.."includes/playlists/web.inc",
+                                     arturl = art})
 
-            playlistline = playlist:readline()
-            description =""
-            if not playlistline then vlc.msg.info("Empty playlists-file") end
-            while playlistline ~= nil
-            do
-                if string.match( playlistline, "class=\".-first" ) then
-                    description = find( playlistline, "h%d.->(.-)</h%d")
-                end
-                if string.match( playlistline, "class=\"hd\".-\.mov") then
-                    for urlline,resolution in string.gmatch(playlistline, "class=\"hd\".-href=\"(.-.mov)\".-(%d+.-p)") do
-                        urlline = string.gsub( urlline, "_"..resolution, "_h"..resolution )
-                        node:add_subitem( {path = urlline,
-                                  title=title.." "..description.." ("..resolution..")",
-                                  options=options, arturl=art })
-                    end
-                end
-                playlistline = playlist:readline()
-            end
          end
          line = fd:readline()
     end