2 -- Copyright (C) 2013 Toni Gundogdu <legatvs@gmail.com>
3 -- Copyright (C) 2012 Tzafrir Cohen <tzafrir@cohens.org.il>
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 Tapuz
= {} -- Utility functions unique to this script
24 -- Identify the media script.
27 can_parse_url
= Tapuz
.can_parse_url(qargs
),
28 domains
= table.concat({'flix.tapuz.co.il'}, ',')
32 -- Parse the media properties.
35 -- Make mandatory: the ID required to fetch the XML data
36 qargs
.id
= qargs
.input_url
:match('/v/watch%-(%d+)%-.*%.html')
38 qargs
.id
= qargs
.input_url
:match('/showVideo%.asp%?m=(%d+)')
39 or error("no match: media ID")
43 'http://flix.tapuz.co.il/v/Handlers/XmlForPlayer.ashx?mediaid=',
44 qargs
.id
, '&playerOptions=0|1|grey|large|0&mako=0'
47 local d
= quvi
.http
.fetch(table.concat(t
)).data
48 local L
= require
'quvi/lxph'
50 local X
= require
'lxp.lom'
53 qargs
.duration_ms
= tonumber(L
.find_first_tag(x
, 'duration')[1] or 0)*1000
55 qargs
.thumb_url
= L
.find_first_tag(x
, 'thumbUrl')[1]
57 qargs
.title
= L
.find_first_tag(x
, 'title')[1]
59 qargs
.streams
= Tapuz
.iter_streams(L
, x
)
68 function Tapuz
.can_parse_url(qargs
)
69 local U
= require
'socket.url'
70 local t
= U
.parse(qargs
.input_url
)
71 if t
and t
.scheme
and t
.scheme
:lower():match('^http$')
72 and t
.host
and t
.host
:lower():match('flix%.tapuz%.co%.il$')
73 and t
.path
and (t
.path
:lower():match('^/v/watch%-.-%.html$')
74 or t
.path
:lower():match('/showVideo%.asp%?m=%d+'))
82 function Tapuz
.iter_streams(L
, x
)
83 local u
= L
.find_first_tag(x
, 'videoUrl')[1]
84 or error('no match: media stream URL')
85 local S
= require
'quvi/stream'
86 return {S
.stream_new(u
)}
89 -- vim: set ts=2 sw=2 tw=72 expandtab: