3 -- Copyright (C) 2010,2011 quvi project
5 -- This file is part of quvi <http://quvi.sourceforge.net/>.
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
23 -- Note: Video URL verification which is done after parsing the details
24 -- in this script *will* fail if you are using a proxy that omits the
27 -- Identify the script.
29 package
.path
= self
.script_dir
.. '/?.lua'
30 local C
= require
'quvi/const'
32 r
.domain
= "video.globo.com"
34 r
.categories
= C
.proto_http
35 local U
= require
'quvi/util'
36 r
.handles
= U
.handles(self
.page_url
, {r
.domain
}, {"/Videos/"})
40 -- Query available formats.
41 function query_formats(self
)
42 self
.formats
= 'default'
48 self
.host_id
= "globo"
49 local page
= quvi
.fetch(self
.page_url
)
51 local _
,_
,s
= page
:find('midiaId: (.-),')
52 self
.id
= s
or error ("no match: media id")
54 local _
,_
,s
= page
:find('<title>.*-.*- (.-)</title>')
55 self
.title
= s
or error ("no match: media title")
58 "http://playervideo.globo.com/webmedia/GMCPlayListASX"
59 .. "?flash=true&midiaId="
62 -- Unless user-agent is set here to 'iphone', URL verification
63 -- *will* fail (HTTP/403) later. Fetching below itself does not
64 -- need it, just the URL verification. We set it here to be safe.
66 local opts
= {fetch_type
= 'config', user_agent
= 'iphone'}
67 local xml
= quvi
.fetch(config_url
, opts
)
68 local _
,_
,d
,s
= xml
:find('<video duration="(.-)" src="(.-)%?')
69 self
.duration
= tonumber(d
) or 0
70 self
.url
= {s
or error('no match: media url')}
75 -- vim: set ts=4 sw=4 tw=72 expandtab: