]> git.sesse.net Git - vlc/commitdiff
Add a lua playlist script for trailers.apple.com pages.
authorAntoine Cellerier <dionoea@videolan.org>
Tue, 11 Sep 2007 21:55:39 +0000 (21:55 +0000)
committerAntoine Cellerier <dionoea@videolan.org>
Tue, 11 Sep 2007 21:55:39 +0000 (21:55 +0000)
share/luaplaylist/appletrailers.lua [new file with mode: 0644]

diff --git a/share/luaplaylist/appletrailers.lua b/share/luaplaylist/appletrailers.lua
new file mode 100644 (file)
index 0000000..127eb72
--- /dev/null
@@ -0,0 +1,51 @@
+-- $Id$
+
+--[[
+    Translate trailers.apple.com video webpages URLs to the corresponding
+    movie URL
+--]]
+
+-- Probe function.
+function probe()
+    return vlc.access == "http"
+        and string.match( vlc.path, "trailers.apple.com" ) 
+end
+
+-- Parse function.
+function parse()
+    p = {}
+    while true
+    do 
+        line = vlc.readline()
+        if not line then break end
+        if string.match( line, "http://movies.apple.com/movies/.*%.mov" )
+        or string.match( line, "http://images.apple.com/movies/.*%.mov" )
+        then
+            if string.match( line, "http://movies.apple.com/movies/.*%.mov" ) then
+                path = vlc.decode_uri( string.gsub( line, "^.*(http://movies.apple.com/movies/.*%.mov).*$", "%1" ) )
+            elseif string.match( line, "http://images.apple.com/movies/.*%.mov" ) then
+                path = vlc.decode_uri( string.gsub( line, "^.*(http://images.apple.com/movies/.*%.mov).*$", "%1" ) )
+            end
+            if string.match( path, "480p" ) then
+                extraname = " (480p)"
+            elseif string.match( path, "720p" ) then
+                extraname = " (720p)"
+            elseif string.match( path, "1080p" ) then
+                extraname = " (1080p)"
+            else
+                extraname = ""
+            end
+            vlc.msg_err( path )
+            table.insert( p, { path = path; name = title..extraname; description = description; url = vlc.path } )
+        end
+        if string.match( line, "<title>" )
+        then
+            title = vlc.decode_uri( string.gsub( line, "^.*<title>([^<]*).*$", "%1" ) )
+        end
+        if string.match( line, "<meta name=\"Description\"" )
+        then
+            description = vlc.resolve_xml_special_chars( string.gsub( line, "^.*name=\"Description\" content=\"([^\"]*)\".*$", "%1" ) )
+        end
+    end
+    return p
+end