[vlc-commits] commit: appletrailers sd: rewrite (Ilkka Ollakka )

git at videolan.org git at videolan.org
Fri May 21 13:01:24 CEST 2010


vlc | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Fri May 21 14:00:08 2010 +0300| [e78e5ad1873afe798aafc830c2dd6e3f01c6c4f8] | committer: Ilkka Ollakka 

appletrailers sd: rewrite

Don't use the iphone-trick, but instead parse the playlist-file and add
all the video-types on one run. Seems that when adding nodes on lua sd plugin,
theres some flickering.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e78e5ad1873afe798aafc830c2dd6e3f01c6c4f8
---

 share/lua/sd/appletrailers.lua |   53 +++++++++++++++++++++++++++-------------
 1 files changed, 36 insertions(+), 17 deletions(-)

diff --git a/share/lua/sd/appletrailers.lua b/share/lua/sd/appletrailers.lua
index 3afd184..69d9a68 100644
--- a/share/lua/sd/appletrailers.lua
+++ b/share/lua/sd/appletrailers.lua
@@ -30,28 +30,47 @@ 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
+    options = {":http-user-agent=QuickTime/7.2 vlc edition",":demux=avformat",":play-and-pause"}
+    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, "location\":\"(.-)\"")
-            trailertype = ""
-            trailertype = find( line, "type\":\"(.-)\"")
-            vlc.msg.err(trailertype)
-            if trailertype then
-               trailertype = string.gsub( trailertype, " ", "")
-               trailertype = string.lower( trailertype )
-            else
-               trailertype = "trailer"
+
+            url = find( line, "url\":\"(.-)\"")
+            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} )
+
+            playlistline = playlist:readline()
+            description =""
+            vlc.msg.info( "http://trailers.apple.com"..url.."includes/playlists/web.inc" )
+            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")
+                    vlc.msg.info( "Got type:"..description )
+                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 )
+                        vlc.msg.info( "adding url:"..urlline )
+                        node:add_subitem( {path = urlline,
+                                  title=title.." "..description.." ("..resolution..")",
+                                  options=options, arturl=art })
+                    end
+                end
+                playlistline = playlist:readline()
             end
-            url = "http://trailers.apple.com"..url..trailertype.."/"
-            vlc.sd.add_item( { path = url, name=title, title=title, options=options, arturl=art})
+            vlc.msg.info( "entry done...")
          end
+         line = fd:readline()
     end
 end



More information about the vlc-commits mailing list