]> git.sesse.net Git - vlc/blob - share/lua/playlist/metacafe.lua
Don't leak every https parameters.
[vlc] / share / lua / playlist / metacafe.lua
1 --[[
2  $Id$
3
4  Copyright © 2007 the VideoLAN team
5
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  GNU General Public License for more details.
15
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 --]]
20
21 -- Probe function.
22 function probe()
23     return vlc.access == "http"
24         and string.match( vlc.path, "metacafe.com" ) 
25         and (  string.match( vlc.path, "watch/" )
26             or string.match( vlc.path, "mediaURL=" ) )
27 end
28
29 -- Parse function.
30 function parse()
31     if string.match( vlc.path, "watch/" )
32     then -- This is the HTML page's URL
33         while true do
34             -- Try to find the video's title
35             line = vlc.readline()
36             if not line then break end
37             if string.match( line, "<meta name=\"title\"" ) then
38                 name = string.gsub( line, "^.*content=\"Metacafe %- ([^\"]*).*$", "%1" )  
39             end
40             if string.match( line, "<meta name=\"description\"" ) then
41                 description = string.gsub( line, "^.*content=\"([^\"]*).*$", "%1" )  
42             end
43             if string.match( line, "<link rel=\"image_src\"" ) then
44                 arturl = string.gsub( line, "^.*href=\"([^\"]*)\".*$", "%1" )
45             end
46             if name and description and arturl then break end
47         end
48         return { { path = string.gsub( vlc.path, "^.*watch/(.*[^/])/?$", "http://www.metacafe.com/fplayer/%1.swf" ); name = name; description = description; arturl = arturl;  } }
49     else -- This is the flash player's URL
50         return { { path = string.gsub( vlc.path, "^.*mediaURL=([^&]*).*$", "%1" ) } }
51     end
52 end