Added 101greatgoals.lua
[libquvi-scripts.git] / share / lua / website / 101greatgoals.lua
blobd0bf490f6c11027904b4123ff515851c76e0d4a1
2 -- libquvi-scripts
3 -- Copyright (C) 2012 quvi project
4 --
5 -- This file is part of libquvi-scripts <http://quvi.sourceforge.net/>.
6 --
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
20 -- 02110-1301 USA
23 -- Hundred and One Great Goals
24 local HaOgg = {} -- Utility functions specific to this script
26 -- Identify the script.
27 function ident(self)
28 package.path = self.script_dir .. '/?.lua'
29 local C = require 'quvi/const'
30 local r = {}
31 r.domain = "101greatgoals%.com"
32 r.formats = "default"
33 r.categories = C.proto_http
34 local U = require 'quvi/util'
35 r.handles = U.handles(self.page_url, {r.domain}, {"/gvideos/.+"})
36 return r
37 end
39 -- Query available formats.
40 function query_formats(self)
41 self.formats = 'default'
42 return HaOgg.check_external_content(self)
43 end
45 -- Parse media URL.
46 function parse(self)
47 self.host_id = "101greatgoals"
48 return HaOgg.check_external_content(self)
49 end
52 -- Utility functions
55 function HaOgg.check_external_content(self)
56 local p = quvi.fetch(self.page_url)
58 local a = p:match('<div id="space4para" class="post%-type%-gvideos">(.-)</div>')
59 or error("no match: article")
61 -- Self-hosted, and they use YouTube
62 -- http://www.101greatgoals.com/gvideos/golazo-wanchope-abila-sarmiento-junin-v-merlo-2/
63 if a:match('id="jwplayer%-1%-div"') then -- get the javascript chunk for jwplayer
64 local U = require 'quvi/util'
65 local s = p:match('"file":"(.-)"') or error('no match: file location')
66 a = U.unescape(s):gsub("\\/", "/")
67 end
69 -- e.g. http://www.101greatgoals.com/gvideos/ea-sports-uefa-euro-2012-launch-trailer/
70 -- or
71 -- http://www.101greatgoals.com/gvideos/golazo-wanchope-abila-sarmiento-junin-v-merlo-2/
72 local s = a:match('http://.*youtube.com/embed/([^/"]+)')
73 or a:match('http://.*youtube.com/v/([^/"]+)')
74 or a:match('http://.*youtube.com/watch%?v=([^/"]+)')
75 or a:match('http://.*youtu%.be/([^/"]+)')
76 if s then
77 self.redirect_url = 'http://youtube.com/watch?v=' .. s
78 return self
79 end
81 -- e.g. http://www.101greatgoals.com/gvideos/leicester-1-west-ham-2/
82 -- or
83 -- http://www.101greatgoals.com/gvideos/golazo-alvaro-negredo-overhead-kick-puts-sevilla-1-0-up-at-getafe/
84 local s = a:match('http://.*dailymotion.com/embed/video/([^?"]+)')
85 or a:match('http://.*dailymotion.com/swf/video/([^?"]+)')
86 if s then
87 self.redirect_url = 'http://dailymotion.com/video/' .. s
88 return self
89 end
91 -- e.g. http://www.101greatgoals.com/gvideos/2-0-juventus-arturo-vidal-2-v-roma/
92 local s = a:match('http://.*videa.hu/flvplayer.swf%?v=([^?"]+)')
93 if s then
94 self.redirect_url = 'http://videa.hu/flvplayer.swf?v=' .. s
95 return self
96 end
98 -- e.g. http://www.101greatgoals.com/gvideos/golazo-hulk-porto-v-benfica/
99 local s = a:match('http://.*sapo.pt/([^?"/]+)')
100 if s then
101 self.redirect_url = 'http://videos.sapo.pt/' .. s
102 return self
105 -- FIXME rutube support missing
106 -- e.g. http://www.101greatgoals.com/gvideos/allesandro-diamanti-bologna-1-0-golazo-v-cagliari-2/
107 local s = a:match('http://video.rutube.ru/([^?"]+)')
108 if s then
109 self.redirect_url = 'http://video.rutube.ru/' .. s
110 return self
113 -- FIXME svt.se support missing
114 -- e.g. http://www.101greatgoals.com/gvideos/gais-2-norrkoping-0/
115 local s = a:match('http://svt%.se/embededflash/(%d+)/play%.swf')
116 if s then
117 self.redirect_url = 'http://svt.se/embededflash/' .. s .. '/play.swf'
118 return self
121 -- FIXME lamalla.tv support missing
122 -- e.g. http://www.101greatgoals.com/gvideos/golazo-bakary-espanyol-b-vs-montanesa/
124 -- FIXME indavideo.hu support missing
125 -- e.g. http://www.101greatgoals.com/gvideos/golazo-michel-bastos-lyon-v-psg-3/
127 -- FIXME xtsream.dk support missing
128 -- e.g. http://www.101greatgoals.com/gvideos/golazo-the-ball-doesnt-hit-the-floor-viktor-claesson-elfsborg-v-fc-copenhagen-1-22-mins-in/
130 -- FIXME mslsoccer.com support missing
131 -- e.g. http://www.101greatgoals.com/gvideos/thierry-henry-back-heel-assist-mehdi-ballouchy-v-montreal-impact/
133 error("FIXME: no support: Unable to determine the media host")
136 -- vim: set ts=4 sw=4 tw=72 expandtab: