fifadat 0.0.1 → 2026.9.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -0
- data/Manifest.txt +60 -83
- data/Rakefile +2 -2
- data/{lib/fifadat/config → config}/seasons/at.csv +1 -0
- data/{lib/fifadat/config → config}/seasons/at.cup.csv +1 -0
- data/{lib/fifadat/config → config}/seasons/au.csv +1 -0
- data/{lib/fifadat/config → config}/seasons/be.csv +1 -0
- data/{lib/fifadat/config → config}/seasons/ch.csv +1 -0
- data/{lib/fifadat/config → config}/seasons/cz.csv +1 -0
- data/{lib/fifadat/config → config}/seasons/de.2.csv +1 -0
- data/{lib/fifadat/config → config}/seasons/de.csv +1 -0
- data/{lib/fifadat/config → config}/seasons/de.cup.csv +1 -0
- data/{lib/fifadat/config → config}/seasons/eg.csv +1 -0
- data/{lib/fifadat/config → config}/seasons/eng.2.csv +1 -0
- data/{lib/fifadat/config → config}/seasons/eng.csv +1 -0
- data/{lib/fifadat/config → config}/seasons/eng.facup.csv +1 -0
- data/{lib/fifadat/config → config}/seasons/es.csv +1 -0
- data/{lib/fifadat/config → config}/seasons/fr.csv +1 -0
- data/{lib/fifadat/config → config}/seasons/gr.csv +1 -0
- data/{lib/fifadat/config → config}/seasons/hu.csv +1 -0
- data/{lib/fifadat/config → config}/seasons/il.csv +1 -0
- data/{lib/fifadat/config → config}/seasons/interconticup.csv +1 -1
- data/{lib/fifadat/config → config}/seasons/is.csv +1 -1
- data/{lib/fifadat/config → config}/seasons/it.csv +1 -0
- data/{lib/fifadat/config → config}/seasons/it.cup.csv +1 -0
- data/{lib/fifadat/config → config}/seasons/lu.csv +1 -0
- data/{lib/fifadat/config → config}/seasons/ma.csv +1 -0
- data/{lib/fifadat/config → config}/seasons/mx.csv +1 -0
- data/{lib/fifadat/config → config}/seasons/nir.csv +1 -0
- data/{lib/fifadat/config → config}/seasons/nl.csv +1 -0
- data/{lib/fifadat/config → config}/seasons/pl.csv +1 -0
- data/{lib/fifadat/config → config}/seasons/pt.csv +1 -0
- data/{lib/fifadat/config → config}/seasons/sa.csv +1 -0
- data/{lib/fifadat/config → config}/seasons/sco.csv +1 -0
- data/{lib/fifadat/config → config}/seasons/tn.csv +1 -0
- data/{lib/fifadat/config → config}/seasons/tr.csv +1 -0
- data/{lib/fifadat/config → config}/seasons/uefa.cl.csv +1 -0
- data/{lib/fifadat/config → config}/seasons/uefa.con.csv +1 -0
- data/{lib/fifadat/config → config}/seasons/uefa.europa.csv +1 -0
- data/{lib/fifadat/config → config}/seasons/wal.csv +1 -0
- data/{lib/fifadat/config → config}/seasons/za.csv +1 -0
- data/lib/fifadat/{api-config.rb → config.rb} +4 -9
- data/lib/fifadat/version.rb +19 -0
- data/lib/fifadat.rb +8 -36
- metadata +63 -87
- data/bin/fifadat +0 -14
- data/lib/fifadat/errata.rb +0 -59
- data/lib/fifadat/helper.rb +0 -46
- data/lib/fifadat/pp/build_match.rb +0 -105
- data/lib/fifadat/pp/build_report.rb +0 -135
- data/lib/fifadat/pp/convert-reports.rb +0 -114
- data/lib/fifadat/pp/convert.rb +0 -163
- data/lib/fifadat/pp/goals-calc_score.rb +0 -58
- data/lib/fifadat/pp/goals.rb +0 -89
- data/lib/fifadat/pp/helper-date.rb +0 -13
- data/lib/fifadat/pp/helper-minute.rb +0 -81
- data/lib/fifadat/pp/helper-score.rb +0 -139
- data/lib/fifadat/pp/norm.rb +0 -34
- data/lib/fifadat/pp/officials.rb +0 -86
- data/lib/fifadat/pp/penalties.rb +0 -132
- data/lib/fifadat/pp/players.rb +0 -323
- data/lib/fifadat/pp/stadiums.rb +0 -99
- data/lib/fifadat/pp/stages.rb +0 -119
- data/lib/fifadat/pp/substitutions.rb +0 -444
- data/lib/fifadat/pp/teams.rb +0 -91
- data/lib/fifadat/ppdebug.rb +0 -128
- data/lib/fifadat/ppmatch.rb +0 -78
- data/lib/fifadat/tool.rb +0 -184
- data/lib/fifadat/types.rb +0 -166
- /data/{lib/fifadat/config → config}/codes_club-europe.csv +0 -0
- /data/{lib/fifadat/config → config}/codes_club.csv +0 -0
- /data/{lib/fifadat/config → config}/codes_nati.csv +0 -0
- /data/{lib/fifadat/config → config}/seasons/ar.csv +0 -0
- /data/{lib/fifadat/config → config}/seasons/br.csv +0 -0
- /data/{lib/fifadat/config → config}/seasons/clubworldcup.csv +0 -0
- /data/{lib/fifadat/config → config}/seasons/cn.csv +0 -0
- /data/{lib/fifadat/config → config}/seasons/co.csv +0 -0
- /data/{lib/fifadat/config → config}/seasons/copa.l.csv +0 -0
- /data/{lib/fifadat/config → config}/seasons/copa.s.csv +0 -0
- /data/{lib/fifadat/config → config}/seasons/ie.csv +0 -0
- /data/{lib/fifadat/config → config}/seasons/jp.csv +0 -0
- /data/{lib/fifadat/config → config}/seasons/kr.csv +0 -0
- /data/{lib/fifadat/config → config}/seasons/mls.csv +0 -0
- /data/{lib/fifadat/config → config}/seasons/mx.2.csv +0 -0
- /data/{lib/fifadat/config → config}/seasons/mx.cup.csv +0 -0
- /data/{lib/fifadat/config → config}/seasons/no.csv +0 -0
- /data/{lib/fifadat/config → config}/seasons/se.csv +0 -0
- /data/{lib/fifadat/config → config}/seasons/uy.csv +0 -0
- /data/{lib/fifadat/config → config}/seasons/worldcup.csv +0 -0
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fifadat
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2026.9.23
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gerald Bauer
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-09-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: cocos
|
|
@@ -88,8 +88,7 @@ dependencies:
|
|
|
88
88
|
version: '4.2'
|
|
89
89
|
description: fifadat - get football data via the (unofficial) fifa api
|
|
90
90
|
email: gerald.bauer@gmail.com
|
|
91
|
-
executables:
|
|
92
|
-
- fifadat
|
|
91
|
+
executables: []
|
|
93
92
|
extensions: []
|
|
94
93
|
extra_rdoc_files:
|
|
95
94
|
- CHANGELOG.md
|
|
@@ -100,93 +99,70 @@ files:
|
|
|
100
99
|
- Manifest.txt
|
|
101
100
|
- README.md
|
|
102
101
|
- Rakefile
|
|
103
|
-
-
|
|
102
|
+
- config/codes_club-europe.csv
|
|
103
|
+
- config/codes_club.csv
|
|
104
|
+
- config/codes_nati.csv
|
|
105
|
+
- config/seasons/ar.csv
|
|
106
|
+
- config/seasons/at.csv
|
|
107
|
+
- config/seasons/at.cup.csv
|
|
108
|
+
- config/seasons/au.csv
|
|
109
|
+
- config/seasons/be.csv
|
|
110
|
+
- config/seasons/br.csv
|
|
111
|
+
- config/seasons/ch.csv
|
|
112
|
+
- config/seasons/clubworldcup.csv
|
|
113
|
+
- config/seasons/cn.csv
|
|
114
|
+
- config/seasons/co.csv
|
|
115
|
+
- config/seasons/copa.l.csv
|
|
116
|
+
- config/seasons/copa.s.csv
|
|
117
|
+
- config/seasons/cz.csv
|
|
118
|
+
- config/seasons/de.2.csv
|
|
119
|
+
- config/seasons/de.csv
|
|
120
|
+
- config/seasons/de.cup.csv
|
|
121
|
+
- config/seasons/eg.csv
|
|
122
|
+
- config/seasons/eng.2.csv
|
|
123
|
+
- config/seasons/eng.csv
|
|
124
|
+
- config/seasons/eng.facup.csv
|
|
125
|
+
- config/seasons/es.csv
|
|
126
|
+
- config/seasons/fr.csv
|
|
127
|
+
- config/seasons/gr.csv
|
|
128
|
+
- config/seasons/hu.csv
|
|
129
|
+
- config/seasons/ie.csv
|
|
130
|
+
- config/seasons/il.csv
|
|
131
|
+
- config/seasons/interconticup.csv
|
|
132
|
+
- config/seasons/is.csv
|
|
133
|
+
- config/seasons/it.csv
|
|
134
|
+
- config/seasons/it.cup.csv
|
|
135
|
+
- config/seasons/jp.csv
|
|
136
|
+
- config/seasons/kr.csv
|
|
137
|
+
- config/seasons/lu.csv
|
|
138
|
+
- config/seasons/ma.csv
|
|
139
|
+
- config/seasons/mls.csv
|
|
140
|
+
- config/seasons/mx.2.csv
|
|
141
|
+
- config/seasons/mx.csv
|
|
142
|
+
- config/seasons/mx.cup.csv
|
|
143
|
+
- config/seasons/nir.csv
|
|
144
|
+
- config/seasons/nl.csv
|
|
145
|
+
- config/seasons/no.csv
|
|
146
|
+
- config/seasons/pl.csv
|
|
147
|
+
- config/seasons/pt.csv
|
|
148
|
+
- config/seasons/sa.csv
|
|
149
|
+
- config/seasons/sco.csv
|
|
150
|
+
- config/seasons/se.csv
|
|
151
|
+
- config/seasons/tn.csv
|
|
152
|
+
- config/seasons/tr.csv
|
|
153
|
+
- config/seasons/uefa.cl.csv
|
|
154
|
+
- config/seasons/uefa.con.csv
|
|
155
|
+
- config/seasons/uefa.europa.csv
|
|
156
|
+
- config/seasons/uy.csv
|
|
157
|
+
- config/seasons/wal.csv
|
|
158
|
+
- config/seasons/worldcup.csv
|
|
159
|
+
- config/seasons/za.csv
|
|
104
160
|
- lib/fifadat.rb
|
|
105
|
-
- lib/fifadat/api-config.rb
|
|
106
161
|
- lib/fifadat/api.rb
|
|
107
|
-
- lib/fifadat/config
|
|
108
|
-
- lib/fifadat/config/codes_club.csv
|
|
109
|
-
- lib/fifadat/config/codes_nati.csv
|
|
110
|
-
- lib/fifadat/config/seasons/ar.csv
|
|
111
|
-
- lib/fifadat/config/seasons/at.csv
|
|
112
|
-
- lib/fifadat/config/seasons/at.cup.csv
|
|
113
|
-
- lib/fifadat/config/seasons/au.csv
|
|
114
|
-
- lib/fifadat/config/seasons/be.csv
|
|
115
|
-
- lib/fifadat/config/seasons/br.csv
|
|
116
|
-
- lib/fifadat/config/seasons/ch.csv
|
|
117
|
-
- lib/fifadat/config/seasons/clubworldcup.csv
|
|
118
|
-
- lib/fifadat/config/seasons/cn.csv
|
|
119
|
-
- lib/fifadat/config/seasons/co.csv
|
|
120
|
-
- lib/fifadat/config/seasons/copa.l.csv
|
|
121
|
-
- lib/fifadat/config/seasons/copa.s.csv
|
|
122
|
-
- lib/fifadat/config/seasons/cz.csv
|
|
123
|
-
- lib/fifadat/config/seasons/de.2.csv
|
|
124
|
-
- lib/fifadat/config/seasons/de.csv
|
|
125
|
-
- lib/fifadat/config/seasons/de.cup.csv
|
|
126
|
-
- lib/fifadat/config/seasons/eg.csv
|
|
127
|
-
- lib/fifadat/config/seasons/eng.2.csv
|
|
128
|
-
- lib/fifadat/config/seasons/eng.csv
|
|
129
|
-
- lib/fifadat/config/seasons/eng.facup.csv
|
|
130
|
-
- lib/fifadat/config/seasons/es.csv
|
|
131
|
-
- lib/fifadat/config/seasons/fr.csv
|
|
132
|
-
- lib/fifadat/config/seasons/gr.csv
|
|
133
|
-
- lib/fifadat/config/seasons/hu.csv
|
|
134
|
-
- lib/fifadat/config/seasons/ie.csv
|
|
135
|
-
- lib/fifadat/config/seasons/il.csv
|
|
136
|
-
- lib/fifadat/config/seasons/interconticup.csv
|
|
137
|
-
- lib/fifadat/config/seasons/is.csv
|
|
138
|
-
- lib/fifadat/config/seasons/it.csv
|
|
139
|
-
- lib/fifadat/config/seasons/it.cup.csv
|
|
140
|
-
- lib/fifadat/config/seasons/jp.csv
|
|
141
|
-
- lib/fifadat/config/seasons/kr.csv
|
|
142
|
-
- lib/fifadat/config/seasons/lu.csv
|
|
143
|
-
- lib/fifadat/config/seasons/ma.csv
|
|
144
|
-
- lib/fifadat/config/seasons/mls.csv
|
|
145
|
-
- lib/fifadat/config/seasons/mx.2.csv
|
|
146
|
-
- lib/fifadat/config/seasons/mx.csv
|
|
147
|
-
- lib/fifadat/config/seasons/mx.cup.csv
|
|
148
|
-
- lib/fifadat/config/seasons/nir.csv
|
|
149
|
-
- lib/fifadat/config/seasons/nl.csv
|
|
150
|
-
- lib/fifadat/config/seasons/no.csv
|
|
151
|
-
- lib/fifadat/config/seasons/pl.csv
|
|
152
|
-
- lib/fifadat/config/seasons/pt.csv
|
|
153
|
-
- lib/fifadat/config/seasons/sa.csv
|
|
154
|
-
- lib/fifadat/config/seasons/sco.csv
|
|
155
|
-
- lib/fifadat/config/seasons/se.csv
|
|
156
|
-
- lib/fifadat/config/seasons/tn.csv
|
|
157
|
-
- lib/fifadat/config/seasons/tr.csv
|
|
158
|
-
- lib/fifadat/config/seasons/uefa.cl.csv
|
|
159
|
-
- lib/fifadat/config/seasons/uefa.con.csv
|
|
160
|
-
- lib/fifadat/config/seasons/uefa.europa.csv
|
|
161
|
-
- lib/fifadat/config/seasons/uy.csv
|
|
162
|
-
- lib/fifadat/config/seasons/wal.csv
|
|
163
|
-
- lib/fifadat/config/seasons/worldcup.csv
|
|
164
|
-
- lib/fifadat/config/seasons/za.csv
|
|
165
|
-
- lib/fifadat/errata.rb
|
|
166
|
-
- lib/fifadat/helper.rb
|
|
162
|
+
- lib/fifadat/config.rb
|
|
167
163
|
- lib/fifadat/json.rb
|
|
168
|
-
- lib/fifadat/pp/build_match.rb
|
|
169
|
-
- lib/fifadat/pp/build_report.rb
|
|
170
|
-
- lib/fifadat/pp/convert-reports.rb
|
|
171
|
-
- lib/fifadat/pp/convert.rb
|
|
172
|
-
- lib/fifadat/pp/goals-calc_score.rb
|
|
173
|
-
- lib/fifadat/pp/goals.rb
|
|
174
|
-
- lib/fifadat/pp/helper-date.rb
|
|
175
|
-
- lib/fifadat/pp/helper-minute.rb
|
|
176
|
-
- lib/fifadat/pp/helper-score.rb
|
|
177
|
-
- lib/fifadat/pp/norm.rb
|
|
178
|
-
- lib/fifadat/pp/officials.rb
|
|
179
|
-
- lib/fifadat/pp/penalties.rb
|
|
180
|
-
- lib/fifadat/pp/players.rb
|
|
181
|
-
- lib/fifadat/pp/stadiums.rb
|
|
182
|
-
- lib/fifadat/pp/stages.rb
|
|
183
|
-
- lib/fifadat/pp/substitutions.rb
|
|
184
|
-
- lib/fifadat/pp/teams.rb
|
|
185
|
-
- lib/fifadat/ppdebug.rb
|
|
186
|
-
- lib/fifadat/ppmatch.rb
|
|
187
164
|
- lib/fifadat/prepare.rb
|
|
188
|
-
- lib/fifadat/
|
|
189
|
-
- lib/fifadat/types.rb
|
|
165
|
+
- lib/fifadat/version.rb
|
|
190
166
|
homepage: https://github.com/sportdb/sport.db
|
|
191
167
|
licenses:
|
|
192
168
|
- Public Domain
|
data/bin/fifadat
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
## tip: to test run:
|
|
4
|
-
## ruby -I ./lib bin/fifadat
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
##
|
|
8
|
-
## note - always use latest (local) if present
|
|
9
|
-
$LOAD_PATH.unshift( '/sports/yorobot/sport.db.more/fifadat/lib' )
|
|
10
|
-
|
|
11
|
-
require 'fifadat'
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
Fifadat.main( ARGV )
|
data/lib/fifadat/errata.rb
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
###
|
|
2
|
-
# known data gotchas/errors
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
##
|
|
6
|
-
# worldcup 2026 - USA v Belgium
|
|
7
|
-
# -- goal (period, minute)
|
|
8
|
-
|
|
9
|
-
=begin
|
|
10
|
-
in USA v Belgium
|
|
11
|
-
"Type"=>2,
|
|
12
|
-
"IdPlayer"=>"448362",
|
|
13
|
-
"Minute"=>"1'",
|
|
14
|
-
"IdAssistPlayer"=>nil,
|
|
15
|
-
"Period"=>2,
|
|
16
|
-
"IdGoal"=>nil,
|
|
17
|
-
"IdTeam"=>"43935"}
|
|
18
|
-
|
|
19
|
-
{ "Type": 2,
|
|
20
|
-
"IdPlayer": "448362",
|
|
21
|
-
"Minute": "0'",
|
|
22
|
-
"IdAssistPlayer": null,
|
|
23
|
-
"Period": 2,
|
|
24
|
-
"IdGoal": null,
|
|
25
|
-
"IdTeam": "43935"},
|
|
26
|
-
|
|
27
|
-
=end
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def errata_autofix_goal( h )
|
|
31
|
-
if h['Type'] == 2 &&
|
|
32
|
-
h['IdPlayer'] == '448362' && ##
|
|
33
|
-
h['IdTeam'] == '43935' ## Belgium
|
|
34
|
-
h['Type'] = 3 ## 1ST_HALF
|
|
35
|
-
h['Minute'] = "9'"
|
|
36
|
-
|
|
37
|
-
puts "-- ERRATA - autofix goal USA v Belgium / Worldcup"
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
h
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
##
|
|
45
|
-
# clubworldcup
|
|
46
|
-
# -- score (ResultType)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
def errata_autofix_score( m )
|
|
50
|
-
## pachuca vs salzburg in cwc 2025??
|
|
51
|
-
if m['IdMatch'] == '400019191' && ## fix for pachuca vs salzburg
|
|
52
|
-
m['ResultType'] == 0
|
|
53
|
-
m['ResultType'] == 1 ## regular (or use 4-REG/AGG - why? why not?)
|
|
54
|
-
|
|
55
|
-
puts "-- ERRATA - autofix score pachuca vs salzburg / Club Worldcup"
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
m
|
|
59
|
-
end
|
data/lib/fifadat/helper.rb
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
def assert( test, msg )
|
|
4
|
-
if test
|
|
5
|
-
else
|
|
6
|
-
puts "!! ASSERT FAILED - #{msg}"
|
|
7
|
-
exit 1
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
### fix - change/rename to datetime!!!
|
|
12
|
-
def parse_date( date_str )
|
|
13
|
-
date = DateTime.strptime( date_str, '%Y-%m-%dT%H:%M:%S%z' )
|
|
14
|
-
|
|
15
|
-
assert( date_str == date.strftime('%Y-%m-%dT%H:%M:%SZ'),
|
|
16
|
-
"date parse expected #{date_str} - got #{date.inspect}" )
|
|
17
|
-
date
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def parse_date_utc( str )
|
|
22
|
-
date = DateTime.strptime( str, '%Y-%m-%dT%H:%M:%S%z' )
|
|
23
|
-
|
|
24
|
-
## note: check for seconds is 00
|
|
25
|
-
## AND timezone is Z (zulu) (shortkey for utc!)
|
|
26
|
-
## e.g. hard code ":00Z" in strftime!!!
|
|
27
|
-
|
|
28
|
-
str_exp = date.strftime('%Y-%m-%dT%H:%M:00Z')
|
|
29
|
-
assert( str == str_exp,
|
|
30
|
-
"date parse expected #{str_exp} - got #{str} #{date.inspect}" )
|
|
31
|
-
date
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def desc( data ) ## get description
|
|
38
|
-
return nil if data.nil? || (data.is_a?(Array) && data.empty?)
|
|
39
|
-
|
|
40
|
-
row = data[0] ## assume first entry is en-GB
|
|
41
|
-
locale = row['Locale']
|
|
42
|
-
assert( locale == 'en-GB' || locale == 'en-gb',
|
|
43
|
-
"locale en-GB expected in data[0] - got #{data}")
|
|
44
|
-
|
|
45
|
-
row['Description']
|
|
46
|
-
end
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def _build_match( m ) ## use _fill/build_match_basics() or such ???
|
|
5
|
-
rec = {}
|
|
6
|
-
|
|
7
|
-
## 0 => FINISHED/complete (OK)
|
|
8
|
-
## 1 => SCHEDULED/not yet played
|
|
9
|
-
status = m['MatchStatus']
|
|
10
|
-
timed = m['TimeDefined']
|
|
11
|
-
|
|
12
|
-
if status == 1 && timed ## note: use TIMED (instead of SCHEDULED)
|
|
13
|
-
rec[:status] = 'TIMED'
|
|
14
|
-
else
|
|
15
|
-
rec[:status] = MATCH_STATUS[ status ] || "#{status}-???"
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
rec[:stage] = desc( m['StageName'] )
|
|
21
|
-
|
|
22
|
-
## check optional group, matchday, (match) num
|
|
23
|
-
## note - matchday is a string!! (check if always a number)
|
|
24
|
-
## ## convert to int if str - why? why not??
|
|
25
|
-
group = desc( m['GroupName'] )
|
|
26
|
-
rec[:group] = group if group
|
|
27
|
-
|
|
28
|
-
matchday = m['MatchDay']
|
|
29
|
-
rec[:matchday] = matchday.to_i(10) if matchday
|
|
30
|
-
|
|
31
|
-
num = m['MatchNumber']
|
|
32
|
-
rec[:num] = num if num
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
dateTime = parse_date_utc( m['Date'] )
|
|
36
|
-
localDateTime = parse_date_utc( m['LocalDate'] )
|
|
37
|
-
|
|
38
|
-
if timed
|
|
39
|
-
## pass along as is for now - why? why not
|
|
40
|
-
## note - Date is date_utc and
|
|
41
|
-
## LocalDate is date_local (also in utc BUT different HH:MM or possible day)
|
|
42
|
-
## note - also in utc, that is, timezone is Z (not +03:00 or such!!!)
|
|
43
|
-
|
|
44
|
-
## note - use datetime - why? why not?
|
|
45
|
-
##
|
|
46
|
-
## note - cut-off/remove seconds
|
|
47
|
-
rec[:datetime_utc] = dateTime.strftime( '%Y-%m-%dT%H:%MZ' )
|
|
48
|
-
|
|
49
|
-
## note - use 20:30 UTC+1 or 20:30 UTC-3 for timezone format for now
|
|
50
|
-
rec[:datetime_local] = _fmt_date_local( dateTime, localDateTime )
|
|
51
|
-
else
|
|
52
|
-
rec[:date] = dateTime.strftime( '%Y-%m-%d' )
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if m['HomeTeam'] && m['AwayTeam'] ## assume match reports
|
|
58
|
-
team1 = build_team( m['HomeTeam'] )
|
|
59
|
-
team2 = build_team( m['AwayTeam'] )
|
|
60
|
-
## use full team details here (via lookup)
|
|
61
|
-
## when report (mode) - why? why not?
|
|
62
|
-
rec[:team1] = team1[:name]
|
|
63
|
-
rec[:team2] = team2[:name]
|
|
64
|
-
else
|
|
65
|
-
team1 = build_team( m['Home'] )
|
|
66
|
-
team2 = build_team( m['Away'] )
|
|
67
|
-
rec[:team1] = team1[:name]
|
|
68
|
-
rec[:team2] = team2[:name]
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
#####
|
|
74
|
-
# handle score
|
|
75
|
-
## m = (full) match hash incl. IdMatch, etc.
|
|
76
|
-
## returns string e.g. 4-4 or 4-3 a.e.t etc
|
|
77
|
-
|
|
78
|
-
score = _parse_score( m )
|
|
79
|
-
rec[:score] = score unless score.empty?
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
## check - never in use?
|
|
83
|
-
rec[:home] = true if m['IsHome']
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
## add country to stadium too - why? why not?
|
|
87
|
-
stadium = build_stadium( m['Stadium'] )
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if m['HomeTeam'] && m['AwayTeam'] ## assume match reports
|
|
91
|
-
rec[:stadium] = { name: stadium[:name],
|
|
92
|
-
city: stadium[:city],
|
|
93
|
-
street: stadium[:street],
|
|
94
|
-
country: stadium[:country] }
|
|
95
|
-
else
|
|
96
|
-
rec[:stadium] = { name: stadium[:name],
|
|
97
|
-
city: stadium[:city] }
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
attendance = m['Attendance']
|
|
101
|
-
rec[:attendance] = attendance.to_i(10) if attendance
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
rec
|
|
105
|
-
end
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
def _build_report_score( live, timeline=nil )
|
|
4
|
-
|
|
5
|
-
_scores = _build_score_from_goals( live )
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
score = nil
|
|
9
|
-
|
|
10
|
-
case live['ResultType']
|
|
11
|
-
when 1,4
|
|
12
|
-
## 1 => 'REGULAR',
|
|
13
|
-
## 4 => 'REGULAR/AGG', ## aggregate (1st/2nd leg) - regular
|
|
14
|
-
## add ht
|
|
15
|
-
## assert ft match
|
|
16
|
-
score = { ht: _scores[:ht][:score],
|
|
17
|
-
ft: _scores[:ft][:score]
|
|
18
|
-
}
|
|
19
|
-
when 3,5,8
|
|
20
|
-
score = { ht: _scores[:ht][:score],
|
|
21
|
-
ft: _scores[:ft][:score],
|
|
22
|
-
et: _scores[:et][:score],
|
|
23
|
-
}
|
|
24
|
-
when 2
|
|
25
|
-
## todo/fix - pull in timeline check too to check
|
|
26
|
-
## if any events recorded for extra time!!
|
|
27
|
-
score = { ht: _scores[:ht][:score],
|
|
28
|
-
ft: _scores[:ft][:score],
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
## note - only incl. extra-time (et) if a goal scored in extra time
|
|
32
|
-
score[:et] = _scores[:et][:score] unless _scores[:et][:minutes].empty?
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
score
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
def _build_report( live, timeline=nil )
|
|
41
|
-
rec = {}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
####
|
|
45
|
-
## add goals
|
|
46
|
-
players = Players.new
|
|
47
|
-
players.add( live['HomeTeam']['Players'] )
|
|
48
|
-
players.add( live['AwayTeam']['Players'] )
|
|
49
|
-
|
|
50
|
-
rec[:goals1] = build_goals( live['HomeTeam']['Goals'], players: players )
|
|
51
|
-
rec[:goals2] = build_goals( live['AwayTeam']['Goals'], players: players )
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
##########
|
|
55
|
-
## add penalty kicks / penalties
|
|
56
|
-
if live['ResultType'] == 2 ## aet, win on pens
|
|
57
|
-
if timeline.nil?
|
|
58
|
-
##
|
|
59
|
-
team1_code = live['HomeTeam']['Abbreviation']
|
|
60
|
-
team2_code = live['AwayTeam']['Abbreviation']
|
|
61
|
-
puts "!! ERROR - no timeline for match #{team1_code} v #{team2_code} with win on penalties!!"
|
|
62
|
-
exit 1
|
|
63
|
-
else
|
|
64
|
-
### get timeline with penalty shoot-out details
|
|
65
|
-
## note - requires team1/2_ids!!!
|
|
66
|
-
team1_id = live['HomeTeam']['IdTeam']
|
|
67
|
-
team2_id = live['AwayTeam']['IdTeam']
|
|
68
|
-
|
|
69
|
-
pens = build_penalties( timeline['Event'],
|
|
70
|
-
players: players,
|
|
71
|
-
team1_id: team1_id,
|
|
72
|
-
team2_id: team2_id )
|
|
73
|
-
pp pens
|
|
74
|
-
|
|
75
|
-
rec[:penalties] = pens
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
##
|
|
81
|
-
## add players by team1/team2
|
|
82
|
-
players1 = Players.new
|
|
83
|
-
players1.add( live['HomeTeam']['Players'] )
|
|
84
|
-
|
|
85
|
-
players2 = Players.new
|
|
86
|
-
players2.add( live['AwayTeam']['Players'] )
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
rec[:formation1] = live['HomeTeam']['Tactics'] ## e.g. "Tactics": "3-1-4-2"
|
|
90
|
-
rec[:lineup1] = players1.lineup ## starter XI
|
|
91
|
-
rec[:bench1] = players1.bench ## substitutes
|
|
92
|
-
|
|
93
|
-
rec[:formation2] = live['AwayTeam']['Tactics']
|
|
94
|
-
rec[:lineup2] = players2.lineup
|
|
95
|
-
rec[:bench2] = players2.bench
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
#####
|
|
99
|
-
## add bookings (yellow/red/red-yellow cards)
|
|
100
|
-
players1.add_bookings( live['HomeTeam']['Bookings'])
|
|
101
|
-
players2.add_bookings( live['AwayTeam']['Bookings'])
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
yellow1 = players1.yellowcards
|
|
105
|
-
red1 = players1.redcards
|
|
106
|
-
yellowred1 = players1.yellowredcards
|
|
107
|
-
rec[:yellow1] = yellow1 unless yellow1.empty?
|
|
108
|
-
rec[:red1] = red1 unless red1.empty?
|
|
109
|
-
rec[:yellowred1] = yellowred1 unless yellowred1.empty?
|
|
110
|
-
|
|
111
|
-
yellow2 = players2.yellowcards
|
|
112
|
-
red2 = players2.redcards
|
|
113
|
-
yellowred2 = players2.yellowredcards
|
|
114
|
-
rec[:yellow2] = yellow2 unless yellow2.empty?
|
|
115
|
-
rec[:red2] = red2 unless red2.empty?
|
|
116
|
-
rec[:yellowred2] = yellowred2 unless yellowred2.empty?
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
## add substitutions (off/on - in/out)
|
|
121
|
-
rec[:subs1] = build_subs( live['HomeTeam']['Substitutions'], players: players1 )
|
|
122
|
-
rec[:subs2] = build_subs( live['AwayTeam']['Substitutions'], players: players2 )
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
## add referees
|
|
126
|
-
officials = build_officials( live['Officials'], id: false )
|
|
127
|
-
|
|
128
|
-
if officials.empty?
|
|
129
|
-
## puts "!! WARN no refs / officials found"
|
|
130
|
-
else
|
|
131
|
-
rec[:referees] = officials
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
rec
|
|
135
|
-
end
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
##
|
|
4
|
-
## read & build match report
|
|
5
|
-
|
|
6
|
-
## use mk/build_report_basename - why? why not?
|
|
7
|
-
## fix-fix-fix - change to _match_basename !!!
|
|
8
|
-
## use by (match)report and (match)timeline !!!
|
|
9
|
-
def _report_basename( m )
|
|
10
|
-
### get match (live) details
|
|
11
|
-
team1_code = m['Home']['Abbreviation']
|
|
12
|
-
team2_code = m['Away']['Abbreviation']
|
|
13
|
-
localDateTime = parse_date_utc( m['LocalDate'] )
|
|
14
|
-
|
|
15
|
-
## e.g. 2020-06-24_RAP-AUS__54545454
|
|
16
|
-
basename = String.new
|
|
17
|
-
basename += localDateTime.strftime('%Y-%m-%d') ## i) date
|
|
18
|
-
basename += "_#{team1_code}-#{team2_code}" ## ii) team1 v team2
|
|
19
|
-
|
|
20
|
-
basename
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def _read_timeline( m, timeline_dir: )
|
|
26
|
-
return nil if m['Home'].nil? || m['Away'].nil?
|
|
27
|
-
|
|
28
|
-
basename = _report_basename( m )
|
|
29
|
-
basename += "__#{m['IdMatch']}"
|
|
30
|
-
|
|
31
|
-
path = "#{timeline_dir}/#{basename}.json"
|
|
32
|
-
|
|
33
|
-
## note - skip if no match report available!!!
|
|
34
|
-
if File.file?( path )
|
|
35
|
-
timeline = read_json_v2( path )
|
|
36
|
-
timeline
|
|
37
|
-
else
|
|
38
|
-
nil
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def _read_report( m, report_dir: )
|
|
43
|
-
return nil if m['Home'].nil? || m['Away'].nil?
|
|
44
|
-
|
|
45
|
-
## e.g. 2020-06-24_RAP-AUS__54545454
|
|
46
|
-
# note - add match id for "raw" match reports!!!
|
|
47
|
-
basename = _report_basename( m )
|
|
48
|
-
basename += "__#{m['IdMatch']}"
|
|
49
|
-
|
|
50
|
-
## #{indir}/#{slug}/matches/#{season.to_path}
|
|
51
|
-
path = "#{report_dir}/#{basename}.json"
|
|
52
|
-
|
|
53
|
-
## note - skip if no match report available!!!
|
|
54
|
-
if File.file?( path )
|
|
55
|
-
live = read_json_v2( path )
|
|
56
|
-
live
|
|
57
|
-
else
|
|
58
|
-
nil
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
def convert_reports( slug:, season:,
|
|
68
|
-
indir: '.',
|
|
69
|
-
outdir: './tmp' )
|
|
70
|
-
|
|
71
|
-
season = Season(season)
|
|
72
|
-
|
|
73
|
-
data = read_json_v2( "#{indir}/#{slug}/#{season.to_path}_matches.json" )
|
|
74
|
-
matches = data['Results'] ## only use results (match) array
|
|
75
|
-
puts " #{matches.size} match(es) in season #{season}"
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
report_dir = "#{indir}/#{slug}/matches/#{season.to_path}"
|
|
79
|
-
timeline_dir = "#{indir}/#{slug}/timelines/#{season.to_path}"
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
matches.each_with_index do |m, i|
|
|
84
|
-
live = _read_report( m, report_dir: report_dir )
|
|
85
|
-
|
|
86
|
-
## no report found; continue
|
|
87
|
-
next if live.nil?
|
|
88
|
-
|
|
89
|
-
## check for optional timeline
|
|
90
|
-
timeline = _read_timeline( m, timeline_dir: timeline_dir )
|
|
91
|
-
|
|
92
|
-
rec = {
|
|
93
|
-
meta: {
|
|
94
|
-
name: desc(live['SeasonName']),
|
|
95
|
-
slug: slug,
|
|
96
|
-
season: season.to_s,
|
|
97
|
-
generated: Time.now.to_s,
|
|
98
|
-
}
|
|
99
|
-
}.merge( _build_match( live ),
|
|
100
|
-
_build_report( live, timeline ))
|
|
101
|
-
|
|
102
|
-
## try update of score via goals from report
|
|
103
|
-
score_more = _build_report_score( live, timeline )
|
|
104
|
-
if score_more
|
|
105
|
-
rec[:score] = rec[:score].merge( score_more )
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
## build basename e.g 2026-07-15_ARG-ENG
|
|
110
|
-
basename = _report_basename( m )
|
|
111
|
-
outpath = "#{outdir}/#{season.to_path}/#{slug}/#{basename}.json"
|
|
112
|
-
write_json( outpath, rec )
|
|
113
|
-
end
|
|
114
|
-
end
|