3 -- Copyright (C) 2013 Toni Gundogdu <legatvs@gmail.com>
4 -- Copyright (C) 2012 quvi project
6 -- This file is part of libquvi-scripts <http://quvi.sourceforge.net/>.
8 -- This library is free software; you can redistribute it and/or
9 -- modify it under the terms of the GNU Lesser General Public
10 -- License as published by the Free Software Foundation; either
11 -- version 2.1 of the License, or (at your option) any later version.
13 -- This library is distributed in the hope that it will be useful,
14 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
15 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 -- Lesser General Public License for more details.
18 -- You should have received a copy of the GNU Lesser General Public
19 -- License along with this library; if not, write to the Free Software
20 -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 -- Hundred and One Great Goals (aggregator)
25 local HaOgg
= {} -- Utility functions specific to this script
27 -- Identify the script.
29 package
.path
= self
.script_dir
.. '/?.lua'
30 local C
= require
'quvi/const'
32 r
.domain
= "101greatgoals%.com"
34 r
.categories
= C
.proto_http
35 local U
= require
'quvi/util'
36 r
.handles
= U
.handles(self
.page_url
, {r
.domain
}, {"/gvideos/.+/$"})
40 -- Query available formats.
41 function query_formats(self
)
42 self
.formats
= 'default'
43 return HaOgg
.chk_ext_content(self
)
48 self
.host_id
= "101greatgoals"
49 return HaOgg
.chk_ext_content(self
)
56 function HaOgg
.chk_self_hosted(p
)
58 -- Previously referred to as the "self-hosted" media, although according
59 -- to the old notes, these were typically hosted by YouTube.
60 -- http://is.gd/EKKPy2
62 -- 2013-05-05: The contents of the URL no longer seems to contain the
63 -- "file" value, see chk_embedded for notes; keep this
64 -- function around for now
66 local d
= p
:match('%.setup%((.-)%)')
68 local s
= d
:match('"file":"(.-)"') or error('no match: file')
70 error('empty media URL ("file")')
72 local U
= require
'quvi/util'
73 return (U
.slash_unescape(U
.unescape(s
)))
77 function HaOgg
.chk_embedded(p
)
79 -- 2013-05-05: Most of the content appears to be embedded from elsewhere
81 -- Instead of trying to check for each, parse the likely embedded source
82 -- and pass it back to libquvi to find a media script that accepts the
83 -- parsed (embedded) media URL.
85 -- NOTE: This means that those media scripts must unwrangle the embedded
86 -- media URLs passed from this script
88 local s
= p
:match('class="post%-type%-gvideos">(.-)</')
89 or p
:match('id="jwplayer%-1">(.-)</>')
90 or error('unable to determine embedded source')
91 return s
:match('value="(.-)"') or s
:match('src="(.-)"')
94 function HaOgg
.chk_ext_content(self
)
95 local p
= quvi
.fetch(self
.page_url
)
97 self
.redirect_url
= HaOgg
.chk_self_hosted(p
) or HaOgg
.chk_embedded(p
)
98 or error('unable to determine media source')
103 -- vim: set ts=4 sw=4 tw=72 expandtab: