worldfootball 0.2.6 → 0.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9d824bdedb279bf91779c99445fcf5bd5a6df8acc342232624032256a32fbe18
4
- data.tar.gz: 14eb224174efe18645412a88eaa332e01901247dd28ffa795cba8b902d3a1dd6
3
+ metadata.gz: 89d825112036b8740d446612f179f44d96d33fbba1874ab51d8f9e5dda1e01a9
4
+ data.tar.gz: 38d332b34ef4adb9017cbcee8434aa2f85d8a53a46e4556a267cb45443e17abd
5
5
  SHA512:
6
- metadata.gz: b0e4885e80c6ff3fb13a00a654524ea4514fcac730438096e412cd76a5ba14c17fa563996afd81176f7538bffb6ac8bdc3c75de7af7ace2124269b7c72c0265b
7
- data.tar.gz: feb02079e9c481c3b2e53d5c72030e5e9e687f94bf053c29134da613933c2f5f6b569339fb8980ab3c048e248c171c93ea23a4b4a350c5dfede8563990b5a298
6
+ metadata.gz: cf178997ed45d02f06e1039bab38d84979ab6df75422d73988c7dc2617d1a1cd4538f4ab5884ad4479faa130bd8203d8b58938f09fec661b937396cbc7364146
7
+ data.tar.gz: 23e76db98b915fe5f280653d4928cfb7f6c7e1c8adbc506b7ae87ad6ba99fcb30748968111bcb0b6e24c545ee89d42906abc662d07440f6aad87227aac8cdda2
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 0.2.6
1
+ ### 0.3.0
2
2
 
3
3
  ### 0.0.1 / 2024-07-04
4
4
 
data/Manifest.txt CHANGED
@@ -3,12 +3,12 @@ Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
5
  bin/wfb
6
- config/leagues_africa.csv
7
- config/leagues_america.csv
8
- config/leagues_asia.csv
9
- config/leagues_europe.csv
10
- config/leagues_middle_east.csv
11
- config/leagues_pacific.csv
6
+ config/leagues/africa.csv
7
+ config/leagues/america.csv
8
+ config/leagues/asia.csv
9
+ config/leagues/europe.csv
10
+ config/leagues/middle_east.csv
11
+ config/leagues/pacific.csv
12
12
  config/rounds.csv
13
13
  config/stages.csv
14
14
  lib/worldfootball.rb
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # worldfootball - get world football (leagues, cups & more) match data via the worldfootball.net/weltfussball.de pages
2
-
2
+
3
3
 
4
4
  * home :: [github.com/sportdb/sport.db](https://github.com/sportdb/sport.db)
5
5
  * bugs :: [github.com/sportdb/sport.db/issues](https://github.com/sportdb/sport.db/issues)
@@ -41,7 +41,7 @@ and so on.
41
41
 
42
42
  ### More
43
43
 
44
- Debugging tips. List all cached (offline local) match schedule pages:
44
+ Debugging tips & tricks. List all cached (offline local) match schedule pages:
45
45
 
46
46
  ```
47
47
  $ wfb cache
data/Rakefile CHANGED
@@ -22,6 +22,7 @@ Hoe.spec 'worldfootball' do
22
22
  ['fifa'],
23
23
  ['webget'],
24
24
  ['nokogiri'],
25
+ ['sportdb-writers'],
25
26
  ]
26
27
 
27
28
  self.licenses = ['Public Domain']
data/bin/wfb CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  ## tip: to test run:
4
4
  ## ruby -I ./lib bin/wfb
5
+ ## or
6
+ ## ruby -I wfb/lib wfb/bin/wfb
7
+
5
8
 
6
9
  require 'worldfootball'
7
10
 
@@ -18,9 +21,17 @@ Worldfootball.config.convert.out_dir = if File.exist?( '/sports/cache.wfb')
18
21
  puts " setting convert out_dir to >/sports/cache.wfb<"
19
22
  '/sports/cache.wfb'
20
23
  else
21
- '.' ## use working dir
24
+ './tmp' ## use tmp in working dir
25
+ end
26
+
27
+ Worldfootball.config.generate.out_dir = if File.exist?( '/sports/cache.wfb.txt')
28
+ puts " setting convert out_dir to >/sports/cache.wfb.txt<"
29
+ '/sports/cache.wfb.txt'
30
+ else
31
+ './tmp' ## use tmp in working dir
22
32
  end
23
33
 
34
+
24
35
  require 'optparse'
25
36
 
26
37
 
@@ -28,9 +39,11 @@ module Worldfootball
28
39
  def self.main( args=ARGV )
29
40
 
30
41
  opts = {
31
- cached: false,
32
- convert: true,
33
- file: nil,
42
+ debug: false,
43
+ cached: false,
44
+ convert: true,
45
+ generate: true,
46
+ file: nil,
34
47
  }
35
48
 
36
49
 
@@ -49,14 +62,22 @@ parser = OptionParser.new do |parser|
49
62
  end
50
63
 
51
64
  parser.on( "--[no-]convert",
52
- "turn on/off conversion to .csv in #{Worldfootball.config.convert.out_dir} - default is (#{opts[:convert]})" ) do |convert|
65
+ "turn on/off conversion to (tabular) .csv format in #{Worldfootball.config.convert.out_dir} - default is (#{opts[:convert]})" ) do |convert|
53
66
  opts[:convert] = convert # true|false
54
67
  end
55
68
 
69
+ parser.on( "--[no-]generate",
70
+ "turn on/off generation in football.txt format in #{Worldfootball.config.generate.out_dir} - default is (#{opts[:generate]})" ) do |generate|
71
+ opts[:generate] = generate # true|false
72
+ end
73
+
74
+
56
75
  parser.on( "--print", "--pp",
57
- "pretty print cached data in #{Webcache.root}; no download & conversion") do |print|
58
- opts[:cached] = true
59
- opts[:convert] = false
76
+ "pretty print cached data in #{Webcache.root}; no download & conversion & generation") do |print|
77
+ opts[:debug] = true
78
+ opts[:cached] = true
79
+ opts[:convert] = false
80
+ opts[:generate] = false
60
81
  end
61
82
 
62
83
  parser.on( "-f FILE", "--file FILE",
@@ -76,6 +97,14 @@ puts "ARGV:"
76
97
  p args
77
98
 
78
99
 
100
+ ## turn on debug output
101
+ if opts[:debug]
102
+ Worldfootball.debug = true
103
+ else
104
+ Worldfootball.debug = false
105
+ end
106
+
107
+
79
108
  ### check special (built-in) commands first
80
109
  if ['cache'].include?( args[0] )
81
110
  Worldfootball.list_pages
@@ -127,6 +156,11 @@ datasets.each do |dataset|
127
156
  end
128
157
 
129
158
 
159
+ ###
160
+ ## collect league names & more
161
+ extra = {}
162
+
163
+
130
164
  ## step 1 - download
131
165
  datasets.each do |league_key, seasons|
132
166
  league = find_league!( league_key ) ## league info lookup
@@ -152,6 +186,10 @@ datasets.each do |league_key, seasons|
152
186
  matches = page.matches
153
187
 
154
188
  puts " #{matches.size} match(es)"
189
+
190
+ league_extra = extra[ league.key ] ||= {}
191
+ season_extra = league_extra[ season.key] ||= { names: [] }
192
+ season_extra[:names] << page.title
155
193
  end
156
194
  end # each seasons
157
195
  end # each league
@@ -168,6 +206,43 @@ if opts[:convert]
168
206
  end
169
207
  end
170
208
 
209
+ if opts[:generate]
210
+ ## step 3 - generate
211
+ datasets.each do |league_key, seasons|
212
+ seasons.each do |season|
213
+
214
+ path = "#{config.convert.out_dir}/#{season.to_path}/#{league_key}.csv"
215
+ ## get matches
216
+ puts " ---> reading matches in #{path} ..."
217
+ matches = SportDb::CsvMatchParser.read( path )
218
+ puts " #{matches.size} matches"
219
+
220
+ ## build
221
+ txt = SportDb::TxtMatchWriter.build( matches )
222
+ puts txt
223
+
224
+ path = if season >= Season( '2000' )
225
+ "#{config.generate.out_dir}/#{season.to_path}/#{league_key}.txt"
226
+ else
227
+ decade = season.start_year - (season.start_year%10)
228
+ ## use archive-style before 2000!!!
229
+ "#{config.generate.out_dir}/archive/#{decade}s/#{season.to_path}/#{league_key}.txt"
230
+ end
231
+
232
+ buf = String.new
233
+ ## note - use league key for league name for now!!
234
+ buf << "= #{league_key.upcase.gsub('.', ' ')} #{season.key}\n\n"
235
+ buf << txt
236
+
237
+ puts " writing to >#{path}<..."
238
+ write_text( path, buf )
239
+ end
240
+ end
241
+ ## for debugging dump page (slug) titles
242
+ pp extra
243
+ end
244
+
245
+
171
246
 
172
247
  end # def self.main
173
248
  end # module Worldfootball
@@ -27,6 +27,10 @@ mx.2, mex-liga-de-expansion-2024-2025-apertura
27
27
  mx.cup, mex-copa-mx-2019-2020
28
28
 
29
29
 
30
+ ### fix add from / to seasons !!! for mx!!!!
31
+ mx.3, mex-premier-de-ascenso-2020-2021-grupo-b
32
+
33
+
30
34
 
31
35
  ## change to mls - why? why not?
32
36
  us.1, usa-major-league-soccer-2024
@@ -34,6 +38,12 @@ us.2, usa-usl-championship-2024
34
38
  us.cup, usa-u-s-open-cup-2024
35
39
 
36
40
 
41
+ concacaf.cl, concacaf-champions-league-2020
42
+
43
+
44
+
45
+ #############
46
+ ### South America
37
47
 
38
48
  br.1, bra-serie-a-2024
39
49
  br.2, bra-serie-b-2024
@@ -78,4 +88,16 @@ uy.1, uru-primera-division-2024-clausura
78
88
  uy.2, uru-segunda-division-2024-fase-regular
79
89
  uy.cup, uru-copa-2024
80
90
 
81
- ve.1, ven-primera-division-2024-clausura
91
+ ve.1, ven-primera-division-2024-clausura
92
+
93
+
94
+ copa.l, copa-libertadores-2020
95
+
96
+
97
+ ###################
98
+ ### Central America & Caribbean Islands
99
+ cr.1, crc-primera-division-2020-2021-apertura
100
+ sv.1, slv-primera-division-2020-2021-apertura
101
+ gt.1, gua-liga-nacional-2020-2021-apertura
102
+ hn.1, hon-liga-nacional-2020-2021-apertura
103
+ ni.1, nca-liga-primera-2020-2021-apertura
@@ -1,5 +1,9 @@
1
1
  key, slug
2
2
 
3
+
4
+ ###########
5
+ #### Central Europe
6
+
3
7
  de.1, bundesliga-2024-2025
4
8
  de.2, 2-bundesliga-2024-2025
5
9
  de.3, 3-liga-2024-2025
@@ -36,6 +40,8 @@ sk.1, svk-super-liga-2024-2025
36
40
  pl.1, pol-ekstraklasa-2024-2025
37
41
 
38
42
 
43
+ #########
44
+ ### British Isles / Western Europe
39
45
 
40
46
  eng.1, eng-premier-league-2024-2025
41
47
  eng.2, eng-championship-2024-2025
@@ -45,19 +51,20 @@ eng.5, eng-national-league-2024-2025
45
51
  eng.cup, eng-fa-cup-2023-2024 ### update to 2024-2025 later!!!
46
52
  eng.cup.l, eng-league-cup-2024-2025
47
53
 
48
-
49
-
50
54
  sco.1, sco-premiership-2024-2025
51
55
  wal.1, wal-premier-league-2024-2025
52
56
  nir.1, nir-premier-league-2024-2025
53
57
  ie.1, irl-premier-division-2024
54
58
 
55
59
 
60
+
61
+ ##############
62
+ ### Benelux / Western Europe
63
+
56
64
  fr.1, fra-ligue-1-2024-2025
57
65
  fr.2, fra-ligue-2-2024-2025
58
66
  fr.cup, fra-coupe-de-france-2023-2024 ### update to 2024-2025 later!!!
59
67
 
60
-
61
68
  lu.1, lux-nationaldivision-2024-2025
62
69
 
63
70
  nl.1, ned-eredivisie-2024-2025
@@ -69,6 +76,10 @@ be.2, bel-eerste-klasse-b-2024-2025
69
76
  be.cup, bel-beker-van-belgie-2024-2025
70
77
 
71
78
 
79
+
80
+ ######################
81
+ ### Southern Europe
82
+
72
83
  it.1, ita-serie-a-2024-2025
73
84
  it.2, ita-serie-b-2024-2025
74
85
  it.3.a, ita-serie-c-girone-a-2024-2025
@@ -91,11 +102,20 @@ ad.1, and-1a-divisio-2024-2025
91
102
  gi.1, gib-premier-divison-2024-2025
92
103
 
93
104
 
105
+
106
+ ###################
107
+ ### Eastern Europe
108
+
94
109
  ro.1, rou-liga-1-2024-2025
95
110
  ro.cup, rou-cupa-romaniei-2024-2025
96
111
 
97
112
  bg.1, bul-parva-liga-2024-2025
98
113
 
114
+ ##
115
+ ## note: ru - special (transition) league format for season 2011/12 (lasting 18 month!!)
116
+ # 1) rus-premier-liga-2011-2012/ -- 30 rounds
117
+ # 2a) rus-premier-liga-2011-2012-meisterschaft/ -- 2011/2012 Meisterschaft (rounds 31 to 44)
118
+ # b) rus-premier-liga-2011-2012-relegation/ -- 2011/2012 Relegation (rounds 31 to 44)
99
119
  ru.1, rus-premier-liga-2024-2025
100
120
  ru.2, rus-premier-liga-2024-2025
101
121
 
@@ -104,6 +124,12 @@ by.1, blr-cempionat-2024
104
124
  ua.1, ukr-premyer-liga-2024-2025
105
125
 
106
126
 
127
+ ## note: start with 2012/13 for now!!!
128
+ ## in 2011/12 a new format was introduced, in which after the regular season
129
+ ## two play-off groups were played to decide over the Champions League and Europa League starting rounds
130
+ ## 1) - tur-sueperlig-2011-2012
131
+ ## 2a) - tur-sueperlig-2012-meisterschaft -- 2012 Meisterschaft
132
+ ## 2b) - tur-sueperlig-2012-platzierung -- 2012 Platzierung
107
133
 
108
134
  tr.1, tur-sueperlig-2024-2025
109
135
  tr.2, tur-1-lig-2024-2025
@@ -134,6 +160,11 @@ az.1, aze-premyer-liqasi-2024-2025
134
160
  ge.1, geo-erovnuli-liga-2024
135
161
 
136
162
 
163
+
164
+
165
+ ###################
166
+ ### Northern Europe
167
+
137
168
  is.1, isl-urvalsdeild-2024
138
169
  fo.1, fro-effodeildin-2024
139
170
 
@@ -123,13 +123,13 @@ end # class LeagueConfig
123
123
 
124
124
 
125
125
  LEAGUES = LeagueConfig.new
126
- ['leagues_africa',
127
- 'leagues_america',
128
- 'leagues_asia',
129
- 'leagues_europe',
130
- 'leagues_middle_east',
131
- 'leagues_pacific'].each do |name|
132
- recs = read_csv( "#{Worldfootball.root}/config/#{name}.csv" )
126
+ ['africa',
127
+ 'america',
128
+ 'asia',
129
+ 'europe',
130
+ 'middle_east',
131
+ 'pacific'].each do |name|
132
+ recs = read_csv( "#{Worldfootball.root}/config/leagues/#{name}.csv" )
133
133
  pp recs
134
134
  puts " #{recs.size} league(s) in #{name}"
135
135
  LEAGUES.add( recs )
@@ -1,8 +1,8 @@
1
1
 
2
2
  module Worldfootball
3
3
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
4
- MINOR = 2
5
- PATCH = 6
4
+ MINOR = 3
5
+ PATCH = 0
6
6
  VERSION = [MAJOR,MINOR,PATCH].join('.')
7
7
 
8
8
  def self.version
data/lib/worldfootball.rb CHANGED
@@ -6,6 +6,9 @@ require 'webget' ## incl. webget, webcache, webclient, etc.
6
6
  require 'nokogiri'
7
7
 
8
8
 
9
+ require 'sportdb/writers'
10
+
11
+
9
12
  ###
10
13
  # our own code
11
14
  require_relative 'worldfootball/version'
@@ -47,10 +50,16 @@ class Configuration
47
50
  def out_dir() @out_dir || './o'; end
48
51
  def out_dir=(value) @out_dir = value; end
49
52
  end
53
+ class Generate
54
+ def out_dir() @out_dir || './o'; end
55
+ def out_dir=(value) @out_dir = value; end
56
+ end
50
57
 
51
- def convert() @convert ||= Convert.new; end
58
+ def convert() @convert ||= Convert.new; end
59
+ def generate() @generate ||= Generate.new; end
52
60
  end # class Configuration
53
61
 
62
+
54
63
  ## lets you use
55
64
  ## Worldfootball.configure do |config|
56
65
  ## config.convert.out_dir = './o'
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.2.6
4
+ version: 0.3.0
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-10-05 00:00:00.000000000 Z
11
+ date: 2024-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: football-timezones
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: sportdb-writers
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rdoc
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -116,12 +130,12 @@ files:
116
130
  - README.md
117
131
  - Rakefile
118
132
  - bin/wfb
119
- - config/leagues_africa.csv
120
- - config/leagues_america.csv
121
- - config/leagues_asia.csv
122
- - config/leagues_europe.csv
123
- - config/leagues_middle_east.csv
124
- - config/leagues_pacific.csv
133
+ - config/leagues/africa.csv
134
+ - config/leagues/america.csv
135
+ - config/leagues/asia.csv
136
+ - config/leagues/europe.csv
137
+ - config/leagues/middle_east.csv
138
+ - config/leagues/pacific.csv
125
139
  - config/rounds.csv
126
140
  - config/stages.csv
127
141
  - lib/worldfootball.rb
File without changes
File without changes