worldfootball 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,200 +1,146 @@
1
1
 
2
2
 
3
- require_relative 'leagues/europe'
4
- require_relative 'leagues/north_america'
5
- require_relative 'leagues/south_america'
6
- require_relative 'leagues/pacific'
7
- require_relative 'leagues/asia'
3
+ module Worldfootball
4
+ class LeagueConfig
5
+ def initialize
6
+ @table = {}
7
+ end
8
8
 
9
+ class LeagueItem # nested inside LeagueConfig
10
+ attr_reader :key, :slug
9
11
 
10
- module Worldfootball
12
+ def initialize( key:, slug: )
13
+ @key = key
14
+ @slug = slug
11
15
 
12
- LEAGUES = [LEAGUES_EUROPE,
13
- LEAGUES_NORTH_AMERICA,
14
- LEAGUES_SOUTH_AMERICA,
15
- LEAGUES_PACIFIC,
16
- LEAGUES_ASIA].reduce({}) { |mem,h| mem.merge!( h ); mem }
16
+ @seasons = nil
17
+ end
17
18
 
18
19
 
19
- class League
20
- def initialize( key, data )
21
- @key = key
22
- ## @data = data
20
+ def seasons
21
+ ## auto-(down)load on first request
23
22
 
24
- @pages = data[:pages]
25
- @season_proc = data[:season] || ->(season) { nil }
26
- end
23
+ @seasons ||= begin
24
+ ### todo/fix:
25
+ ## use from cache if not older than 1 (or 5/10?) hour(s) or such
26
+ ## why? why not?
27
+ Worldfootball::Metal.download_schedule( @slug )
28
+ page = Worldfootball::Page::Schedule.from_cache( @slug )
27
29
 
28
- def key() @key; end
29
-
30
- def pages( season: )
31
- ## note: return for no stages / simple case - just a string
32
- ## and for the stages case ALWAYS an array (even if it has only one page (with stage))
33
-
34
- if @pages.is_a?( String )
35
- # assume always "simple/regular" format w/o stages
36
- slug = @pages
37
- { slug: fill_slug( slug, season: season ) }
38
- else
39
- ## check for league format / stages
40
- ## return array (of strings) or nil (for no stages - "simple" format)
41
- indices = @season_proc.call( season )
42
- if indices.nil?
43
- puts "!! ERROR - no configuration found for season >#{season}< for league >#{@key}< found; sorry"
44
- exit 1
45
- elsif indices.is_a?( Integer ) ## single number - single/regular format w/o stage
46
- # note: starting with 0 (always use idx-1) !!!
47
- slug = if @pages.is_a?( Array )
48
- @pages[indices-1]
49
- else ## assume hash (and key is page slug)
50
- @pages.keys[indices-1]
51
- end
52
- { slug: fill_slug( slug, season: season ) }
53
- else ## assume regular case - array of integers
54
- recs = []
55
- indices.each do |idx|
56
- slug = key = @pages.keys[idx-1]
57
- recs << { slug: fill_slug( slug, season: season ),
58
- stage: @pages[key] } ## note: include mapping for page to stage name!!
59
- end
60
- recs
61
- end
62
- end
63
- end # pages
64
-
65
-
66
- ######
67
- # helper method
68
- def fill_slug( slug, season: )
69
- ## note: fill-in/check for place holders too
70
- slug = if slug.index( '{season}' )
71
- slug.sub( '{season}', season.to_path( :long ) ) ## e.g. 2010-2011
72
- elsif slug.index( '{end_year}' )
73
- slug.sub( '{end_year}', season.end_year.to_s ) ## e.g. 2011
74
- else
75
- ## assume convenience fallback - append regular season
76
- "#{slug}-#{season.to_path( :long )}"
77
- end
78
-
79
- puts " slug=>#{slug}<"
80
-
81
- slug
82
- end
83
- end # class League
30
+ ## pp page.seasons
31
+ =begin
32
+ [{:text=>"2024/2025", :ref=>"aut-oefb-cup-2024-2025"},
33
+ {:text=>"2023/2024", :ref=>"aut-oefb-cup-2023-2024"},
34
+ {:text=>"2022/2023", :ref=>"aut-oefb-cup-2022-2023"},
35
+ {:text=>"2021/2022", :ref=>"aut-oefb-cup-2021-2022"},
36
+ =end
84
37
 
38
+ recs = page.seasons.map { |rec| [rec[:text], rec[:ref]] }
39
+ pp recs
40
+ puts " #{recs.size} record(s)"
41
+ recs
85
42
 
43
+ seasons = {}
44
+ ## generate lookup table by season
45
+ recs.each do |text,slug|
86
46
 
87
- def self.find_league( key ) ## league info lookup
88
- data = LEAGUES[ key ]
89
- if data.nil?
90
- puts "!! ERROR - no league found for >#{key}<; add to leagues tables"
91
- exit 1
92
- end
93
- League.new( key, data ) ## use a convenience wrapper for now
94
- end
47
+ ##
48
+ ## fix upstream?? - allow multi-year seasons? why? why not?
49
+ ## for now ignore special case and collect more real-world cases/samples
50
+ ## if possible
51
+ ## ["2019-2021 Playoffs", "regionalliga-bayern-2019-2021-playoffs"],
52
+ ## ["2019-2021", "regionalliga-bayern-2019-2021"],
53
+ ##
95
54
 
96
55
 
56
+ season, stage = text.split( ' ', 2 )
97
57
 
98
- ### "reverse" lookup by page - returns league AND season
99
- ## note: "blind" season template para - might be season or start_year etc.
100
- ## e.g. {season} or {start_year} becomes {}
58
+ ## todo/fix: add a waring here and auto log to logs.txt!!!!
59
+ next if season == '2019-2021'
101
60
 
102
- PAGE_VAR_RE = /{
103
- [^}]+
104
- }/x
61
+ season = Season.parse( season )
105
62
 
63
+ seasons[ season.key ] ||= []
64
+ seasons[ season.key] << [slug, stage]
65
+ end
66
+ seasons
67
+ end
68
+ @seasons
69
+ end
106
70
 
107
- def self.norm_slug( slug )
108
- ## assume convenience fallback - append regular season
109
- slug.index( '{' ) ? slug : "#{slug}-{season}"
110
- end
111
71
 
112
- PAGES ||=
113
- LEAGUES.reduce( {} ) do |pages, (key, data)|
114
- if data[:pages].is_a?( String )
115
- slug = data[:pages]
116
- slug = Worldfootball.norm_slug( slug )
117
- pages[ slug.sub( PAGE_VAR_RE, '{}') ] = { league: key, slug: slug }
118
- elsif data[:pages].is_a?( Array )
119
- data[:pages].each do |slug|
120
- slug = Worldfootball.norm_slug( slug )
121
- pages[ slug.sub( PAGE_VAR_RE, '{}') ] = { league: key, slug: slug }
122
- end
123
- ## elsif data[:pages].nil?
124
- ## todo/fix: missing pages!!!
125
- else ## assume hash
126
- ## add stage to pages too - why? why not?
127
- data[:pages].each do |slug, stage|
128
- slug = Worldfootball.norm_slug( slug )
129
- pages[ slug.sub( PAGE_VAR_RE, '{}') ] = { league: key, slug: slug, stage: stage }
130
- end
131
- end
132
- pages
133
- end
134
-
135
- # e.g. 2000 or 2000-2001
136
- SEASON_RE = /[0-9]{4}
137
- (?:
138
- -[0-9]{4}
139
- )?
140
- /x
141
-
142
-
143
- def self.find_page!( slug )
144
- page = find_page( slug )
145
- if page.nil?
146
- puts "!! ERROR: no mapping for page >#{slug}< found; sorry"
147
-
148
- season_str = nil
149
- norm = slug.sub( SEASON_RE ) do |match| ## replace season with var placeholder {}
150
- season_str = match ## keep reference to season str
151
- '{}' ## replace with {}
152
- end
153
-
154
- puts " season: >#{season_str}<"
155
- puts " slug (norm): >#{norm}<"
156
- puts
157
- ## pp PAGES
158
- exit 1
72
+ def pages!( season: )
73
+ pages = pages( season: season )
74
+ if pages.nil?
75
+ puts "!! ERROR - no season #{season} found for #{key}; seasons incl:"
76
+ pp seasons.keys
77
+ puts " #{seasons.keys.size} season(s)"
78
+ exit 1
159
79
  end
160
- page
80
+ pages
161
81
  end
162
82
 
83
+ def pages( season: )
84
+ ### lookup league pages/slugs by season
85
+ season = Season( season )
86
+
87
+ ## note: assume reverse chronological order
88
+ ## reverse here
89
+ ## e.g.
90
+ ## [["aut-bundesliga-2023-2024-qualifikationsgruppe", "Qualifikationsgruppe"],
91
+ ## ["aut-bundesliga-2023-2024-playoff", "Playoff"],
92
+ ## ["aut-bundesliga-2023-2024-meistergruppe", "Meistergruppe"],
93
+ ## ["aut-bundesliga-2023-2024", nil]]
94
+ ## =>
95
+ ## [["aut-bundesliga-2023-2024", nil],
96
+ ## ["aut-bundesliga-2023-2024-meistergruppe", "Meistergruppe"],
97
+ ## ["aut-bundesliga-2023-2024-playoff", "Playoff"],
98
+ ## ["aut-bundesliga-2023-2024-qualifikationsgruppe", "Qualifikationsgruppe"]]
99
+ recs = seasons[season.key]
100
+ recs ? recs.reverse : nil
101
+ end
102
+ end # class LeagueItem
163
103
 
164
104
 
165
- def self.find_page( slug )
166
- ## return league key and season
167
- season_str = nil
168
- norm = slug.sub( SEASON_RE ) do |match| ## replace season with var placeholder {}
169
- season_str = match ## keep reference to season str
170
- '{}' ## replace with {}
171
- end
105
+ def add( recs )
106
+ recs.each do |rec|
107
+ @table[ rec['key'] ] = LeagueItem.new( key: rec['key'],
108
+ slug: rec['slug'] )
109
+ end
110
+ end
111
+
112
+ def [](key) @table[key.to_s.downcase]; end
113
+ def keys() @table.keys; end
114
+ def size() @table.size; end
115
+ end # class LeagueConfig
172
116
 
173
- if season_str.nil?
174
- puts "!! ERROR: no season found in page slug >#{slug}<; sorry"
175
- exit 1
176
- end
177
117
 
178
- rec = PAGES[ norm ]
179
- return nil if rec.nil?
180
-
181
-
182
- league_key = rec[:league]
183
- slug_tmpl = rec[:slug]
184
- season = if slug_tmpl.index( '{start_year}' )
185
- ## todo/check - season_str must be year (e.g. 2020 or such and NOT 2020-2021)
186
- Season( "#{season_str.to_i}-#{season_str.to_i+1}" )
187
- elsif slug_tmpl.index( '{end_year}' )
188
- ## todo/check - season_str must be year (e.g. 2020 or such and NOT 2020-2021)
189
- Season( "#{season_str.to_i-1}-#{season_str.to_i}" )
190
- else ## assume "regular" seasson - pass through as is
191
- Season( season_str )
192
- end
193
-
194
- ## return hash table / record
195
- { league: league_key,
196
- season: season.key }
118
+ LEAGUES = LeagueConfig.new
119
+ recs = read_csv( "#{Worldfootball.root}/config/leagues.csv" )
120
+ pp recs
121
+ puts " #{recs.size} league(s)"
122
+ LEAGUES.add( recs )
123
+
124
+
125
+
126
+ ###########
127
+ # (strict) lookup convenience helpers with error reporting
128
+ # AND abort if no lookup found
129
+ def self.find_league!( league_code )
130
+ league = LEAGUES[ league_code ]
131
+ if league.nil?
132
+ puts "!! ERROR - no config found for #{league_code}; leagues incl:"
133
+ pp LEAGUES.keys
134
+ puts " #{LEAGUES.size} leagues(s)"
135
+ exit 1
197
136
  end
137
+ league
138
+ end
198
139
 
140
+ def self.find_league_pages!( league:, season: )
141
+ league = find_league!( league )
142
+ pages = league.pages!( season: season )
143
+ pages
144
+ end
145
+ end # module Worldfootball
199
146
 
200
- end # module Worldfootball
@@ -16,6 +16,9 @@ end
16
16
 
17
17
 
18
18
 
19
+ MODS = {}
20
+
21
+ =begin
19
22
  MODS = {
20
23
  'at' => {
21
24
  ## AT 1
@@ -42,7 +45,7 @@ MODS = {
42
45
  'Wellington Phoenix (R)' => 'Wellington Phoenix Reserves',
43
46
  },
44
47
  }
45
-
48
+ =end
46
49
 
47
50
 
48
51
  ## fix/patch known score format errors in at/de cups
@@ -65,7 +68,11 @@ SCORE_ERRORS = {
65
68
  ## 2010/11
66
69
  '2010-11-24' => [ 'Ergotelis', 'Olympiakos Piräus', ['0-2 (0-0, 0-0, 0-0)', '0-2 (0-0)']],
67
70
  '2010-11-28' => [ 'Panserraikos', 'Aris Saloniki', ['1-0 (1-0, 0-0, 0-0)', '1-0 (1-0)']],
68
- }
71
+ },
72
+ 'at.cup' => {
73
+ ## 2023/24
74
+ '2023-07-22' => [ 'SV Leobendorf', 'SV Horn', ['3-2 (2-0, 2-2, 3-2) n.V.', '3-2 (2-0, 2-2) n.V.']],
75
+ },
69
76
  }
70
77
 
71
78
 
@@ -102,5 +102,14 @@ def assert( cond, msg )
102
102
  end
103
103
  end
104
104
 
105
+
106
+ def log( msg ) ### append to log
107
+ File.open( './logs.txt', 'a:utf-8' ) do |f|
108
+ f.write( msg )
109
+ f.write( "\n" )
110
+ end
111
+ end
112
+
113
+
105
114
  end # class Page
106
115
  end # module Worldfootball
@@ -24,6 +24,8 @@ class Schedule < Page ## note: use nested class for now - why? why not?
24
24
  # puts table.class.name #=> Nokogiri::XML::Element
25
25
  # puts table.text
26
26
 
27
+ assert( table, 'no table.standard_tabelle found in schedule page!!')
28
+
27
29
  trs = table.css( 'tr' )
28
30
  # puts trs.size
29
31
  i = 0
@@ -34,6 +36,9 @@ class Schedule < Page ## note: use nested class for now - why? why not?
34
36
  rows = []
35
37
 
36
38
 
39
+
40
+ trs.each do |tr|
41
+
37
42
  ## ghost trs? what for? see for an example in bra
38
43
  ## check for style display:none - why? why not?
39
44
  ##
@@ -45,10 +50,15 @@ class Schedule < Page ## note: use nested class for now - why? why not?
45
50
  ## </td>
46
51
  ## <td colspan="2"></td>
47
52
  ## </tr>
48
-
49
-
50
- trs.each do |tr|
51
-
53
+ ##
54
+ # <tr class="e2-parent" data-liga_id="530" data-gs_match_id="10259222"
55
+ # style="display:none;">
56
+ ## <td colspan="2"></td>
57
+ ## <td colspan="3">
58
+ ## <span class="e2" data-liga_id="530" data-gs_match_id="10259222"></span>
59
+ ## </td>
60
+ ## <td colspan="2"></td>
61
+ ## </tr>
52
62
  if tr['style'] && tr['style'].index( 'display') &&
53
63
  tr['style'].index( 'none')
54
64
  puts "!! WARN: skipping ghost line >#{tr.text.strip}<"
@@ -58,6 +68,15 @@ class Schedule < Page ## note: use nested class for now - why? why not?
58
68
 
59
69
  i += 1
60
70
 
71
+ ## puts "[debug] row #{i} >#{tr.text.strip}<"
72
+
73
+ ### note - assume for now match lines use tds
74
+ ## and round lines use ths (NOT tds)!!
75
+ ## e.g. <th colspan="7">8. Spieltag</th>
76
+
77
+ ths = tr.css( 'th' )
78
+ tds = tr.css( 'td' )
79
+
61
80
  if tr.text.strip =~ /Spieltag/ ||
62
81
  tr.text.strip =~ /[1-9]\.[ ]Runde|
63
82
  Qual\.[ ][1-9]\.[ ]Runde| # see EL or CL Quali
@@ -68,8 +87,26 @@ class Schedule < Page ## note: use nested class for now - why? why not?
68
87
  Halbfinale|
69
88
  Finale|
70
89
  Gruppe[ ][A-Z]| # see CL
71
- Playoffs # see EL Quali
90
+ Gruppe[ ][1-9]| # see slv-primera-division-2020-2021-clausura_3
91
+ Playoffs| # see EL Quali
92
+ Entscheidungsspiel| # see Serie A 2022-23 Entscheidung Abstieg
93
+ Spiele| # see Serie A 1960-61 Relegation
94
+ 3\.[ ]Platz| # see bra-serie-a-2000-yellow-module-playoffs
95
+ Spiel[ ]um[ ]Platz[ ]3| # see campeonato-2009-cuadrangulares-deportivo-cuenca-cs-emelec
96
+ Relegation| # see egy-premiership-2013-2014-abstiegsplayoff
97
+ Copa[ ]Libertadores| # see ecu-campeonato-2012-segunda-etapa-playoffs
98
+ Copa[ ]Sudamericana| # see campeonato-2012-liguilla-final-playoffs-cs-emelec-ldu-quito
99
+ Repechaje| # see nca-liga-primera-2023-2024-clausura-playoffs
100
+ Final[ ]de[ ]Grupos| # see hon-liga-nacional-2020-2021-clausura-playoffs
101
+ Gran[ ]Final| # see liga-nacional-2020-2021-apertura-playoffs-finale-olimpia-motagua
102
+ Finalrunde| # see hon-liga-nacional-2019-2020-apertura-pentagonal
103
+ Zona[ ]A| # see gua-liga-nacional-2020-2021-clausura
104
+ Zona[ ]B| # see liga-nacional-2020-2021-clausura-zona-a-comunicaciones-deportivo-malacateco
105
+ Interzone| # see liga-nacional-2020-2021-clausura-zona-b-achuapa-sanarate
106
+ Final[ ]Segunda[ ]Ronda| # see crc-primera-division-2018-2019-apertura-playoffs
107
+ Quadrangular # see crc-primera-division-2016-2017-verano-playoffs
72
108
  /x
109
+
73
110
  puts
74
111
  print '[%03d] ' % i
75
112
  ## print squish( tr.text )
@@ -77,8 +114,14 @@ class Schedule < Page ## note: use nested class for now - why? why not?
77
114
  print "\n"
78
115
 
79
116
  last_round = tr.text.strip
117
+ elsif ths.count > 0 &&
118
+ tds.count == 0
119
+ ## check for round NOT yet configured!!!
120
+ puts "!! WARN: found unregistered round line >#{tr.text.strip}<"
121
+ log( "!! WARN: found unregistered round line >#{tr.text.strip}< in page #{title}" )
122
+
123
+ last_round = tr.text.strip
80
124
  else ## assume table row (tr) is match line
81
- tds = tr.css( 'td' )
82
125
 
83
126
  date_str = squish( tds[0].text )
84
127
  time_str = squish( tds[1].text )
@@ -164,12 +207,21 @@ class Schedule < Page ## note: use nested class for now - why? why not?
164
207
  score_str = score_str.gsub( ':', '-' )
165
208
 
166
209
  ## convert date from 25.10.2019 to 2019-25-10
167
- date = Date.strptime( date_str, '%d.%m.%Y' )
210
+
211
+ ## special case for '00.00.0000'
212
+ ## CANNOT parse
213
+ ## use empty date - why? why not?
214
+
215
+ date = if date_str == '00.00.0000'
216
+ nil
217
+ else
218
+ Date.strptime( date_str, '%d.%m.%Y' )
219
+ end
168
220
 
169
221
  ## note: keep structure flat for now
170
222
  ## (AND not nested e.g. team:{text:,ref:}) - why? why not?
171
223
  rows << { round: last_round,
172
- date: date.strftime( '%Y-%m-%d' ),
224
+ date: date ? date.strftime( '%Y-%m-%d' ) : '',
173
225
  time: time_str,
174
226
  team1: team1_str,
175
227
  team1_ref: team1_ref,
@@ -2,7 +2,7 @@
2
2
  module Worldfootball
3
3
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
4
4
  MINOR = 1
5
- PATCH = 1
5
+ PATCH = 2
6
6
  VERSION = [MAJOR,MINOR,PATCH].join('.')
7
7
 
8
8
  def self.version
data/lib/worldfootball.rb CHANGED
@@ -13,22 +13,22 @@ require 'nokogiri'
13
13
  # our own code
14
14
  require_relative 'worldfootball/version'
15
15
  require_relative 'worldfootball/leagues'
16
+ require_relative 'worldfootball/config' ## rename to setup/timezones/layouts or such?
16
17
  require_relative 'worldfootball/download'
17
18
  require_relative 'worldfootball/page'
18
19
  require_relative 'worldfootball/page_schedule'
19
20
  require_relative 'worldfootball/page_report'
21
+ require_relative 'worldfootball/cache'
20
22
 
21
23
 
22
24
  require_relative 'worldfootball/mods'
23
25
  require_relative 'worldfootball/vacuum'
24
26
  require_relative 'worldfootball/build'
27
+ require_relative 'worldfootball/build-parse_score'
25
28
  require_relative 'worldfootball/convert'
26
29
  require_relative 'worldfootball/convert_reports'
27
30
 
28
31
 
29
- require_relative 'worldfootball/generator'
30
-
31
-
32
32
 
33
33
  module Worldfootball
34
34
 
@@ -55,12 +55,6 @@ end # module Worldfootball
55
55
 
56
56
 
57
57
 
58
- ### for processing tool
59
- ## (auto-)add sportdb/writer (pulls in sportdb/catalogs and gitti)
60
- # require 'sportdb/writers'
61
-
62
-
63
-
64
58
 
65
59
  puts Worldfootball.banner ## say hello
66
60
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: worldfootball
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
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-07-07 00:00:00.000000000 Z
11
+ date: 2024-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: season-formats
@@ -116,24 +116,16 @@ files:
116
116
  - README.md
117
117
  - Rakefile
118
118
  - bin/wfb
119
+ - config/leagues.csv
119
120
  - lib/worldfootball.rb
121
+ - lib/worldfootball/build-parse_score.rb
120
122
  - lib/worldfootball/build.rb
123
+ - lib/worldfootball/cache.rb
124
+ - lib/worldfootball/config.rb
121
125
  - lib/worldfootball/convert.rb
122
126
  - lib/worldfootball/convert_reports.rb
123
127
  - lib/worldfootball/download.rb
124
- - lib/worldfootball/generator.rb
125
128
  - lib/worldfootball/leagues.rb
126
- - lib/worldfootball/leagues/asia.rb
127
- - lib/worldfootball/leagues/europe--british_isles.rb
128
- - lib/worldfootball/leagues/europe--central.rb
129
- - lib/worldfootball/leagues/europe--eastern.rb
130
- - lib/worldfootball/leagues/europe--northern.rb
131
- - lib/worldfootball/leagues/europe--southern.rb
132
- - lib/worldfootball/leagues/europe--western.rb
133
- - lib/worldfootball/leagues/europe.rb
134
- - lib/worldfootball/leagues/north_america.rb
135
- - lib/worldfootball/leagues/pacific.rb
136
- - lib/worldfootball/leagues/south_america.rb
137
129
  - lib/worldfootball/mods.rb
138
130
  - lib/worldfootball/page.rb
139
131
  - lib/worldfootball/page_report.rb
@@ -154,7 +146,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
154
146
  requirements:
155
147
  - - ">="
156
148
  - !ruby/object:Gem::Version
157
- version: 2.2.2
149
+ version: 3.1.0
158
150
  required_rubygems_version: !ruby/object:Gem::Requirement
159
151
  requirements:
160
152
  - - ">="
@@ -1,33 +0,0 @@
1
-
2
- ##
3
- ### check - change Generator to Writer
4
- ## and write( league:, season: ) - why? why not?
5
-
6
- module Worldfootball
7
- class Generator
8
-
9
-
10
-
11
- ###########
12
- ## always download for now - why? why not?
13
- ## support cache - why? why not?
14
- def generate( league:, season: )
15
-
16
- ## for testing use cached version always - why? why not?
17
- ## step 1 - download
18
- Worldfootball.schedule( league: league, season: season )
19
-
20
- ## step 2 - convert (to .csv)
21
-
22
- ## todo/fix - convert in-memory and return matches
23
- Worldfootball.convert( league: league, season: season )
24
-
25
- source_dir = Worldfootball.config.convert.out_dir
26
-
27
- Writer.write( league: league,
28
- season: season,
29
- source: source_dir )
30
- end # def generate
31
-
32
- end # class Generator
33
- end # module Worldfootball
@@ -1,53 +0,0 @@
1
- module Worldfootball
2
-
3
- LEAGUES_ASIA = {
4
-
5
- # /chn-super-league-2020/
6
- 'cn.1' => { pages: 'chn-super-league' },
7
-
8
- # /jpn-j1-league-2020/
9
- 'jp.1' => { pages: 'jpn-j1-league' },
10
-
11
-
12
- =begin
13
- 2020 -- >/alle_spiele/kor-k-league-1-2020/<
14
- 2019 Meisterschaft -- >/alle_spiele/kor-k-league-1-2019-meisterschaft/<
15
- 2019 Abstieg -- >/alle_spiele/kor-k-league-1-2019-abstieg/<
16
- 2019 -- >/alle_spiele/kor-k-league-1-2019/<
17
- 2018 Meisterschaft -- >/alle_spiele/kor-k-league-1-2018-meisterschaft/<
18
- 2018 Abstieg -- >/alle_spiele/kor-k-league-1-2018-abstieg/<
19
- 2018 -- >/alle_spiele/kor-k-league-classic-2018/<
20
- 2017 Meisterschaft -- >/alle_spiele/kor-k-league-classic-2017-meisterschaft/<
21
- 2017 Abstieg -- >/alle_spiele/kor-k-league-classic-2017-abstieg/<
22
- 2017 -- >/alle_spiele/kor-k-league-classic-2017/<
23
- 2016 Meisterschaft -- >/alle_spiele/kor-k-league-classic-2016-meisterschaft/<
24
- 2016 Abstieg -- >/alle_spiele/kor-k-league-classic-2016-abstieg/<
25
- 2016 -- >/alle_spiele/kor-k-league-2016/<
26
- 2015 Meisterschaft -- >/alle_spiele/kor-k-league-2015-meisterschaft/<
27
- 2015 Abstieg -- >/alle_spiele/kor-k-league-2015-abstieg/<
28
- 2015 -- >/alle_spiele/kor-k-league-2015/<
29
- =end
30
-
31
- ### todo/fix: time-zone offset!!!!!!!!
32
- # /kor-k-league-1-2020/
33
- # /kor-k-league-1-2019-meisterschaft/
34
- # /kor-k-league-1-2019-abstieg/
35
- 'kr.1' => {
36
- pages: {
37
- 'kor-k-league-1-{season}' => 'Regular Season', # 1
38
- 'kor-k-league-1-{season}-meisterschaft' => 'Playoffs - Championship', # 2
39
- 'kor-k-league-1-{season}-abstieg' => 'Playoffs - Relegation', # 3
40
- },
41
- season: ->( season ) {
42
- case season
43
- when Season('2020') then [1] # just getting started
44
- when Season('2019') then [1,2,3]
45
- end
46
- }
47
- },
48
-
49
- }
50
-
51
- end # module Worldfootball
52
-
53
-