]> git.sesse.net Git - vlc/blobdiff - share/luaplaylist/metacafe.lua
Fix youtube.lua probe() function.
[vlc] / share / luaplaylist / metacafe.lua
index 8490d9b2f953b9d11211e24a73f198b1d64a9f43..30b176b9a1abd07aa8e414a1ca2bb816096a8eb4 100644 (file)
@@ -12,8 +12,23 @@ end
 function parse()
     if string.match( vlc.path, "watch/" )
     then -- This is the HTML page's URL
-        return { { url = string.gsub( vlc.path, "^.*watch/(.*[^/])/?$", "http://www.metacafe.com/fplayer/%1.swf" ) } }
+        while true do
+            -- Try to find the video's title
+            line = vlc.readline()
+            if not line then break end
+            if string.match( line, "<meta name=\"title\"" ) then
+                name = string.gsub( line, "^.*content=\"Metacafe %- ([^\"]*).*$", "%1" )  
+            end
+            if string.match( line, "<meta name=\"description\"" ) then
+                description = string.gsub( line, "^.*content=\"([^\"]*).*$", "%1" )  
+            end
+            if string.match( line, "<link rel=\"image_src\"" ) then
+                arturl = string.gsub( line, "^.*href=\"([^\"]*)\".*$", "%1" )
+            end
+            if name and description and arturl then break end
+        end
+        return { { path = string.gsub( vlc.path, "^.*watch/(.*[^/])/?$", "http://www.metacafe.com/fplayer/%1.swf" ); name = name; description = description; arturl = arturl;  } }
     else -- This is the flash player's URL
-        return { { url = string.gsub( vlc.path, "^.*mediaURL=([^&]*).*$", "%1" ) } }
+        return { { path = string.gsub( vlc.path, "^.*mediaURL=([^&]*).*$", "%1" ) } }
     end
 end