]> git.sesse.net Git - vlc/commitdiff
fix appletrailers playlist parser
authorIlkka Ollakka <ileoo@videolan.org>
Sat, 27 Apr 2013 13:52:05 +0000 (16:52 +0300)
committerIlkka Ollakka <ileoo@videolan.org>
Sat, 27 Apr 2013 13:52:22 +0000 (16:52 +0300)
share/lua/playlist/appletrailers.lua

index 4d0f5e7a9921cc686cf9a06c852d395319a98d24..d303ef79db170f748dac85e40fb38f467b29f865 100644 (file)
@@ -24,6 +24,7 @@
 function probe()
     return vlc.access == "http"
         and string.match( vlc.path, "trailers.apple.com" )
+        and string.match( vlc.path, "web.inc" )
 end
 
 function find( haystack, needle )
@@ -63,8 +64,9 @@ function parse()
         line = vlc.readline()
         if not line then break end
 
-        if string.match( line, "class=\".-first" ) then
-            description = find( line, "h%d.->(.-)</h%d") .. ' '
+        if string.match( line, "h%d>.-</h%d" ) then
+            description = find( line, "h%d>(.+)</h%d")
+            vlc.msg.dbg(description)
         end
         if string.match( line, 'img src=') then
             for img in string.gmatch(line, '<img src="(http://.*%.jpg)" ') do
@@ -73,20 +75,19 @@ function parse()
             for i,value in pairs(playlist) do
                 if value.arturl == '' then
                     playlist[i].arturl = art_url
-                else break end
+                end
             end
         end
         if string.match( line, 'class="hd".-%.mov') then
-            for urlline,resolution in string.gmatch(line, 'class="hd".-href="(.-%.mov)".-(%d+.-p)') do
+            for urlline,resolution in string.gmatch(line, 'class="hd".-href="(.-%.mov)".->(%d+.-p)') do
                 urlline = string.gsub( urlline, "_"..resolution, "_h"..resolution )
                 table.insert( playlist, { path = urlline,
-                                          name = description ..  '(' .. resolution .. ')',
+                                          name = description.." "..resolution,
                                           arturl = art_url,
-                                          options = {":http-user-agent=QuickTime/7.5", ":play-and-pause"} } )
+                                          options = {":http-user-agent=QuickTime/7.5", ":play-and-pause", ":demux=avformat"} } )
             end
         end
     end
 
-    table.sort(playlist, sort)
     return playlist
 end