ard.lua: Cleanup Ard.iter_formats
[libquvi-scripts.git] / share / lua / website / 101greatgoals.lua
blob30658da2585faf5ef340dfd0c1548762a950056c
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 m = '<div .- id="space4para" class="post%-type%-gvideos">'
59 ..'.-<script (.-)</script>'
60 local a = p:match(m) or error("no match: article")
62 -- Self-hosted, and they use YouTube
63 -- http://www.101greatgoals.com/gvideos/golazo-wanchope-abila-sarmiento-junin-v-merlo-2/
64 if a:match('id="jwplayer%-1%-div"') then -- get the javascript chunk for jwplayer
65 local U = require 'quvi/util'
66 local s = p:match('"file":"(.-)"') or error('no match: file location')
67 a = U.unescape(s):gsub("\\/", "/")
68 end
70 -- e.g. http://www.101greatgoals.com/gvideos/ea-sports-uefa-euro-2012-launch-trailer/
71 -- or
72 -- http://www.101greatgoals.com/gvideos/golazo-wanchope-abila-sarmiento-junin-v-merlo-2/
73 local s = a:match('http://.*youtube.com/embed/([^/"]+)')
74 or a:match('http://.*youtube.com/v/([^/"]+)')
75 or a:match('http://.*youtube.com/watch%?v=([^/"]+)')
76 or a:match('http://.*youtu%.be/([^/"]+)')
77 if s then
78 self.redirect_url = 'http://youtube.com/watch?v=' .. s
79 return self
80 end
82 -- e.g. http://www.101greatgoals.com/gvideos/leicester-1-west-ham-2/
83 -- or
84 -- http://www.101greatgoals.com/gvideos/golazo-alvaro-negredo-overhead-kick-puts-sevilla-1-0-up-at-getafe/
85 local s = a:match('http://.*dailymotion.com/embed/video/([^?"]+)')
86 or a:match('http://.*dailymotion.com/swf/video/([^?"]+)')
87 if s then
88 self.redirect_url = 'http://dailymotion.com/video/' .. s
89 return self
90 end
92 -- e.g. http://www.101greatgoals.com/gvideos/2-0-juventus-arturo-vidal-2-v-roma/
93 local s = a:match('http://.*videa.hu/flvplayer.swf%?v=([^?"]+)')
94 if s then
95 self.redirect_url = 'http://videa.hu/flvplayer.swf?v=' .. s
96 return self
97 end
99 -- e.g. http://www.101greatgoals.com/gvideos/golazo-hulk-porto-v-benfica/
100 local s = a:match('http://.*sapo.pt/([^?"/]+)')
101 if s then
102 self.redirect_url = 'http://videos.sapo.pt/' .. s
103 return self
106 -- FIXME rutube support missing
107 -- e.g. http://www.101greatgoals.com/gvideos/allesandro-diamanti-bologna-1-0-golazo-v-cagliari-2/
108 local s = a:match('http://video.rutube.ru/([^?"]+)')
109 if s then
110 self.redirect_url = 'http://video.rutube.ru/' .. s
111 return self
114 -- FIXME svt.se support missing
115 -- e.g. http://www.101greatgoals.com/gvideos/gais-2-norrkoping-0/
116 local s = a:match('http://svt%.se/embededflash/(%d+)/play%.swf')
117 if s then
118 self.redirect_url = 'http://svt.se/embededflash/' .. s .. '/play.swf'
119 return self
122 -- FIXME lamalla.tv support missing
123 -- e.g. http://www.101greatgoals.com/gvideos/golazo-bakary-espanyol-b-vs-montanesa/
125 -- FIXME indavideo.hu support missing
126 -- e.g. http://www.101greatgoals.com/gvideos/golazo-michel-bastos-lyon-v-psg-3/
128 -- FIXME xtsream.dk support missing
129 -- e.g. http://www.101greatgoals.com/gvideos/golazo-the-ball-doesnt-hit-the-floor-viktor-claesson-elfsborg-v-fc-copenhagen-1-22-mins-in/
131 -- FIXME mslsoccer.com support missing
132 -- e.g. http://www.101greatgoals.com/gvideos/thierry-henry-back-heel-assist-mehdi-ballouchy-v-montreal-impact/
134 error("FIXME: no support: Unable to determine the media host")
137 -- vim: set ts=4 sw=4 tw=72 expandtab: