]> git.sesse.net Git - vlc/blob - share/lua/playlist/canalplus.lua
Use var_InheritString for --decklink-video-connection.
[vlc] / share / lua / playlist / canalplus.lua
1 --[[
2  $Id: $
3
4  Copyright (c) 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" and string.match( vlc.path, "www.canalplus.fr" )
24 end
25
26 -- Parse function.
27 function parse()
28     p = {}
29     --vlc.msg.dbg( vlc.path )
30     if string.match( vlc.path, "www.canalplus.fr/.*%?pid=.*" )
31     then -- This is the HTML page's URL
32         local _,_,pid = string.find( vlc.path, "pid(%d-)%-" )
33         local id, name, description, arturl
34         while true do
35             -- Try to find the video's title
36             local line = vlc.readline()
37             if not line then break end
38             -- vlc.msg.dbg( line )
39             if string.match( line, "aVideos" ) then
40                 if string.match( line, "CONTENT_ID.*=" ) then
41                     _,_,id = string.find( line, "\"(.-)\"" )
42                 elseif string.match( line, "CONTENT_VNC_TITRE" ) then
43                     _,_,arturl = string.find( line, "src=\"(.-)\"" )
44                     _,_,name = string.find( line, "title=\"(.-)\"" )
45                 elseif string.match( line, "CONTENT_VNC_DESCRIPTION" ) then
46                     _,_,description = string.find( line, "\"(.-)\"" )
47                 end
48                 if id and string.match( line, "new Array" ) then
49                     add_item( p, id, name, description, arturl )
50                     id = nil
51                     name = nil
52                     arturl = nil
53                     description = nil
54                 end
55             end
56         end
57         if id then
58             add_item( p, id, name, description, arturl )
59         end
60         return p
61     elseif string.match( vlc.path, "embed%-video%-player" ) then
62         while true do
63             local line = vlc.readline()
64             if not line then break end
65             --vlc.msg.dbg( line )
66             if string.match( line, "<hi" ) then
67                 local _,_,path = string.find( line, "%[(http.-)%]" )
68                 return { { path = path } }
69             end
70         end
71     end
72 end
73
74 function get_url_param( url, name )
75     local _,_,ret = string.find( url, "[&?]"..name.."=([^&]*)" )
76     return ret
77 end
78
79 function add_item( p, id, name, description, arturl )
80     --[[vlc.msg.dbg( "id: " .. tostring(id) )
81     vlc.msg.dbg( "name: " .. tostring(name) )
82     vlc.msg.dbg( "arturl: " .. tostring(arturl) )
83     vlc.msg.dbg( "description: " .. tostring(description) )
84     --]]
85     --local path = "http://www.canalplus.fr/flash/xml/configuration/configuration-embed-video-player.php?xmlParam="..id.."-"..get_url_param(vlc.path,"pid")
86     local path = "http://www.canalplus.fr/flash/xml/module/embed-video-player/embed-video-player.php?video_id="..id.."&pid="..get_url_param(vlc.path,"pid")
87     table.insert( p, { path = path; name = name; description = description; arturl = arturl } )
88 end