3 -- Copyright (C) 2012,2013 Toni Gundogdu <legatvs@gmail.com>
4 -- Copyright (C) 2011 Bastien Nocera <hadess@hadess.net>
6 -- This file is part of libquvi-scripts <http://quvi.sourceforge.net/>.
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
24 local Ted
= {} -- Utility functions unique to this script
26 -- Identify the script.
28 package
.path
= self
.script_dir
.. '/?.lua'
29 local C
= require
'quvi/const'
32 r
.formats
= "default|best"
33 r
.categories
= C
.proto_http
34 local U
= require
'quvi/util'
35 r
.handles
= U
.handles(self
.page_url
, {r
.domain
}, {"/talks/.+$"})
39 -- Query available formats.
40 function query_formats(self
)
41 self
.formats
= "default"
42 Ted
.is_external(self
, quvi
.fetch(self
.page_url
))
50 local p
= quvi
.fetch(self
.page_url
)
52 if Ted
.is_external(self
, p
) then return self
end
54 self
.id
= p
:match('ti:"(%d+)"') or error("no match: media ID")
56 self
.title
= p
:match('<title>(.-)%s+|') or error("no match: media title")
58 self
.thumbnail_url
= p
:match('"og:image" content="(.-)"') or ''
67 function Ted
.is_external(self
, p
)
68 self
.url
= {p
:match('(http://download.-)"') or ''}
69 if #self
.url
[1] ==0 then -- Try the first iframe
70 self
.redirect_url
= p
:match('<iframe src="(.-)"') or ''
71 if #self
.redirect_url
>0 then
74 error('no match: media stream URL')
80 -- vim: set ts=4 sw=4 tw=72 expandtab: