2 -- Copyright (C) 2013 Toni Gundogdu <legatvs@gmail.com>
3 -- Copyright (C) 2012 Mikhail Gusarov <dottedmag@dottedmag.net>
5 -- This file is part of libquvi-scripts <http://quvi.sourceforge.net/>.
7 -- This program is free software: you can redistribute it and/or
8 -- modify it under the terms of the GNU Affero General Public
9 -- License as published by the Free Software Foundation, either
10 -- version 3 of the License, or (at your option) any later version.
12 -- This program 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
15 -- GNU Affero General Public License for more details.
17 -- You should have received a copy of the GNU Affero General
18 -- Public License along with this program. If not, see
19 -- <http://www.gnu.org/licenses/>.
22 local OTvRu
= {} -- Utility functions specific to this script
24 -- Identify the media script.
27 can_parse_url
= OTvRu
.can_parse_url(qargs
),
28 domains
= table.concat({'1tv.ru'}, ',')
32 -- Query available formats.
33 function query_formats(self
)
34 self
.formats
= 'default'
40 self
.host_id
= "1tvru"
42 self
.id
= self
.page_url
:match('fi(%d+)')
43 or self
.page_url
:match('fi=(%d+)')
44 or error("no match: media ID")
46 local p
= quvi
.fetch(self
.page_url
)
48 self
.title
= p
:match("'title': '(.-)'")
49 or error("no match: media title")
51 self
.url
= {p
:match("'file': '(.-)'")
52 or error("no match: media stream URL")}
54 self
.thumbnail_url
= p
:match('"og:image" content="(.-)"') or ''
63 function OTvRu
.can_parse_url(qargs
)
64 local U
= require
'socket.url'
65 local t
= U
.parse(qargs
.input_url
)
66 if t
and t
.scheme
and t
.scheme
:lower():match('^https?$')
67 and t
.host
and t
.host
:lower():match('1tv%.ru$')
68 and t
.path
and (t
.path
:lower():match('^/sprojects_edition/')
69 or t
.path
:lower():match('^/sprojects_utro_video/'))
77 -- vim: set ts=4 sw=4 tw=72 expandtab: