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.
24function probe()
25    local path = vlc.path:gsub("^www%.", "")
26    return vlc.access == "http"
27        and string.match( path, "^lelombrik%.net/videos" )
28end
29
30-- Parse function.
31function parse()
32    while true do
33        line = vlc.readline()
34        if not line then
35            vlc.msg.err("Couldn't extract the video URL from lelombrik")
36            return { }
37        end
38
39        if string.match( line, "id=\"nom_fichier\">" ) then
40            title = string.gsub( line, ".*\"nom_fichier\">([^<]*).*", "%1" )
41            if title then
42                title = vlc.strings.from_charset( "ISO_8859-1", title )
43            end
44        elseif string.match( line, "'file'" ) then
45            _,_,path = string.find( line, "'file', *'([^']*)")
46        elseif string.match( line, "flashvars=" ) then
47            path = string.gsub( line, "flashvars=.*&file=([^&]*).*", "%1" )
48            arturl = string.gsub( line, "flashvars=.*&image=([^&]*).*", "%1" )
49        elseif string.match( line, "'image'" ) then
50            _,_,arturl = string.find( line, "'image', *'([^']*)")
51        end
52
53        if path and arturl and title then
54            return { { path = path; arturl = arturl; title = title } }
55        end
56    end
57end
58