footballdata-api 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97e75a5cbf4b952cb018a40c4ff790a201c26cbd95af1027bae3e7ac2153d1b5
4
- data.tar.gz: a4d0cfd2e6ff636f030cd6c4d4d949f2173763cc39352b28b3425ad9aa077796
3
+ metadata.gz: 6712b00c0f67e3c23fbdd0cd9f5436e9683dedc75fa53028cc72a07fa36437e2
4
+ data.tar.gz: 8d9ae9147cba11203f2f9755ad1d0a79b52715dab2d03027bdc340a6e4e50d87
5
5
  SHA512:
6
- metadata.gz: d1c8650effbb80caec23410ee3fc739f379976359f044b29eff3a02d7bd82f23d76f7daffd6b2cfa76dfbdcbc6be53e178a04929b02401a30641f29cb3d0bd18
7
- data.tar.gz: 39d810683288fc35703f19fd1643af8bb0b8332168ae4d4e819eb681444ea4c27e7c0b36daccf27fc97d02704aa6325696579a6d5b3941988cd6bef8f400d0ec
6
+ metadata.gz: b4a5f064656d889e36b352dcedfc77cd503c6f5f2f9ce8fc25a84ac3ece1ecb8acab941a3f21a647e1278f9f87b8e232e1958acca8138b50a6f073351c677856
7
+ data.tar.gz: f9bdb77161614d3d381e187aad999f5f0ff67835b920bdd0d31ea553cdab89ab849489f59cb95c98f78088a79cb39a4e9f94d673914048f83b179b6a207dbbc5
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 0.4.2
1
+ ### 0.4.3
2
2
 
3
3
  ### 0.0.1 / 2024-07-03
4
4
 
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # footballdata-api - get football data via Daniel Freitag's football-data.org api v4
1
+ # footballdata-api - get football data via Daniel Freitag's football-data.org api v4
2
2
 
3
3
 
4
4
  * home :: [github.com/sportdb/sport.db](https://github.com/sportdb/sport.db)
@@ -48,14 +48,13 @@ Footballdata.schedule( league: 'eng.2', season: '2020/21' )
48
48
 
49
49
  Footballdata.schedule( league: 'de.1', season: '2020/21' )
50
50
  Footballdata.schedule( league: 'es.1', season: '2020/21' )
51
-
52
51
  Footballdata.schedule( league: 'fr.1', season: '2020/21' )
53
52
  Footballdata.schedule( league: 'it.1', season: '2020/21' )
54
53
 
55
54
  Footballdata.schedule( league: 'nl.1', season: '2020/21' )
56
55
  Footballdata.schedule( league: 'pt.1', season: '2020/21' )
57
56
 
58
- Footballdata.schedule( league: 'cl', season: '2020/21' )
57
+ Footballdata.schedule( league: 'uefa.cl', season: '2020/21' )
59
58
 
60
59
  # note: Brasileirão - season is a calendar year (NOT an academic year)
61
60
  Footballdata.schedule( league: 'br.1', season: '2020' )
@@ -83,7 +82,7 @@ require 'footballdata'
83
82
  'it.1',
84
83
  'nl.1',
85
84
  'pt.1',
86
- 'cl',
85
+ 'uefa.cl',
87
86
  ].each do |league|
88
87
  Footballdata.convert( league: league, season: '2020/21' )
89
88
  end
data/Rakefile CHANGED
@@ -19,6 +19,7 @@ Hoe.spec 'footballdata-api' do
19
19
 
20
20
  self.extra_deps = [
21
21
  ['football-timezones'],
22
+ ['fifa'],
22
23
  ['webget'],
23
24
  ]
24
25
 
@@ -3,6 +3,8 @@ module Footballdata
3
3
 
4
4
  #######
5
5
  ## map round-like to higher-level stages
6
+ ## fix - map by league codes
7
+ ## or * (all)
6
8
  STAGES = {
7
9
  'REGULAR_SEASON' => ['Regular'],
8
10
 
@@ -36,6 +38,31 @@ STAGES = {
36
38
 
37
39
 
38
40
 
41
+ def self.team_autofill( name, teams: )
42
+ ## note - no country for place holder teams
43
+ return name if name == 'N.N.'
44
+
45
+ ## add (fifa) country code e.g.
46
+ ## Liverpool FC => Liverpool FC (ENG)
47
+ ## or Liverpool FC => Liverpool FC (URU)
48
+ rec = teams[ name ]
49
+ if rec.nil?
50
+ puts "!! ERROR - no team record found in teams.json for #{name}"
51
+ pp teams.keys
52
+ exit 1
53
+ end
54
+
55
+ country_name = rec['area']['name']
56
+ country = Fifa.world.find_by_name( country_name )
57
+ if country.nil?
58
+ puts "!! ERROR - no country record found for #{country_name}"
59
+ exit 1
60
+ end
61
+
62
+ "#{name} (#{country.code})"
63
+ end
64
+
65
+
39
66
 
40
67
  def self.convert( league:, season: )
41
68
 
@@ -50,6 +77,14 @@ def self.convert( league:, season: )
50
77
  data_teams = Webcache.read_json( teams_url )
51
78
 
52
79
 
80
+ ## note - for internation club tournaments
81
+ ## auto-add (fifa) country code e.g.
82
+ ## Liverpool FC => Liverpool FC (ENG)
83
+ ##
84
+ ## todo/fix - move flag to league_info via .csv config - why? why not?
85
+ clubs_intl = ['uefa.cl',
86
+ 'copa.l'].include?(league.downcase) ? true : false
87
+
53
88
 
54
89
  ## check for time zone
55
90
  tz = find_zone!( league: league,
@@ -94,10 +129,17 @@ matches.each do |m|
94
129
  team1 = m['homeTeam']['name'] || 'N.N.'
95
130
  team2 = m['awayTeam']['name'] || 'N.N.'
96
131
 
97
- score = m['score']
132
+ ## auto-fix copa.l 2024
133
+ ## !! ERROR: unsupported match status >IN_PLAY< - sorry:
134
+ if m['status'] == 'IN_PLAY' &&
135
+ team1 == 'Club Aurora' && team2 == 'FBC Melgar'
136
+ m['status'] = 'FINISHED'
137
+ end
98
138
 
99
139
 
100
140
 
141
+ score = m['score']
142
+
101
143
  group = m['group']
102
144
  ## GROUP_A
103
145
  ## shorten group to A|B|C etc.
@@ -151,8 +193,16 @@ matches.each do |m|
151
193
  end
152
194
 
153
195
 
154
- teams[ team1 ] += 1
155
- teams[ team2 ] += 1
196
+ teams[ team1 ] += 1
197
+ teams[ team2 ] += 1
198
+
199
+ ####
200
+ # auto-add (fifa) country code if int'l club tournament
201
+ if clubs_intl
202
+ team1 = team_autofill( team1, teams: teams_by_name )
203
+ team2 = team_autofill( team2, teams: teams_by_name )
204
+ end
205
+
156
206
 
157
207
  ### mods - rename club names
158
208
  unless mods.nil? || mods.empty?
@@ -161,13 +211,6 @@ matches.each do |m|
161
211
  end
162
212
 
163
213
 
164
- ## auto-fix copa.l 2024
165
- ## !! ERROR: unsupported match status >IN_PLAY< - sorry:
166
- if m['status'] == 'IN_PLAY' &&
167
- team1 == 'Club Aurora' && team2 == 'FBC Melgar'
168
- m['status'] = 'FINISHED'
169
- end
170
-
171
214
 
172
215
  comments = ''
173
216
  ft = ''
@@ -178,7 +221,7 @@ matches.each do |m|
178
221
  stats['status'][m['status']] += 1 ## track status counts
179
222
 
180
223
  case m['status']
181
- when 'SCHEDULED', 'TIMED' ## , 'IN_PLAY'
224
+ when 'SCHEDULED', 'TIMED' ## , 'IN_PLAY', 'PAUSED'
182
225
  ft = ''
183
226
  ht = ''
184
227
  when 'FINISHED'
@@ -2,7 +2,7 @@
2
2
  module FootballdataApi
3
3
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
4
4
  MINOR = 4
5
- PATCH = 2
5
+ PATCH = 3
6
6
  VERSION = [MAJOR,MINOR,PATCH].join('.')
7
7
 
8
8
  def self.version
data/lib/footballdata.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  ## 3rd party (our own)
2
2
  require 'football/timezones' # note - pulls in season/formats, cocos & tzinfo
3
3
  require 'webget' ## incl. webget, webcache, webclient, etc.
4
+ require 'fifa'
4
5
 
5
6
 
6
7
  module Footballdata
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: footballdata-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-15 00:00:00.000000000 Z
11
+ date: 2024-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: football-timezones
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: fifa
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: webget
29
43
  requirement: !ruby/object:Gem::Requirement