FIX: website/publicsenat: Reimpl. support
[libquvi-scripts.git] / share / lua / website / publicsenat.lua
blob403f6c3e25a8115df813005e805c03df16cebb3e
2 -- libquvi-scripts
3 -- Copyright (C) 2013 Toni Gundogdu <legatvs@gmail.com>
4 -- Copyright (C) 2010,2012 Raphaƫl Droz.
5 --
6 -- This file is part of libquvi-scripts <http://quvi.googlecode.com/>.
7 --
8 -- This library is free software; you can redistribute it and/or
9 -- modify it under the terms of the GNU Lesser General Public
10 -- License as published by the Free Software Foundation; either
11 -- version 2.1 of the License, or (at your option) any later version.
13 -- This library 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 GNU
16 -- Lesser General Public License for more details.
18 -- You should have received a copy of the GNU Lesser General Public
19 -- License along with this library; if not, write to the Free Software
20 -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 -- 02110-1301 USA
23 -- Identify the script.
24 function ident(self)
25 package.path = self.script_dir .. '/?.lua'
26 local C = require 'quvi/const'
27 local r = {}
28 r.domain = "publicsenat%.fr"
29 r.formats = "default"
30 r.categories = C.proto_http
31 local U = require 'quvi/util'
32 r.handles = U.handles(self.page_url, {r.domain}, {"/vod/.-/%d+$"})
33 return r
34 end
36 -- Query available formats.
37 function query_formats(self)
38 self.formats = 'default'
39 return self
40 end
42 -- Parse media URL.
43 function parse(self)
44 self.host_id = "publicsenat"
46 self.id = self.page_url:match("/vod/.-/(%d+)$")
47 or error('no match: media ID')
49 local p = quvi.fetch(self.page_url)
51 self.title = p:match('<title>(.-)%s+%|')
52 or error("no match: media title")
54 local u = p:match('id="dmcloudUrlEmissionSelect" value="(.-)"')
55 or error('no match: emission URL')
57 local e = quvi.fetch(u, {fetch_type='config'})
59 local d = e:match('info = (.-);')
60 or error('no match: info')
62 self.thumbnail_url = d:match('"thumbnail_url": "(.-)"') or ''
64 self.url = {d:match('"mp4_url": "(.-)"')
65 or error('no match: media stream URL')}
67 return self
68 end
70 -- vim: set ts=4 sw=4 tw=72 expandtab: