FIX: website/cbsnews: Adapt to website changes
[libquvi-scripts.git] / share / lua / website / cbsnews.lua
blob5e39a7d94a69a40b5d4e68ba7efd19a236f6d0f5
2 -- libquvi-scripts
3 -- Copyright (C) 2010-2012,2013 Toni Gundogdu <legatvs@gmail.com>
4 --
5 -- This file is part of libquvi-scripts <http://quvi.sourceforge.net/>.
6 --
7 -- This library is free software; you can redistribute it and/or
8 -- modify it under the terms of the GNU Lesser General Public
9 -- License as published by the Free Software Foundation; either
10 -- version 2.1 of the License, or (at your option) any later version.
12 -- This library is distributed in the hope that it will be useful,
13 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
14 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 -- Lesser General Public License for more details.
17 -- You should have received a copy of the GNU Lesser General Public
18 -- License along with this library; if not, write to the Free Software
19 -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 -- 02110-1301 USA
23 local CBSNews = {} -- Utility functions unique to this script
25 -- Identify the script.
26 function ident(self)
27 package.path = self.script_dir .. '/?.lua'
28 local C = require 'quvi/const'
29 local U = require 'quvi/util'
30 local B = require 'quvi/bit'
31 local d = 'cbsnews%.com'
32 local r = {
33 handles = U.handles(self.page_url, {d}, {"/videos/.-/?"}),
34 categories = B.bit_or(C.proto_http, C.proto_rtmp),
35 formats = 'default',
36 domain = d
38 return r
39 end
41 -- Query available formats.
42 function query_formats(self)
43 self.formats = 'default'
44 return self
45 end
47 -- Parse media URL.
48 function parse(self)
49 self.host_id = "cbsnews"
51 local p = quvi.fetch(self.page_url)
53 local d = p:match("data%-cbsvideoui%-options='(.-)'")
54 or error('no match: player options')
56 local U = require 'quvi/util'
58 self.thumbnail_url =
59 U.slash_unescape(d:match('"image":{"path":"(.-)"') or '')
61 self.title = d:match('"title":"(.-)"')
62 or error('no match: media ID')
64 self.id = d:match('"id":"(.-)"')
65 or error('no match: media ID')
67 local u = d:match('"desktop":.-"uri":"(.-)"')
68 or error('no match: media stream URL')
70 self.url = {U.slash_unescape(u)}
72 return self
73 end
75 -- vim: set ts=4 sw=4 tw=72 expandtab: