footballdata-12xpert 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +3 -0
- data/Manifest.txt +13 -0
- data/README.md +306 -0
- data/Rakefile +31 -0
- data/lib/footballdata-12xpert.rb +168 -0
- data/lib/footballdata-12xpert/config.rb +420 -0
- data/lib/footballdata-12xpert/convert.rb +206 -0
- data/lib/footballdata-12xpert/download.rb +92 -0
- data/lib/footballdata-12xpert/version.rb +22 -0
- data/lib/footballdata/12xpert.rb +6 -0
- data/test/helper.rb +10 -0
- data/test/test_download.rb +27 -0
- data/test/test_import.rb +33 -0
- metadata +141 -0
@@ -0,0 +1,420 @@
|
|
1
|
+
|
2
|
+
module Footballdata12xpert
|
3
|
+
|
4
|
+
SOURCES_I =
|
5
|
+
{
|
6
|
+
eng: [[ '2020/21', %w(E0 E1 E2 E3 EC) ],
|
7
|
+
[ '2019/20', %w(E0 E1 E2 E3 EC) ],
|
8
|
+
[ '2018/19', %w(E0 E1 E2 E3 EC) ],
|
9
|
+
[ '2017/18', %w(E0 E1 E2 E3 EC) ],
|
10
|
+
[ '2016/17', %w(E0 E1 E2 E3 EC) ],
|
11
|
+
[ '2015/16', %w(E0 E1 E2 E3 EC) ],
|
12
|
+
[ '2014/15', %w(E0 E1 E2 E3 EC) ],
|
13
|
+
[ '2013/14', %w(E0 E1 E2 E3 EC) ],
|
14
|
+
[ '2012/13', %w(E0 E1 E2 E3 EC) ],
|
15
|
+
[ '2011/12', %w(E0 E1 E2 E3 EC) ],
|
16
|
+
[ '2010/11', %w(E0 E1 E2 E3 EC) ],
|
17
|
+
[ '2009/10', %w(E0 E1 E2 E3 EC) ],
|
18
|
+
[ '2008/09', %w(E0 E1 E2 E3 EC) ],
|
19
|
+
[ '2007/08', %w(E0 E1 E2 E3 EC) ],
|
20
|
+
[ '2006/07', %w(E0 E1 E2 E3 EC) ],
|
21
|
+
[ '2005/06', %w(E0 E1 E2 E3 EC) ],
|
22
|
+
[ '2004/05', %w(E0 E1 E2 E3) ],
|
23
|
+
[ '2003/04', %w(E0 E1 E2 E3) ],
|
24
|
+
[ '2002/03', %w(E0 E1 E2 E3) ],
|
25
|
+
[ '2001/02', %w(E0 E1 E2 E3) ],
|
26
|
+
[ '2000/01', %w(E0 E1 E2 E3) ],
|
27
|
+
[ '1999/00', %w(E0 E1 E2 E3) ],
|
28
|
+
[ '1998/99', %w(E0 E1 E2 E3) ],
|
29
|
+
[ '1997/98', %w(E0 E1 E2 E3) ],
|
30
|
+
[ '1996/97', %w(E0 E1 E2 E3) ],
|
31
|
+
[ '1995/96', %w(E0 E1 E2 E3) ],
|
32
|
+
[ '1994/95', %w(E0 E1 E2 E3) ],
|
33
|
+
[ '1993/94', %w(E0 E1 E2 E3) ],
|
34
|
+
],
|
35
|
+
sco: [[ '2020/21', %w(SC0 SC1 SC2 SC3) ],
|
36
|
+
[ '2019/20', %w(SC0 SC1 SC2 SC3) ],
|
37
|
+
[ '2018/19', %w(SC0 SC1 SC2 SC3) ],
|
38
|
+
[ '2017/18', %w(SC0 SC1 SC2 SC3) ],
|
39
|
+
[ '2016/17', %w(SC0 SC1 SC2 SC3) ],
|
40
|
+
[ '2015/16', %w(SC0 SC1 SC2 SC3) ],
|
41
|
+
[ '2014/15', %w(SC0 SC1 SC2 SC3) ],
|
42
|
+
[ '2013/14', %w(SC0 SC1 SC2 SC3) ],
|
43
|
+
[ '2012/13', %w(SC0 SC1 SC2 SC3) ],
|
44
|
+
[ '2011/12', %w(SC0 SC1 SC2 SC3) ],
|
45
|
+
[ '2010/11', %w(SC0 SC1 SC2 SC3) ],
|
46
|
+
[ '2009/10', %w(SC0 SC1 SC2 SC3) ],
|
47
|
+
[ '2008/09', %w(SC0 SC1 SC2 SC3) ],
|
48
|
+
[ '2007/08', %w(SC0 SC1 SC2 SC3) ],
|
49
|
+
[ '2006/07', %w(SC0 SC1 SC2 SC3) ],
|
50
|
+
[ '2005/06', %w(SC0 SC1 SC2 SC3) ],
|
51
|
+
[ '2004/05', %w(SC0 SC1 SC2 SC3) ],
|
52
|
+
[ '2003/04', %w(SC0 SC1 SC2 SC3) ],
|
53
|
+
[ '2002/03', %w(SC0 SC1 SC2 SC3) ],
|
54
|
+
[ '2001/02', %w(SC0 SC1 SC2 SC3) ],
|
55
|
+
[ '2000/01', %w(SC0 SC1 SC2 SC3) ],
|
56
|
+
[ '1999/00', %w(SC0 SC1 SC2 SC3) ],
|
57
|
+
[ '1998/99', %w(SC0 SC1 SC2 SC3) ],
|
58
|
+
[ '1997/98', %w(SC0 SC1 SC2 SC3) ],
|
59
|
+
[ '1996/97', %w(SC0 SC1) ],
|
60
|
+
[ '1995/96', %w(SC0 SC1) ],
|
61
|
+
[ '1994/95', %w(SC0 SC1) ]],
|
62
|
+
de: [[ '2020/21', %w(D1 D2) ],
|
63
|
+
[ '2019/20', %w(D1 D2) ],
|
64
|
+
[ '2018/19', %w(D1 D2) ],
|
65
|
+
[ '2017/18', %w(D1 D2) ],
|
66
|
+
[ '2016/17', %w(D1 D2) ],
|
67
|
+
[ '2015/16', %w(D1 D2) ],
|
68
|
+
[ '2014/15', %w(D1 D2) ],
|
69
|
+
[ '2013/14', %w(D1 D2) ],
|
70
|
+
[ '2012/13', %w(D1 D2) ],
|
71
|
+
[ '2011/12', %w(D1 D2) ],
|
72
|
+
[ '2010/11', %w(D1 D2) ],
|
73
|
+
[ '2009/10', %w(D1 D2) ],
|
74
|
+
[ '2008/09', %w(D1 D2) ],
|
75
|
+
[ '2007/08', %w(D1 D2) ],
|
76
|
+
[ '2006/07', %w(D1 D2) ],
|
77
|
+
[ '2005/06', %w(D1 D2) ],
|
78
|
+
[ '2004/05', %w(D1 D2) ],
|
79
|
+
[ '2003/04', %w(D1 D2) ],
|
80
|
+
[ '2002/03', %w(D1 D2) ],
|
81
|
+
[ '2001/02', %w(D1 D2) ],
|
82
|
+
[ '2000/01', %w(D1 D2) ],
|
83
|
+
[ '1999/00', %w(D1 D2) ],
|
84
|
+
[ '1998/99', %w(D1 D2) ],
|
85
|
+
[ '1997/98', %w(D1 D2) ],
|
86
|
+
[ '1996/97', %w(D1 D2) ],
|
87
|
+
[ '1995/96', %w(D1 D2) ],
|
88
|
+
[ '1994/95', %w(D1 D2) ],
|
89
|
+
[ '1993/94', %w(D1 D2) ]],
|
90
|
+
it: [[ '2020-21', %w(I1 I2) ],
|
91
|
+
[ '2019-20', %w(I1 I2) ],
|
92
|
+
[ '2018-19', %w(I1 I2) ],
|
93
|
+
[ '2017-18', %w(I1 I2) ],
|
94
|
+
[ '2016-17', %w(I1 I2) ],
|
95
|
+
[ '2015-16', %w(I1 I2) ],
|
96
|
+
[ '2014-15', %w(I1 I2) ],
|
97
|
+
[ '2013-14', %w(I1 I2) ],
|
98
|
+
[ '2012-13', %w(I1 I2) ],
|
99
|
+
[ '2011-12', %w(I1 I2) ],
|
100
|
+
[ '2010-11', %w(I1 I2) ],
|
101
|
+
[ '2009-10', %w(I1 I2) ],
|
102
|
+
[ '2008-09', %w(I1 I2) ],
|
103
|
+
[ '2007-08', %w(I1 I2) ],
|
104
|
+
[ '2006-07', %w(I1 I2) ],
|
105
|
+
[ '2005-06', %w(I1 I2) ],
|
106
|
+
[ '2004-05', %w(I1 I2) ],
|
107
|
+
[ '2003-04', %w(I1 I2) ],
|
108
|
+
[ '2002-03', %w(I1 I2) ],
|
109
|
+
[ '2001-02', %w(I1 I2) ],
|
110
|
+
[ '2000-01', %w(I1 I2) ],
|
111
|
+
[ '1999-00', %w(I1 I2) ],
|
112
|
+
[ '1998-99', %w(I1 I2) ],
|
113
|
+
[ '1997-98', %w(I1 I2) ],
|
114
|
+
[ '1996-97', %w(I1) ],
|
115
|
+
[ '1995-96', %w(I1) ],
|
116
|
+
[ '1994-95', %w(I1) ],
|
117
|
+
[ '1993-94', %w(I1) ]],
|
118
|
+
es: [[ '2020-21', %w(SP1 SP2) ],
|
119
|
+
[ '2019-20', %w(SP1 SP2) ],
|
120
|
+
[ '2018-19', %w(SP1 SP2) ],
|
121
|
+
[ '2017-18', %w(SP1 SP2) ],
|
122
|
+
[ '2016-17', %w(SP1 SP2) ],
|
123
|
+
[ '2015-16', %w(SP1 SP2) ],
|
124
|
+
[ '2014-15', %w(SP1 SP2) ],
|
125
|
+
[ '2013-14', %w(SP1 SP2) ],
|
126
|
+
[ '2012-13', %w(SP1 SP2) ],
|
127
|
+
[ '2011-12', %w(SP1 SP2) ],
|
128
|
+
[ '2010-11', %w(SP1 SP2) ],
|
129
|
+
[ '2009-10', %w(SP1 SP2) ],
|
130
|
+
[ '2008-09', %w(SP1 SP2) ],
|
131
|
+
[ '2007-08', %w(SP1 SP2) ],
|
132
|
+
[ '2006-07', %w(SP1 SP2) ],
|
133
|
+
[ '2005-06', %w(SP1 SP2) ],
|
134
|
+
[ '2004-05', %w(SP1 SP2) ],
|
135
|
+
[ '2003-04', %w(SP1 SP2) ],
|
136
|
+
[ '2002-03', %w(SP1 SP2) ],
|
137
|
+
[ '2001-02', %w(SP1 SP2) ],
|
138
|
+
[ '2000-01', %w(SP1 SP2) ],
|
139
|
+
[ '1999-00', %w(SP1 SP2) ],
|
140
|
+
[ '1998-99', %w(SP1 SP2) ],
|
141
|
+
[ '1997-98', %w(SP1 SP2) ],
|
142
|
+
[ '1996-97', %w(SP1 SP2) ],
|
143
|
+
[ '1995-96', %w(SP1) ],
|
144
|
+
[ '1994-95', %w(SP1) ],
|
145
|
+
[ '1993-94', %w(SP1) ]],
|
146
|
+
fr: [[ '2020-21', %w(F1 F2) ],
|
147
|
+
[ '2019-20', %w(F1 F2) ],
|
148
|
+
[ '2018-19', %w(F1 F2) ],
|
149
|
+
[ '2017-18', %w(F1 F2) ],
|
150
|
+
[ '2016-17', %w(F1 F2) ],
|
151
|
+
[ '2015-16', %w(F1 F2) ],
|
152
|
+
[ '2014-15', %w(F1 F2) ],
|
153
|
+
[ '2013-14', %w(F1 F2) ],
|
154
|
+
[ '2012-13', %w(F1 F2) ],
|
155
|
+
[ '2011-12', %w(F1 F2) ],
|
156
|
+
[ '2010-11', %w(F1 F2) ],
|
157
|
+
[ '2009-10', %w(F1 F2) ],
|
158
|
+
[ '2008-09', %w(F1 F2) ],
|
159
|
+
[ '2007-08', %w(F1 F2) ],
|
160
|
+
[ '2006-07', %w(F1 F2) ],
|
161
|
+
[ '2005-06', %w(F1 F2) ],
|
162
|
+
[ '2004-05', %w(F1 F2) ],
|
163
|
+
[ '2003-04', %w(F1 F2) ],
|
164
|
+
[ '2002-03', %w(F1 F2) ],
|
165
|
+
[ '2001-02', %w(F1 F2) ],
|
166
|
+
[ '2000-01', %w(F1 F2) ],
|
167
|
+
[ '1999-00', %w(F1 F2) ],
|
168
|
+
[ '1998-99', %w(F1 F2) ],
|
169
|
+
[ '1997-98', %w(F1 F2) ],
|
170
|
+
[ '1996-97', %w(F1 F2) ],
|
171
|
+
[ '1995-96', %w(F1) ],
|
172
|
+
[ '1994-95', %w(F1) ],
|
173
|
+
[ '1993-94', %w(F1) ]],
|
174
|
+
nl: [[ '2020-21', %w(N1) ],
|
175
|
+
[ '2019-20', %w(N1) ],
|
176
|
+
[ '2018-19', %w(N1) ],
|
177
|
+
[ '2017-18', %w(N1) ],
|
178
|
+
[ '2016-17', %w(N1) ],
|
179
|
+
[ '2015-16', %w(N1) ],
|
180
|
+
[ '2014-15', %w(N1) ],
|
181
|
+
[ '2013-14', %w(N1) ],
|
182
|
+
[ '2012-13', %w(N1) ],
|
183
|
+
[ '2011-12', %w(N1) ],
|
184
|
+
[ '2010-11', %w(N1) ],
|
185
|
+
[ '2009-10', %w(N1) ],
|
186
|
+
[ '2008-09', %w(N1) ],
|
187
|
+
[ '2007-08', %w(N1) ],
|
188
|
+
[ '2006-07', %w(N1) ],
|
189
|
+
[ '2005-06', %w(N1) ],
|
190
|
+
[ '2004-05', %w(N1) ],
|
191
|
+
[ '2003-04', %w(N1) ],
|
192
|
+
[ '2002-03', %w(N1) ],
|
193
|
+
[ '2001-02', %w(N1) ],
|
194
|
+
[ '2000-01', %w(N1) ],
|
195
|
+
[ '1999-00', %w(N1) ],
|
196
|
+
[ '1998-99', %w(N1) ],
|
197
|
+
[ '1997-98', %w(N1) ],
|
198
|
+
[ '1996-97', %w(N1) ],
|
199
|
+
[ '1995-96', %w(N1) ],
|
200
|
+
[ '1994-95', %w(N1) ],
|
201
|
+
[ '1993-94', %w(N1) ]],
|
202
|
+
be: [[ '2020-21', %w(B1) ],
|
203
|
+
[ '2019-20', %w(B1) ],
|
204
|
+
[ '2018-19', %w(B1) ],
|
205
|
+
[ '2017-18', %w(B1) ],
|
206
|
+
[ '2016-17', %w(B1) ],
|
207
|
+
[ '2015-16', %w(B1) ],
|
208
|
+
[ '2014-15', %w(B1) ],
|
209
|
+
[ '2013-14', %w(B1) ],
|
210
|
+
[ '2012-13', %w(B1) ],
|
211
|
+
[ '2011-12', %w(B1) ],
|
212
|
+
[ '2010-11', %w(B1) ],
|
213
|
+
[ '2009-10', %w(B1) ],
|
214
|
+
[ '2008-09', %w(B1) ],
|
215
|
+
[ '2007-08', %w(B1) ],
|
216
|
+
[ '2006-07', %w(B1) ],
|
217
|
+
[ '2005-06', %w(B1) ],
|
218
|
+
[ '2004-05', %w(B1) ],
|
219
|
+
[ '2003-04', %w(B1) ],
|
220
|
+
[ '2002-03', %w(B1) ],
|
221
|
+
[ '2001-02', %w(B1) ],
|
222
|
+
[ '2000-01', %w(B1) ],
|
223
|
+
[ '1999-00', %w(B1) ],
|
224
|
+
[ '1998-99', %w(B1) ],
|
225
|
+
[ '1997-98', %w(B1) ],
|
226
|
+
[ '1996-97', %w(B1) ],
|
227
|
+
[ '1995-96', %w(B1) ]],
|
228
|
+
pt: [[ '2020-21', %w(P1) ],
|
229
|
+
[ '2019-20', %w(P1) ],
|
230
|
+
[ '2018-19', %w(P1) ],
|
231
|
+
[ '2017-18', %w(P1) ],
|
232
|
+
[ '2016-17', %w(P1) ],
|
233
|
+
[ '2015-16', %w(P1) ],
|
234
|
+
[ '2014-15', %w(P1) ],
|
235
|
+
[ '2013-14', %w(P1) ],
|
236
|
+
[ '2012-13', %w(P1) ],
|
237
|
+
[ '2011-12', %w(P1) ],
|
238
|
+
[ '2010-11', %w(P1) ],
|
239
|
+
[ '2009-10', %w(P1) ],
|
240
|
+
[ '2008-09', %w(P1) ],
|
241
|
+
[ '2007-08', %w(P1) ],
|
242
|
+
[ '2006-07', %w(P1) ],
|
243
|
+
[ '2005-06', %w(P1) ],
|
244
|
+
[ '2004-05', %w(P1) ],
|
245
|
+
[ '2003-04', %w(P1) ],
|
246
|
+
[ '2002-03', %w(P1) ],
|
247
|
+
[ '2001-02', %w(P1) ],
|
248
|
+
[ '2000-01', %w(P1) ],
|
249
|
+
[ '1999-00', %w(P1) ],
|
250
|
+
[ '1998-99', %w(P1) ],
|
251
|
+
[ '1997-98', %w(P1) ],
|
252
|
+
[ '1996-97', %w(P1) ],
|
253
|
+
[ '1995-96', %w(P1) ],
|
254
|
+
[ '1994-95', %w(P1) ]],
|
255
|
+
tr: [[ '2020-21', %w(T1) ],
|
256
|
+
[ '2019-20', %w(T1) ],
|
257
|
+
[ '2018-19', %w(T1) ],
|
258
|
+
[ '2017-18', %w(T1) ],
|
259
|
+
[ '2016-17', %w(T1) ],
|
260
|
+
[ '2015-16', %w(T1) ],
|
261
|
+
[ '2014-15', %w(T1) ],
|
262
|
+
[ '2013-14', %w(T1) ],
|
263
|
+
[ '2012-13', %w(T1) ],
|
264
|
+
[ '2011-12', %w(T1) ],
|
265
|
+
[ '2010-11', %w(T1) ],
|
266
|
+
[ '2009-10', %w(T1) ],
|
267
|
+
[ '2008-09', %w(T1) ],
|
268
|
+
[ '2007-08', %w(T1) ],
|
269
|
+
[ '2006-07', %w(T1) ],
|
270
|
+
[ '2005-06', %w(T1) ],
|
271
|
+
[ '2004-05', %w(T1) ],
|
272
|
+
[ '2003-04', %w(T1) ],
|
273
|
+
[ '2002-03', %w(T1) ],
|
274
|
+
[ '2001-02', %w(T1) ],
|
275
|
+
[ '2000-01', %w(T1) ],
|
276
|
+
[ '1999-00', %w(T1) ],
|
277
|
+
[ '1998-99', %w(T1) ],
|
278
|
+
[ '1997-98', %w(T1) ],
|
279
|
+
[ '1996-97', %w(T1) ],
|
280
|
+
[ '1995-96', %w(T1) ],
|
281
|
+
[ '1994-95', %w(T1) ]],
|
282
|
+
gr: [[ '2020-21', %w(G1) ],
|
283
|
+
[ '2019-20', %w(G1) ],
|
284
|
+
[ '2018-19', %w(G1) ],
|
285
|
+
[ '2017-18', %w(G1) ],
|
286
|
+
[ '2016-17', %w(G1) ],
|
287
|
+
[ '2015-16', %w(G1) ],
|
288
|
+
[ '2014-15', %w(G1) ],
|
289
|
+
[ '2013-14', %w(G1) ],
|
290
|
+
[ '2012-13', %w(G1) ],
|
291
|
+
[ '2011-12', %w(G1) ],
|
292
|
+
[ '2010-11', %w(G1) ],
|
293
|
+
[ '2009-10', %w(G1) ],
|
294
|
+
[ '2008-09', %w(G1) ],
|
295
|
+
[ '2007-08', %w(G1) ],
|
296
|
+
[ '2006-07', %w(G1) ],
|
297
|
+
[ '2005-06', %w(G1) ],
|
298
|
+
[ '2004-05', %w(G1) ],
|
299
|
+
[ '2003-04', %w(G1) ],
|
300
|
+
[ '2002-03', %w(G1) ],
|
301
|
+
[ '2001-02', %w(G1) ],
|
302
|
+
[ '2000-01', %w(G1) ],
|
303
|
+
[ '1999-00', %w(G1) ],
|
304
|
+
[ '1998-99', %w(G1) ],
|
305
|
+
[ '1997-98', %w(G1) ],
|
306
|
+
[ '1996-97', %w(G1) ],
|
307
|
+
[ '1995-96', %w(G1) ],
|
308
|
+
[ '1994-95', %w(G1) ]]
|
309
|
+
}
|
310
|
+
|
311
|
+
## all seasons in-one-file datasets
|
312
|
+
SOURCES_II =
|
313
|
+
{
|
314
|
+
## https://www.football-data.co.uk/new/<code>.csv
|
315
|
+
##
|
316
|
+
## check - adjust time-zone/time-offset
|
317
|
+
##
|
318
|
+
## - austria
|
319
|
+
## - major-league-soccer
|
320
|
+
## - mexico
|
321
|
+
## - brazil
|
322
|
+
##
|
323
|
+
## if no "national" repo, use the "world" repo
|
324
|
+
##
|
325
|
+
## check for seasons format
|
326
|
+
## is a full year e.g. 2016 (and NOT 2016/17)
|
327
|
+
## e.g. bra,arg, fin, and others!!!!
|
328
|
+
|
329
|
+
ar: 'ARG', # Argentina Football Results - Primera Division
|
330
|
+
at: 'AUT', # Austria Football Results - Bundesliga
|
331
|
+
br: 'BRA', # Brazil Football Results - Serie A
|
332
|
+
cn: 'CHN', # China Football Results - Super League
|
333
|
+
dk: 'DNK', # Denmark Football Results - Superliga
|
334
|
+
fi: 'FIN', # Finland Football Results - Veikkausliiga
|
335
|
+
ie: 'IRL', # Ireland Football Results - Premier Division
|
336
|
+
jp: 'JPN', # Japan Football Results - J-League
|
337
|
+
mx: 'MEX', # Mexico Football Results - Liga MX
|
338
|
+
no: 'NOR', # Norway Football Results - Eliteserien
|
339
|
+
pl: 'POL', # Poland Football Results - Ekstraklasa
|
340
|
+
ro: 'ROU', # Romania Football Results - Liga 1
|
341
|
+
ru: 'RUS', # Russia Football Results - Premier League
|
342
|
+
se: 'SWE', # Sweden Football Results - Allsvenskan
|
343
|
+
ch: 'SWZ', # Switzerland Football Results - Super League
|
344
|
+
us: 'USA', # USA Football Results - MLS
|
345
|
+
}
|
346
|
+
|
347
|
+
## map football_data leagues to our own keys
|
348
|
+
LEAGUES = {
|
349
|
+
'E0' => 'eng.1', # english premier league
|
350
|
+
'E1' => 'eng.2', # english championship league
|
351
|
+
'E2' => 'eng.3', # english league 1
|
352
|
+
'E3' => 'eng.4', # english league 2
|
353
|
+
'EC' => 'eng.5', # english conference
|
354
|
+
|
355
|
+
'SP1' => 'es.1', # spanish liga 1
|
356
|
+
'SP2' => 'es.2', # spanish liga 2
|
357
|
+
|
358
|
+
'F1' => 'fr.1', # french ligue 1
|
359
|
+
'F2' => 'fr.2', # french ligue 2
|
360
|
+
|
361
|
+
'I1' => 'it.1', # italian serie a
|
362
|
+
'I2' => 'it.2', # italian serie b
|
363
|
+
|
364
|
+
'D1' => 'de.1', # german bundesliga
|
365
|
+
'D2' => 'de.2', # german 2. bundesliga
|
366
|
+
|
367
|
+
'SC0' => 'sco.1', # scotish Premiership # starting w/ 2013-14 season
|
368
|
+
'SC1' => 'sco.2', # scotish Championship
|
369
|
+
'SC2' => 'sco.3', # scotish League One
|
370
|
+
'SC3' => 'sco.4', # scotish League Two
|
371
|
+
|
372
|
+
'N1' => 'nl.1', # dutch eredivisie
|
373
|
+
|
374
|
+
'B1' => 'be.1', # belgian pro league
|
375
|
+
|
376
|
+
'P1' => 'pt.1', # portugese Primeira Liga
|
377
|
+
|
378
|
+
'T1' => 'tr.1', # turkish Süper Lig
|
379
|
+
|
380
|
+
'G1' => 'gr.1', # greek Superleague
|
381
|
+
}
|
382
|
+
|
383
|
+
|
384
|
+
# https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
385
|
+
## todo/fix: add support for dst (daylight saving time!!! )
|
386
|
+
## uses always "winter" time for now
|
387
|
+
TIMEZONES = {
|
388
|
+
mx: -6, ## America/Mexico_City - note: baja sur is -7, bajar norte (tijuana) is -8 !!!
|
389
|
+
us: -5, ## America/New_York
|
390
|
+
ar: -3, ## America/Argentina/Buenos_Aires
|
391
|
+
br: -3, ## America/Sao_Paulo
|
392
|
+
|
393
|
+
eng: 0, ## Europe/London
|
394
|
+
sco: 0, ## ?
|
395
|
+
ie: 0, ## Europe/Dublin
|
396
|
+
pt: 0, ## Europe/Lisbon
|
397
|
+
at: +1, ## Europe/Vienna
|
398
|
+
de: +1, ## Europe/Berlin
|
399
|
+
it: +1, ## Europe/Rome
|
400
|
+
es: +1, ## Europe/Madrid
|
401
|
+
fr: +1, ## Europe/Paris
|
402
|
+
nl: +1, ## Europe/Amsterdam
|
403
|
+
be: +1, ## Europe/Brussels
|
404
|
+
dk: +1, ## Europe/Copenhagen
|
405
|
+
no: +1, ## Europe/Oslo
|
406
|
+
se: +1, ## Europe/Stockholm
|
407
|
+
ch: +1, ## Europe/Zurich
|
408
|
+
|
409
|
+
fi: +2, ## Europe/Helsinki
|
410
|
+
gr: +2, ## Europe/Athens
|
411
|
+
pl: +2, ## Europe/Warsaw
|
412
|
+
ro: +2, ## Europe/Bucharest
|
413
|
+
tr: +3, ## Europe/Istanbul
|
414
|
+
ru: +3, ## Europe/Moscow
|
415
|
+
|
416
|
+
cn: +8, ## Asia/Shanghai
|
417
|
+
jp: +9, ## Asia/Tokyo
|
418
|
+
}
|
419
|
+
|
420
|
+
end # module Footballdata12xpert
|
@@ -0,0 +1,206 @@
|
|
1
|
+
|
2
|
+
## todo/fix: move CsvMatchWriter to its own file!!!!!
|
3
|
+
class CsvMatchWriter
|
4
|
+
|
5
|
+
def self.write( path, matches )
|
6
|
+
|
7
|
+
## for convenience - make sure parent folders/directories exist
|
8
|
+
FileUtils.mkdir_p( File.dirname( path) ) unless Dir.exist?( File.dirname( path ))
|
9
|
+
|
10
|
+
|
11
|
+
out = File.new( path, 'w:utf-8' )
|
12
|
+
|
13
|
+
headers = [
|
14
|
+
'Date',
|
15
|
+
'Team 1',
|
16
|
+
'FT',
|
17
|
+
'HT',
|
18
|
+
'Team 2'
|
19
|
+
]
|
20
|
+
|
21
|
+
out << headers.join(',') ## e.g. Date,Team 1,FT,HT,Team 2
|
22
|
+
out << "\n"
|
23
|
+
|
24
|
+
|
25
|
+
matches.each_with_index do |match,i|
|
26
|
+
|
27
|
+
if i < 2
|
28
|
+
puts "[#{i}]:" + match.inspect
|
29
|
+
end
|
30
|
+
|
31
|
+
## note: skip empty match rows
|
32
|
+
## todo/fix: fix "upstream" in match parser!!!!!
|
33
|
+
next if match.team1.blank? && match.team2.blank?
|
34
|
+
|
35
|
+
|
36
|
+
values = []
|
37
|
+
|
38
|
+
## note:
|
39
|
+
## as a convention add all auto-calculated values in ()
|
40
|
+
## e.g. weekday e.g. (Fri), weeknumber (22), matches played (2), etc.
|
41
|
+
|
42
|
+
## for easier double-checking of rounds and dates
|
43
|
+
## (auto-)add weekday and weeknumber
|
44
|
+
## todo/fix: weeknumber - use +1 (do NOT start with 0 - why? why not)
|
45
|
+
if match.date
|
46
|
+
## todo/fix: add time if present? why? why not?
|
47
|
+
## note: assumes string for now e.g. 2018-11-22
|
48
|
+
date = Date.strptime( match.date, '%Y-%m-%d' )
|
49
|
+
|
50
|
+
date_buf = ''
|
51
|
+
date_buf << date.strftime( '%a %b %-d %Y' )
|
52
|
+
## date_buf << " (W#{date.cweek})" ## use week number (iso-standard week starting on monday)
|
53
|
+
|
54
|
+
values << date_buf ## print weekday e.g. Fri, Sat, etc.
|
55
|
+
else
|
56
|
+
values << '?'
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
values << match.team1
|
62
|
+
|
63
|
+
if match.score1 && match.score2
|
64
|
+
values << "#{match.score1}-#{match.score2}"
|
65
|
+
else
|
66
|
+
# no (or incomplete) full time score; add empty
|
67
|
+
values << '?'
|
68
|
+
end
|
69
|
+
|
70
|
+
if match.score1i && match.score2i
|
71
|
+
values << "#{match.score1i}-#{match.score2i}"
|
72
|
+
else
|
73
|
+
# no (or incomplete) half time score; add empty
|
74
|
+
values << '?'
|
75
|
+
end
|
76
|
+
|
77
|
+
values << match.team2
|
78
|
+
|
79
|
+
out << values.join( ',' )
|
80
|
+
out << "\n"
|
81
|
+
end
|
82
|
+
|
83
|
+
out.close
|
84
|
+
end
|
85
|
+
end # class CsvMatchWriter
|
86
|
+
|
87
|
+
|
88
|
+
module Footballdata12xpert
|
89
|
+
|
90
|
+
##
|
91
|
+
## todo/fix: add fix_date converter to CsvReader !!!!!
|
92
|
+
|
93
|
+
def self.convert( *country_keys, start: nil )
|
94
|
+
## note: always downcase and symbolize keys (thus, allow strings too for now)
|
95
|
+
country_keys = country_keys.map {|key| key.downcase.to_sym }
|
96
|
+
|
97
|
+
SOURCES_I.each do |country_key, country_sources|
|
98
|
+
if country_keys.empty? || country_keys.include?( country_key )
|
99
|
+
convert_season_by_season( country_key,
|
100
|
+
country_sources,
|
101
|
+
start: start )
|
102
|
+
else
|
103
|
+
## skipping country
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
SOURCES_II.each do |country_key, country_basename|
|
108
|
+
if country_keys.empty? || country_keys.include?( country_key )
|
109
|
+
convert_all_seasons( country_key,
|
110
|
+
country_basename,
|
111
|
+
start: start )
|
112
|
+
else
|
113
|
+
## skipping country
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end ## method convert
|
117
|
+
|
118
|
+
|
119
|
+
###
|
120
|
+
# private helpers / machinery
|
121
|
+
|
122
|
+
def self.convert_season_by_season( country_key, sources, start: nil )
|
123
|
+
|
124
|
+
start = Season.parse( start ) if start ## convert to season obj
|
125
|
+
|
126
|
+
|
127
|
+
out_dir = './o'
|
128
|
+
|
129
|
+
|
130
|
+
sources.each do |rec|
|
131
|
+
season = Season.parse( rec[0] ) ## note: dirname is season e.g. 2011-12 etc.
|
132
|
+
basenames = rec[1] ## e.g. E1,E2,etc.
|
133
|
+
|
134
|
+
if start && season < start
|
135
|
+
puts "skipping #{season} before #{start}"
|
136
|
+
next
|
137
|
+
end
|
138
|
+
|
139
|
+
basenames.each do |basename|
|
140
|
+
url = season_by_season_url( basename, season )
|
141
|
+
|
142
|
+
## hack: find a better/easier helper method - why? why not?
|
143
|
+
in_path = "#{Webcache.root}/#{Webcache::DiskCache.new.url_to_path( url )}"
|
144
|
+
puts " url: >#{url}<, in_path: >#{in_path}<"
|
145
|
+
|
146
|
+
league_key = LEAGUES[basename]
|
147
|
+
league_basename = league_key ## e.g.: eng.1, fr.1, fr.2 etc.
|
148
|
+
|
149
|
+
out_path = "#{out_dir}/#{season.to_path}/#{league_basename}.csv"
|
150
|
+
|
151
|
+
puts "out_path: #{out_path}"
|
152
|
+
|
153
|
+
matches = SportDb::CsvMatchParser.read( in_path )
|
154
|
+
puts "#{matches.size} matches"
|
155
|
+
exit 1 if matches.size == 0 ## make sure parse works (don't ignore empty reads)
|
156
|
+
|
157
|
+
|
158
|
+
CsvMatchWriter.write( out_path, matches )
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end # method convert_season_by_season
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
def self.convert_all_seasons( country_key, basename, start: nil )
|
166
|
+
|
167
|
+
start = Season.parse( start ) if start ## convert to season obj
|
168
|
+
|
169
|
+
out_dir = './o'
|
170
|
+
|
171
|
+
url = all_seasons_url( basename )
|
172
|
+
|
173
|
+
## hack: find a better/easier helper method - why? why not?
|
174
|
+
in_path = "#{Webcache.root}/#{Webcache::DiskCache.new.url_to_path( url )}"
|
175
|
+
puts " url: >#{url}<, in_path: >#{in_path}<"
|
176
|
+
|
177
|
+
col = 'Season'
|
178
|
+
season_keys = SportDb::CsvMatchParser.find_seasons( in_path, col: col )
|
179
|
+
pp season_keys
|
180
|
+
|
181
|
+
## todo/check: make sure timezones entry for country_key exists!!! what results with nil/24.0 ??
|
182
|
+
fix_date_converter = ->(row) { fix_date( row, TIMEZONES[country_key]/24.0 ) }
|
183
|
+
|
184
|
+
season_keys.each do |season_key|
|
185
|
+
season = Season.parse( season_key )
|
186
|
+
if start && season < start
|
187
|
+
puts "skipping #{season} before #{start}"
|
188
|
+
next
|
189
|
+
end
|
190
|
+
|
191
|
+
matches = SportDb::CsvMatchParser.read( in_path, filters: { col => season_key },
|
192
|
+
converters: fix_date_converter )
|
193
|
+
|
194
|
+
pp matches[0..2]
|
195
|
+
pp matches.size
|
196
|
+
|
197
|
+
## note: assume (always) first level league for now
|
198
|
+
league_basename = "#{country_key}.1" ## e.g.: ar.1, at.1, mx.1, us.1, etc.
|
199
|
+
|
200
|
+
out_path = "#{out_dir}/#{season.to_path}/#{league_basename}.csv"
|
201
|
+
|
202
|
+
CsvMatchWriter.write( out_path, matches )
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
end # module Footballdata12xpert
|