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