worldfootball 0.2.4 → 0.2.5

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: 0dfb778159b88ccab0c79abd75512a5751e148c96f5f2c1ecec6a1ea95b4eaa7
4
- data.tar.gz: 907c8f61a222068bc591260c6928f08c5ab76fc3fa0f826b8a83e4aba673f6a3
3
+ metadata.gz: 6bc6759b77de7fe44eccf59f09fd7b6cc3ddc4576612f4fb208c38a59a02536e
4
+ data.tar.gz: 912fe7d04165b50bc3e50f5e5a1ea554d7fd788d4d019c2b719c8625dd222a3e
5
5
  SHA512:
6
- metadata.gz: 3d008e4768814d2d290d71a73a82f7d8b83812e75dffc6a34fa3a32778634b7160b1642d1741ba84546e89f127965f9822db7c77c47ba2b3c01adb679523256a
7
- data.tar.gz: '09605deda7a4431e396747d2b8cca60f1aaae662249999e0b585427d53721328cf2d74beb063f4423034c0bee3e6caf1c3037e87a5ad948836a6f8371c0bfaf6'
6
+ metadata.gz: 74bf6c7e7a8aeaeb18d9bd1b74764328301b3aa3c309ca814ea494be704958a4f086e7bf94b1b1ea1ad9f974b7be31eb6e0d2a0c611b6c35b85caca06d8f6e71
7
+ data.tar.gz: 7cadf69fe3acafc2f976e3f5c980c8411e8758f5426559d56860c791b473debdb4e1067ad071de6704e7da3ccc434c3af14454bed6ba32ac825c2b491467db08
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 0.2.4
1
+ ### 0.2.5
2
2
 
3
3
  ### 0.0.1 / 2024-07-04
4
4
 
data/Manifest.txt CHANGED
@@ -3,6 +3,7 @@ Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
5
  bin/wfb
6
+ config/leagues_africa.csv
6
7
  config/leagues_america.csv
7
8
  config/leagues_asia.csv
8
9
  config/leagues_europe.csv
@@ -22,6 +23,7 @@ lib/worldfootball/mods.rb
22
23
  lib/worldfootball/page.rb
23
24
  lib/worldfootball/page_report.rb
24
25
  lib/worldfootball/page_schedule.rb
26
+ lib/worldfootball/page_team.rb
25
27
  lib/worldfootball/stages.rb
26
28
  lib/worldfootball/vacuum.rb
27
29
  lib/worldfootball/version.rb
data/bin/wfb CHANGED
@@ -45,17 +45,17 @@ parser = OptionParser.new do |parser|
45
45
 
46
46
  parser.on( "--cache", "--cached", "--offline",
47
47
  "use cached data in #{Webcache.root}" ) do |cached|
48
- opts[:cached] = cached
48
+ opts[:cached] = true
49
49
  end
50
50
 
51
51
  parser.on( "--[no-]convert",
52
52
  "turn on/off conversion to .csv in #{Worldfootball.config.convert.out_dir} - default is (#{opts[:convert]})" ) do |convert|
53
- opts[:convert] = convert
53
+ opts[:convert] = convert # true|false
54
54
  end
55
55
 
56
56
  parser.on( "--print", "--pp",
57
57
  "pretty print cached data in #{Webcache.root}; no download & conversion") do |print|
58
- opts[:cached] = true
58
+ opts[:cached] = true
59
59
  opts[:convert] = false
60
60
  end
61
61
 
@@ -0,0 +1,8 @@
1
+ key, slug
2
+
3
+ afl, african-football-league-2023
4
+ caf.cl, caf-champions-league-2024-2025
5
+
6
+ eg.1, egy-premiership-2023-2024
7
+ ma.1, mar-botola-pro-1-2024-2025
8
+ dz.1, alg-ligue-1-2024-2025
@@ -37,8 +37,19 @@ us.cup, usa-u-s-open-cup-2024
37
37
 
38
38
  br.1, bra-serie-a-2024
39
39
  br.2, bra-serie-b-2024
40
+ br.3, bra-serie-c-2024-playoffs
41
+ br.4, bra-serie-d-2024
42
+
40
43
  br.cup, bra-copa-do-brasil-2024
41
44
 
45
+ br.carioca, bra-campeonato-carioca-2024-taca-guanabara-finals
46
+ br.gauchao, bra-campeonato-gaucho-2024-playoffs
47
+ br.mineiro, bra-campeonato-mineiro-2024-fase-final
48
+ br.paranaense, bra-campeonato-paranaense-2024-fase-final
49
+ br.paulistao, bra-campeonato-paulista-2024-playoffs
50
+
51
+
52
+
42
53
 
43
54
  co.1, col-primera-a-2024-clausura
44
55
  co.2, col-primera-b-2024-clausura
@@ -8,3 +8,4 @@ cn.1, chn-super-league-2024
8
8
 
9
9
  kr.1, kor-k-league-1-2024
10
10
 
11
+ kz.1, kaz-premier-liga-2024
@@ -13,6 +13,7 @@ de.cup, dfb-pokal-2024-2025
13
13
  at.1, aut-bundesliga-2024-2025
14
14
  at.2, aut-2-liga-2024-2025
15
15
  at.3.o, aut-regionalliga-ost-2024-2025
16
+ at.3.m, aut-regionalliga-mitte-2024-2025
16
17
  at.cup, aut-oefb-cup-2024-2025
17
18
 
18
19
 
@@ -20,6 +21,9 @@ ch.1, sui-super-league-2024-2025
20
21
  ch.2, sui-challenge-league-2024-2025
21
22
  ch.cup, sui-cup-2024-2025
22
23
 
24
+ # note - li no league, only cup
25
+ # most (all?) clubs play in switzerland
26
+ li.cup, lie-fl-1-cup-2024-2025
23
27
 
24
28
  hu.1, hun-nb-i-2024-2025
25
29
 
@@ -44,7 +48,8 @@ eng.cup.l, eng-league-cup-2024-2025
44
48
 
45
49
 
46
50
  sco.1, sco-premiership-2024-2025
47
-
51
+ wal.1, wal-premier-league-2024-2025
52
+ nir.1, nir-premier-league-2024-2025
48
53
  ie.1, irl-premier-division-2024
49
54
 
50
55
 
@@ -64,10 +69,16 @@ be.2, bel-eerste-klasse-b-2024-2025
64
69
  be.cup, bel-beker-van-belgie-2024-2025
65
70
 
66
71
 
67
- it.1, ita-serie-a-2024-2025
68
- it.2, ita-serie-b-2024-2025
72
+ it.1, ita-serie-a-2024-2025
73
+ it.2, ita-serie-b-2024-2025
74
+ it.3.a, ita-serie-c-girone-a-2024-2025
75
+ it.3.b, ita-serie-c-girone-b-2024-2025
76
+ it.3.c, ita-serie-c-girone-c-2024-2025
69
77
  it.cup, ita-coppa-italia-2024-2025
70
78
 
79
+ sm.1, smr-campionato-2024-2025
80
+
81
+
71
82
  pt.1, por-primeira-liga-2024-2025
72
83
  pt.2, por-segunda-liga-2024-2025
73
84
 
@@ -75,13 +86,21 @@ es.1, esp-primera-division-2024-2025
75
86
  es.2, esp-segunda-division-2024-2025
76
87
  es.cup, esp-copa-del-rey-2023-2024 ## update to 2024-2025 later!!!
77
88
 
89
+ ad.1, and-1a-divisio-2024-2025
90
+
91
+ gi.1, gib-premier-divison-2024-2025
92
+
78
93
 
79
94
  ro.1, rou-liga-1-2024-2025
80
95
  ro.cup, rou-cupa-romaniei-2024-2025
81
96
 
97
+ bg.1, bul-parva-liga-2024-2025
98
+
82
99
  ru.1, rus-premier-liga-2024-2025
83
100
  ru.2, rus-premier-liga-2024-2025
84
101
 
102
+ by.1, blr-cempionat-2024
103
+
85
104
  ua.1, ukr-premyer-liga-2024-2025
86
105
 
87
106
 
@@ -91,13 +110,32 @@ tr.2, tur-1-lig-2024-2025
91
110
 
92
111
  gr.1, gre-super-league-2024-2025
93
112
 
113
+ cy.1, cyp-first-division-2024-2025
114
+ mt.1, mlt-premier-league-2024-2025-opening
115
+
94
116
  hr.1, cro-1-hnl-2024-2025
95
117
  ba.1, bih-premier-liga-2024-2025
96
118
 
97
119
  al.1, alb-kategoria-superiore-2024-2025
98
120
 
121
+ mk.1, mkd-1-mfl-2024-2025
122
+ md.1, mda-divizia-nationala-2024-2025-phase-i
123
+ me.1, mne-1-cfl-2024-2025
124
+ rs.1, srb-super-liga-2024-2025
125
+ si.1, svn-prvaliga-2024-2025
126
+
127
+ ## todo/fix - change to kos.1 - why? why not?
128
+ xk.1, kos-superliga-2024-2025
129
+ kos.1, kos-superliga-2024-2025
130
+
131
+
132
+ am.1, arm-premier-league-2024-2025
133
+ az.1, aze-premyer-liqasi-2024-2025
134
+ ge.1, geo-erovnuli-liga-2024
135
+
99
136
 
100
137
  is.1, isl-urvalsdeild-2024
138
+ fo.1, fro-effodeildin-2024
101
139
 
102
140
  se.1, swe-allsvenskan-2024
103
141
  se.2, swe-superettan-2024
@@ -106,7 +144,9 @@ no.1, nor-eliteserien-2024
106
144
  fi.1, fin-veikkausliiga-2024-championship
107
145
  dk.1, den-superliga-2024-2025
108
146
 
109
-
147
+ ee.1, est-meistriliiga-2024
148
+ lt.1, ltu-a-lyga-2024
149
+ lv.1, lat-virsliga-2024
110
150
 
111
151
 
112
152
  uefa.cl, champions-league-2024-2025
data/config/rounds.csv CHANGED
@@ -1,5 +1,6 @@
1
1
  key, name1, name2
2
2
 
3
+ ## de to en
3
4
  *, 1. Runde, Round 1
4
5
  *, 2. Runde, Round 2
5
6
  *, 3. Runde, Round 3
@@ -14,3 +15,44 @@ key, name1, name2
14
15
  *, Halbfinale, Semifinals
15
16
  *, Finale, Final
16
17
 
18
+ *, Spiel um Platz 3, Match for 3rd place
19
+
20
+ *, Vorrunde, Preliminary round
21
+
22
+ *, Qual. 1. Runde, Qual. Round 1
23
+ *, Qual. 2. Runde, Qual. Round 2
24
+
25
+
26
+
27
+ ## es to en
28
+ *, Recalificación, Reclassification
29
+
30
+
31
+
32
+
33
+ ## misc - make more generic - why? why not?
34
+ mx.1, Qual. 1. Runde, Play-in round 1
35
+ mx.1, Qual. 2. Runde, Play-in round 2
36
+ mx.2, Qual. 1. Runde, Play-in round 1
37
+ mx.2, Qual. 2. Runde, Play-in round 2
38
+
39
+
40
+ ###
41
+ ## quick fix - move groups to new groups column!!!!
42
+ ar.1, Gruppe A, Group
43
+ ar.1, Gruppe B, Group
44
+ ar.1, Gruppe C, Group
45
+ ar.1, Gruppe D, Group
46
+ ar.1, Gruppe E, Group
47
+ ar.1, Gruppe F, Group
48
+ ar.1, Gruppe 1, Group
49
+ ar.1, Gruppe 2, Group
50
+
51
+ co.1, Gruppe A, Group
52
+ co.1, Gruppe B, Group
53
+
54
+ caf.cl, Gruppe A, Group
55
+ caf.cl, Gruppe B, Group
56
+ caf.cl, Gruppe C, Group
57
+ caf.cl, Gruppe D, Group
58
+
@@ -1,6 +1,17 @@
1
1
  module Worldfootball
2
2
 
3
3
 
4
+ ## add WO
5
+ ## br.mineiro 2024 - Descenso
6
+ ##
7
+ ## W.O. or w/o (originally two words: "walk over"),
8
+ ##
9
+ ## [004] 3. Spieltag => 3
10
+ ## [004] 2024-03-22 | 00:00 | Atlético Patrocinense - MG | Ipatinga - MG | WO
11
+ ## !! ERROR - unsupported score format >WO< - sorry; maybe add a score error fix/patch
12
+
13
+
14
+
4
15
 
5
16
  def self.parse_score( score_str )
6
17
  ## add support for
@@ -8,7 +19,7 @@ def self.parse_score( score_str )
8
19
  ## 3-0 (0-0, 0-0) awd.
9
20
 
10
21
  ## check for 0:3 Wert. - change Wert. to awd. (awarded)
11
- ## todo/fix - use "hardcoded" Wert\. in regex - why? why not?
22
+ ## todo/fix - use "hardcoded" Wert\. in regex - why? why not?
12
23
  ## score_str = score_str.sub( /Wert\./i, 'awd.' )
13
24
 
14
25
 
@@ -38,6 +49,11 @@ def self.parse_score( score_str )
38
49
  ft = ''
39
50
  ht = ''
40
51
  comments = 'postponed'
52
+ elsif score_str == 'WO' # walk over
53
+ ## W.O. or w/o (originally two words: "walk over"),
54
+ ft = '(*)'
55
+ ht = ''
56
+ comments = 'w/o' ## use walkover - why? why not?
41
57
  # 5-4 (0-0, 1-1, 2-2) i.E.
42
58
  elsif score_str =~ /([0-9]+) [ ]*-[ ]* ([0-9]+)
43
59
  [ ]*
@@ -54,7 +70,7 @@ def self.parse_score( score_str )
54
70
  ft = "#{$5}-#{$6}"
55
71
  et = "#{$7}-#{$8}"
56
72
  # 3-2 (0-0, 1-1) i.E. - note: no extra time!!! only ht,ft!!!
57
- # "popular" in southamerica & mexico
73
+ # "popular" in southamerica & mexico
58
74
  elsif score_str =~ /([0-9]+) [ ]*-[ ]* ([0-9]+)
59
75
  [ ]*
60
76
  \(([0-9]+) [ ]*-[ ]* ([0-9]+)
@@ -80,14 +96,14 @@ def self.parse_score( score_str )
80
96
  et = "#{$1}-#{$2}"
81
97
  ht = "#{$3}-#{$4}"
82
98
  ft = "#{$5}-#{$6}"
83
- ### auto-patch fix drop last score
99
+ ### auto-patch fix drop last score
84
100
  ## 1-3 (0-1, 1-1, 0-2) n.V. => 1-3 (0-1, 1-1) n.V.
85
101
  elsif score_str =~ /([0-9]+) [ ]*-[ ]* ([0-9]+)
86
102
  [ ]*
87
103
  \(([0-9]+) [ ]*-[ ]* ([0-9]+)
88
104
  [ ]*,[ ]*
89
- ([0-9]+) [ ]*-[ ]* ([0-9]+)
90
- [ ]*,[ ]*
105
+ ([0-9]+) [ ]*-[ ]* ([0-9]+)
106
+ [ ]*,[ ]*
91
107
  ([0-9]+) [ ]*-[ ]* ([0-9]+)
92
108
  \)
93
109
  [ ]*
@@ -97,7 +113,7 @@ def self.parse_score( score_str )
97
113
  ht = "#{$3}-#{$4}"
98
114
  ft = "#{$5}-#{$6}"
99
115
 
100
- puts "!! WARN - auto-fix/patch score - >#{score_str}<"
116
+ puts "!! WARN - auto-fix/patch score - >#{score_str}<"
101
117
  ### todo/fix - log auto-patch/fix - for double checking!!!!!
102
118
  elsif score_str =~ /([0-9]+) [ ]*-[ ]* ([0-9]+)
103
119
  [ ]*
@@ -120,9 +136,9 @@ def self.parse_score( score_str )
120
136
  [ ]*
121
137
  \(([0-9]+) [ ]*-[ ]* ([0-9]+)
122
138
  [ ]*,[ ]*
123
- ([0-9]+) [ ]*-[ ]* ([0-9]+)
124
- \)
125
- [ ]*
139
+ ([0-9]+) [ ]*-[ ]* ([0-9]+)
140
+ \)
141
+ [ ]*
126
142
  Wert\. # ([a-z.]+)
127
143
  /x ### assume awd. (awarded) always - why? why not?
128
144
  ft = "#{$1}-#{$2} (*)"
@@ -133,19 +149,36 @@ def self.parse_score( score_str )
133
149
  ft = "#{$1}-#{$2}" ## e.g. see luxemburg and others
134
150
  ht = ''
135
151
  ## auto-fix/patch
136
- # 3-3 (0-3, 3-3) => 3-3 (0-3) - drop last score
152
+ # 3-3 (0-3, 3-3) => 3-3 (0-3) - drop last score
137
153
  elsif score_str =~ /^([0-9]+) [ ]*-[ ]* ([0-9]+)
138
154
  [ ]*
139
155
  \(([0-9]+) [ ]*-[ ]* ([0-9]+)
140
156
  [ ]*,[ ]*
141
- ([0-9]+) [ ]*-[ ]* ([0-9]+)
157
+ ([0-9]+) [ ]*-[ ]* ([0-9]+)
142
158
  \)$
143
159
  /x
144
160
  ft = "#{$1}-#{$2}"
145
161
  ht = "#{$3}-#{$4}"
146
162
 
147
- puts "!! WARN - auto-fix/patch score - >#{score_str}<"
163
+ puts "!! WARN - auto-fix/patch score - >#{score_str}<"
148
164
  ### todo/fix - log auto-patch/fix - for double checking!!!!!
165
+ elsif score_str =~ /^([0-9]+) [ ]*-[ ]* ([0-9]+)
166
+ [ ]*
167
+ n\.V\.
168
+ $/x
169
+ et = "#{$1}-#{$2}"
170
+ ht = ''
171
+ ft = ''
172
+ puts "!! WARN - weird score n.V. only - >#{score_str}<"
173
+ elsif score_str =~ /^([0-9]+) [ ]*-[ ]* ([0-9]+)
174
+ [ ]*
175
+ i\.E\.
176
+ $/x
177
+ pen = "#{$1}-#{$2}"
178
+ et = ''
179
+ ht = ''
180
+ ft = ''
181
+ puts "!! WARN - weird score i.E. only - >#{score_str}<"
149
182
  else
150
183
  puts "!! ERROR - unsupported score format >#{score_str}< - sorry; maybe add a score error fix/patch"
151
184
  exit 1
@@ -38,7 +38,7 @@ class Metal
38
38
 
39
39
  def self.schedule_url( slug ) "#{BASE_URL}/alle_spiele/#{slug}/"; end
40
40
  def self.report_url( slug ) "#{BASE_URL}/spielbericht/#{slug}/"; end
41
-
41
+ def self.team_url( slug ) "#{BASE_URL}/teams/#{slug}/"; end
42
42
 
43
43
  ##
44
44
  ## note:
@@ -49,6 +49,19 @@ class Metal
49
49
  ## 301 Moved Permanently location=https://www.weltfussball.de/
50
50
 
51
51
 
52
+ def self.download_team( slug, cache: true )
53
+ url = team_url( slug )
54
+
55
+ ## check check first
56
+ if cache && Webcache.cached?( url )
57
+ puts " reuse local (cached) copy >#{Webcache.url_to_id( url )}<"
58
+ else
59
+ download_page( url )
60
+ end
61
+ end
62
+
63
+
64
+
52
65
  # url = "https://www.weltfussball.de/alle_spiele/eng-league-one-#{season}/"
53
66
  # url = "https://www.weltfussball.de/alle_spiele/eng-league-two-#{season}/"
54
67
  # https://www.weltfussball.de/alle_spiele/eng-national-league-2019-2020/
@@ -62,7 +75,6 @@ class Metal
62
75
  # https://www.weltfussball.de/alle_spiele/tur-sueperlig-2019-2020/
63
76
  # https://www.weltfussball.de/alle_spiele/tur-1-lig-2019-2020/
64
77
 
65
-
66
78
  def self.download_schedule( slug )
67
79
  url = schedule_url( slug )
68
80
  download_page( url )
@@ -120,7 +120,8 @@ end # class LeagueConfig
120
120
 
121
121
 
122
122
  LEAGUES = LeagueConfig.new
123
- ['leagues_america',
123
+ ['leagues_africa',
124
+ 'leagues_america',
124
125
  'leagues_asia',
125
126
  'leagues_europe',
126
127
  'leagues_middle_east',
@@ -8,7 +8,9 @@ module Worldfootball
8
8
  end
9
9
 
10
10
  def initialize( html )
11
- @html = html
11
+ ## todo/fix - fix upstream in wget!!!! why? why not?
12
+ ## normalize unicode (to nfc - ruby's default norm form)
13
+ @html = html.unicode_normalize
12
14
  end
13
15
 
14
16
  def doc
@@ -0,0 +1,22 @@
1
+
2
+ module Worldfootball
3
+ class Page
4
+
5
+ class Team < Page ## note: use nested class for now - why? why not?
6
+
7
+ def self.from_cache( slug )
8
+ url = Metal.team_url( slug )
9
+ html = Webcache.read( url )
10
+ new( html )
11
+ end
12
+
13
+
14
+
15
+
16
+ ######
17
+ ## helpers
18
+
19
+ end # class Team
20
+
21
+ end # class Page
22
+ end # module Worldfootball
@@ -2,7 +2,7 @@
2
2
  module Worldfootball
3
3
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
4
4
  MINOR = 2
5
- PATCH = 4
5
+ PATCH = 5
6
6
  VERSION = [MAJOR,MINOR,PATCH].join('.')
7
7
 
8
8
  def self.version
data/lib/worldfootball.rb CHANGED
@@ -16,6 +16,7 @@ require_relative 'worldfootball/download'
16
16
  require_relative 'worldfootball/page'
17
17
  require_relative 'worldfootball/page_schedule'
18
18
  require_relative 'worldfootball/page_report'
19
+ require_relative 'worldfootball/page_team'
19
20
  require_relative 'worldfootball/cache'
20
21
 
21
22
 
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.4
4
+ version: 0.2.5
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-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: football-timezones
@@ -102,6 +102,7 @@ files:
102
102
  - README.md
103
103
  - Rakefile
104
104
  - bin/wfb
105
+ - config/leagues_africa.csv
105
106
  - config/leagues_america.csv
106
107
  - config/leagues_asia.csv
107
108
  - config/leagues_europe.csv
@@ -121,6 +122,7 @@ files:
121
122
  - lib/worldfootball/page.rb
122
123
  - lib/worldfootball/page_report.rb
123
124
  - lib/worldfootball/page_schedule.rb
125
+ - lib/worldfootball/page_team.rb
124
126
  - lib/worldfootball/stages.rb
125
127
  - lib/worldfootball/vacuum.rb
126
128
  - lib/worldfootball/version.rb