footballdata-api 0.5.0 → 0.5.1
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 -1
- data/Rakefile +1 -1
- data/bin/fbdat +9 -23
- data/config/leagues_tier1.csv +2 -2
- data/lib/footballdata/convert.rb +9 -5
- data/lib/footballdata/leagues.rb +27 -0
- data/lib/footballdata/version.rb +1 -1
- data/lib/footballdata.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f57e1559b42ee3e85f0ebeca5f1886110fe4964e48b0c58c2f7bd6713c167b7
|
4
|
+
data.tar.gz: 1e2e40dd8ab8b2cb4c33f10331e9019116ef5453bec5d6f58a64567947f9121b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84d991d2f3a18b440da187df5ac140db10a763f51a07b42a6d7f0c120976ce7db64b155f33c02d0901eb81b788ff6dfb163c1076840261ca1a46aa30b41b93b1
|
7
|
+
data.tar.gz: aafab943f237494592d78238acdb44f84cd66f48170463a5a624f195eed0f8954770963334e287de5262390578abc6110abe3c89b75f4024418f580ff70de88b
|
data/CHANGELOG.md
CHANGED
data/Rakefile
CHANGED
data/bin/fbdat
CHANGED
@@ -190,34 +190,20 @@ end
|
|
190
190
|
## note - only use "generic" uniform league codes for now!!
|
191
191
|
|
192
192
|
|
193
|
+
autofiller = ->(league_query) {
|
194
|
+
seasons = find_league_seasons!( league_query ) || []
|
195
|
+
seasons[ 0 ] ## assume first is latest season
|
196
|
+
}
|
197
|
+
|
198
|
+
|
199
|
+
|
193
200
|
datasets = if opts[:file]
|
194
|
-
read_leagueset( opts[:file] )
|
201
|
+
read_leagueset( opts[:file], autofill: autofiller )
|
195
202
|
else
|
196
|
-
parse_leagueset_args( args )
|
203
|
+
parse_leagueset_args( args, autofill: autofiller )
|
197
204
|
end
|
198
205
|
|
199
206
|
|
200
|
-
## step 0 - validate and fill-up seasons etc.
|
201
|
-
datasets.each do |league_key, seasons|
|
202
|
-
## todo - find a better name
|
203
|
-
## use internal_league_code or such - why? why not?
|
204
|
-
### convenience helpers - lets you use eng.1, euro, etc.
|
205
|
-
## check if mapping for league_code
|
206
|
-
metal_league_code = find_league!( league_key )
|
207
|
-
|
208
|
-
## note - default to latest season of league
|
209
|
-
## might be 2024/25 or 2024 or
|
210
|
-
# for world cup 2022 or such
|
211
|
-
if seasons.empty?
|
212
|
-
season = case league_key
|
213
|
-
when 'world' then Season('2022')
|
214
|
-
when 'euro' then Season('2024')
|
215
|
-
when 'br.1', 'copa.l' then Season('2024')
|
216
|
-
else Season('2024/25')
|
217
|
-
end
|
218
|
-
seasons << season
|
219
|
-
end
|
220
|
-
end
|
221
207
|
|
222
208
|
## step 1 - download
|
223
209
|
datasets.each do |league_key, seasons|
|
data/config/leagues_tier1.csv
CHANGED
@@ -24,7 +24,7 @@ fr.1, FL1, 2024/25 2023/24 2022/23 2021/22 2020/21
|
|
24
24
|
it.1, SA, 2024/25 2023/24 2022/23 2021/22 2020/21
|
25
25
|
# SA - Serie A, Italy 15 seasons | 2019-08-24 - 2020-08-02 / matchday 27
|
26
26
|
|
27
|
-
br.1, BSA, 2024 2023 2022 2021 2020
|
27
|
+
br.1, BSA, 2025 2024 2023 2022 2021 2020
|
28
28
|
|
29
29
|
|
30
30
|
########
|
@@ -34,7 +34,7 @@ uefa.cl, CL, 2024/25 2023/24 2022/23 2021/22 2020/21
|
|
34
34
|
## was europe.cl / cl
|
35
35
|
## todo/check: use champs and NOT cl - why? why not?
|
36
36
|
|
37
|
-
copa.l, CLI, 2024 2023 2022 2021
|
37
|
+
copa.l, CLI, 2025 2024 2023 2022 2021
|
38
38
|
## Copa Libertadores
|
39
39
|
|
40
40
|
|
data/lib/footballdata/convert.rb
CHANGED
@@ -67,6 +67,7 @@ def self.convert( league:, season: )
|
|
67
67
|
|
68
68
|
season = Season( season ) ## cast (ensure) season class (NOT string, integer, etc.)
|
69
69
|
|
70
|
+
### note - find_league returns the metal_league_code
|
70
71
|
league_code = find_league!( league )
|
71
72
|
|
72
73
|
matches_url = Metal.competition_matches_url( league_code, season.start_year )
|
@@ -76,7 +77,14 @@ def self.convert( league:, season: )
|
|
76
77
|
data_teams = Webcache.read_json( teams_url )
|
77
78
|
|
78
79
|
|
79
|
-
|
80
|
+
###
|
81
|
+
## todo/fix - use find_by! - add upstream!!!
|
82
|
+
league_info = LeagueCodes.find_by( code: league, season: season )
|
83
|
+
## check for time zone
|
84
|
+
tz = league_info['tz']
|
85
|
+
pp tz
|
86
|
+
|
87
|
+
## note - for international club tournaments
|
80
88
|
## auto-add (fifa) country code e.g.
|
81
89
|
## Liverpool FC => Liverpool FC (ENG)
|
82
90
|
##
|
@@ -85,10 +93,6 @@ def self.convert( league:, season: )
|
|
85
93
|
'copa.l'].include?(league.downcase) ? true : false
|
86
94
|
|
87
95
|
|
88
|
-
## check for time zone
|
89
|
-
tz = find_zone!( league: league,
|
90
|
-
season: season )
|
91
|
-
pp tz
|
92
96
|
|
93
97
|
## build a (reverse) team lookup by name
|
94
98
|
puts "#{data_teams['teams'].size} teams"
|
data/lib/footballdata/leagues.rb
CHANGED
@@ -20,5 +20,32 @@ module Footballdata
|
|
20
20
|
end
|
21
21
|
code
|
22
22
|
end
|
23
|
+
|
24
|
+
###
|
25
|
+
# quick (and dirty) hack - return seasons by league code
|
26
|
+
# - todo/fix - use one find_league_info method for all or such
|
27
|
+
def self.find_league_seasons!( league )
|
28
|
+
@league_seasons ||= begin
|
29
|
+
recs = read_csv( "#{FootballdataApi.root}/config/leagues_tier1.csv" )
|
30
|
+
leagues = {}
|
31
|
+
recs.each do |rec|
|
32
|
+
leagues[ rec['key'] ] = rec['seasons']
|
33
|
+
end
|
34
|
+
leagues
|
35
|
+
end
|
36
|
+
|
37
|
+
key = league.downcase
|
38
|
+
seasons = @league_seasons[ key ]
|
39
|
+
if seasons.nil?
|
40
|
+
puts "!! ERROR - no code/mapping found for league >#{league}<"
|
41
|
+
puts " mappings include:"
|
42
|
+
pp @league_seasons
|
43
|
+
exit 1
|
44
|
+
end
|
45
|
+
|
46
|
+
### split string into array
|
47
|
+
seasons = seasons.split( /[ ]+/ )
|
48
|
+
seasons
|
49
|
+
end
|
23
50
|
end # module Footballdata
|
24
51
|
|
data/lib/footballdata/version.rb
CHANGED
data/lib/footballdata.rb
CHANGED
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: footballdata-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: leagues
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|