3 -- Copyright (C) 2010 Lionel Elie Mamane <lionel@mamane.lu>
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
= "collegehumor.com"
30 -- Commented out due to limited hd support
31 -- r.formats = "default|best|hd"
32 r
.categories
= C
.proto_http
34 (self
.page_url
~= nil and self
.page_url
:find(r
.domain
) ~= nil)
40 self
.host_id
= "collegehumor"
42 local success
, _
, vid
=
43 self
.page_url
:find("^http://www%.collegehumor%.com/video:(%d+)")
45 if ( success
== nil ) then
46 error("expected URL beginning with 'http://collegehumor.com/video:'")
51 local page
= quvi
.fetch(self
.page_url
)
52 local _
,_
,s
= page
:find('<meta name="title" content="(.-)"')
53 self
.title
= s
or error("no match: video title")
56 quvi
.fetch("http://www.collegehumor.com/moogaloop/video:" .. vid
,
57 {fetch_type
= 'config'})
59 local _
,_
,s
= page
:find('<file>([%w%p]+)</file>')
60 local default
= s
or error("no match: default quality URL")
62 local _
,_
,s
= page
:find('<hq>([%w%p]+)</hq>')
65 self
.url
= { default
}
66 if (self
.requested_format
== "hd" or self
.requested_format
== "best") then
75 -- vim: set ts=4 sw=4 tw=72 expandtab: