]> git.sesse.net Git - vlc/blob - share/luaplaylist/metacafe.lua
vlc.desktop: the version in it refers to the standard version not VLC version.
[vlc] / share / luaplaylist / metacafe.lua
1 -- $Id$
2
3 -- Probe function.
4 function probe()
5     return vlc.access == "http"
6         and string.match( vlc.path, "metacafe.com" ) 
7         and (  string.match( vlc.path, "watch/" )
8             or string.match( vlc.path, "mediaURL=" ) )
9 end
10
11 -- Parse function.
12 function parse()
13     if string.match( vlc.path, "watch/" )
14     then -- This is the HTML page's URL
15         while true do
16             -- Try to find the video's title
17             line = vlc.readline()
18             if not line then break end
19             if string.match( line, "<meta name=\"title\"" ) then
20                 name = string.gsub( line, "^.*content=\"Metacafe %- ([^\"]*).*$", "%1" )  
21             end
22             if string.match( line, "<meta name=\"description\"" ) then
23                 description = string.gsub( line, "^.*content=\"([^\"]*).*$", "%1" )  
24             end
25             if string.match( line, "<link rel=\"image_src\"" ) then
26                 arturl = string.gsub( line, "^.*href=\"([^\"]*)\".*$", "%1" )
27             end
28             if name and description and arturl then break end
29         end
30         return { { path = string.gsub( vlc.path, "^.*watch/(.*[^/])/?$", "http://www.metacafe.com/fplayer/%1.swf" ); name = name; description = description; arturl = arturl;  } }
31     else -- This is the flash player's URL
32         return { { path = string.gsub( vlc.path, "^.*mediaURL=([^&]*).*$", "%1" ) } }
33     end
34 end