3 -- Copyright (C) 2010 Toni Gundogdu <legatvs@gmail.com>
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 -- Identify the script.
25 package
.path
= self
.script_dir
.. '/?.lua'
26 local C
= require
'quvi/const'
28 r
.domain
= "vimeo.com"
29 r
.formats
= "default|best|hd"
30 r
.categories
= C
.proto_http
32 (self
.page_url
~= nil and self
.page_url
:find(r
.domain
) ~= nil)
38 self
.host_id
= "vimeo"
40 is_player
, _
, self
.id
=
41 self
.page_url
:find("^http://player.vimeo.com/video/(%d+)")
43 if ( is_player
~= nil ) then
44 self
.page_url
= "http://vimeo.com/" .. vid
47 if (self
.id
== nil) then
48 local _
,_
,s
= self
.page_url
:find('vimeo.com/(%d+)')
52 if (self
.id
== nil) then error ("no match: video") end
54 local config_url
= "http://vimeo.com/moogaloop/load/clip:" .. self
.id
55 local config
= quvi
.fetch (config_url
, {fetch_type
= 'config'})
57 local _
,_
,s
= config
:find("<caption>(.-)</")
58 self
.title
= s
or error ("no match: video title")
60 local _
,_
,s
= config
:find("<request_signature>(.-)</")
61 local sign
= s
or error ("no match: request signature")
63 local _
,_
,s
= config
:find("<request_signature_expires>(.-)</")
64 local exp = s
or error ("no match: request signature expires")
66 local _
,_
,s
= config
:find("<hd_button>(%d)</")
67 local hd_button
= s
or error ("no match: hd button")
69 local q
= "sd" -- Same as "default".
70 if (self
.requested_format
== "hd" or self
.requested_format
== "best") then
71 if (hd_button
== "1") then
77 string.format("http://vimeo.com/moogaloop/play/clip:%s/%s/%s/?q=%s",
78 self
.id
, sign
, exp, q
)
84 -- vim: set ts=4 sw=4 tw=72 expandtab: