2 -- Copyright (C) 2013 Toni Gundogdu <legatvs@gmail.com>
3 -- Copyright (C) 2012 quvi project
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 -- Hundred and One Great Goals (aggregator)
23 local HaOgg
= {} -- Utility functions specific to this script
25 -- Identify the media script.
28 can_parse_url
= HaOgg
.can_parse_url(qargs
),
29 domains
= table.concat({'101greatgoals.com'}, ',')
33 -- Parse the media properties.
35 local p
= quvi
.http
.fetch(qargs
.input_url
).data
37 qargs
.goto_url
= HaOgg
.chk_self_hosted(p
) or HaOgg
.chk_embedded(p
)
38 or error('unable to determine media source')
47 function HaOgg
.can_parse_url(qargs
)
48 local U
= require
'socket.url'
49 local t
= U
.parse(qargs
.input_url
)
50 if t
and t
.scheme
and t
.scheme
:lower():match('^http$')
51 and t
.host
and t
.host
:lower():match('101greatgoals%.com$')
52 and t
.path
and t
.path
:lower():match('^/gvideos/.+/$')
60 function HaOgg
.chk_self_hosted(p
)
62 -- Previously referred to as the "self-hosted" media, although according
63 -- to the old notes, these were typically hosted by YouTube.
64 -- http://is.gd/EKKPy2
66 -- 2013-05-05: The contents of the URL no longer seems to contain the
67 -- "file" value, see chk_embedded for notes; keep this
68 -- function around for now
70 local d
= p
:match('%.setup%((.-)%)')
72 local s
= d
:match('"file":"(.-)"') or error('no match: file')
74 error('empty media URL ("file")')
76 local U
= require
'quvi/util'
77 return (U
.slash_unescape(U
.unescape(s
)))
81 function HaOgg
.chk_embedded(p
)
83 -- 2013-05-05: Most of the content appears to be embedded from elsewhere
85 -- Instead of trying to check for each, parse the likely embedded source
86 -- and pass it back to libquvi to find a media script that accepts the
87 -- parsed (embedded) media URL.
89 local s
= p
:match('class="post%-type%-gvideos">(.-)</')
90 or p
:match('id="jwplayer%-1">(.-)</>')
91 or error('unable to determine embedded source')
93 s
= s
:match('value="(.-)"') or s
:match('src="(.-)"')
95 local U
= require
'socket.url'
97 if not t
.scheme
then -- Make sure the URL has a scheme.
103 -- vim: set ts=2 sw=2 tw=72 expandtab: