openliga 0.0.1 → 1.0.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: 1c536f8e8f075a90cdaebbc6c0a5b06de9b58dcc026b1a50240a709807ede9d9
4
- data.tar.gz: e0acb89fa7e33e21ca65f1191d8fa1c567cfd05a3220c85d1be8363455c9ca44
3
+ metadata.gz: 8123f6f8860fd4bfec1960d65f175292be9d45df3c462b030afc42798e0c6060
4
+ data.tar.gz: ca3f26f2ca73dce8361e716d772baa9125ee829802a1a38cf0262e624fea18be
5
5
  SHA512:
6
- metadata.gz: 33f66d0098831db3fbc807c7dbc165cc8052e2fbaa2c7795572740add7b012e95cca1347979a7f5f8769bcf24696df095a6a340419a48b93cc08ea636ec5460f
7
- data.tar.gz: 39f97ffa909180c2bf93f4085ada7fc49a8f88e6da3ea967c8495ceabd1561e6fa847836bb043f90531e1f5b92be62a7aa03b995d30bb6fb6352fe9c6a567636
6
+ metadata.gz: db61a16c8abbbdad2914fd47c2900035c5e9898fae029beed4ee8d83969589d88cf9f432b856cf0f59951d567d01950a80461630b9463860d381419a9b7fce11
7
+ data.tar.gz: 75041d2444b4c7ce31999057109c11e9478e251dfdb1d82b6f0f06fd5e88ba88812d00654581b6983e2c8aaa768fe1dad516fff83b7709ba037df6e79e651db5
data/CHANGELOG.md CHANGED
@@ -1,4 +1,5 @@
1
1
 
2
+ ### 1.0.0
2
3
  ### 0.0.1 / 2026-08-28
3
4
 
4
5
  * Everything is new. First release.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # openliga - openligadb.de api client/wrapper and football.txt format converter
1
+ # openliga - openligadb.de api client/wrapper and football.txt format converter
2
2
 
3
3
 
4
4
  * home :: [github.com/sportdb/sport.db](https://github.com/sportdb/sport.db)
@@ -64,10 +64,46 @@ To be continued...
64
64
 
65
65
 
66
66
 
67
+ ### Bonus - `openliga` Command-Line Tool
67
68
 
69
+ Use the `openliga` command-line tool to
70
+ (i) download openligadb.de match data (in JSON) and
71
+ (ii) convert to the Football.TXT format. Try:
72
+
73
+ ```
74
+ $ openliga -h
75
+ ```
76
+
77
+ resulting in:
78
+
79
+ ```
80
+ Usage: openliga [options] CODE
81
+ -m, --metal use openligadb.de shortcuts/codes and seasons/years (default: false)
82
+ -o, --output=PATH write football.txt conversion to output path (default: none)
83
+ --season=SEASON season (default: none)
84
+ ```
85
+
86
+ examples with "common football.txt codes"
87
+ e.g. `de.1`, `de.2`, `de.3`, `de.cup`:
88
+
89
+ ```
90
+ $ openliga de.1
91
+ $ openliga de.cup
92
+
93
+ $ openliga de.1 --output=2026-27_de.1.txt
94
+ $ openliga de.1 --season=2020/21 --output=2020-21_de.1.txt
95
+ $ openliga de.cup --season=2025/26 --output=2025-26_de.cup.txt
96
+ ```
97
+
98
+ or use the original openligadb.de code/shortcut (and season/year)
99
+ with the `-m/--metal` flag:
100
+
101
+ ```
102
+ $ openliga bl1 --metal
103
+ $ openliga bl1 --metal --season=2020
104
+ ```
68
105
 
69
106
 
70
- ### About the Football (Match) Data
71
107
 
72
108
  Conversion to Football.TXT Conversion Samples
73
109
 
@@ -148,6 +184,9 @@ Sat May 23
148
184
 
149
185
 
150
186
 
187
+
188
+ ### About the OpenLigaDB.de (Football) Match Data
189
+
151
190
  **What's missing (upstream)?**
152
191
 
153
192
  the only match status is `finished: true|false`, that is,
@@ -169,12 +208,22 @@ starting with the after-extra time scor e.g.
169
208
  ```
170
209
  SG Sonnenhof Großaspach v DSC Arminia Bielefeld 2-2 aet (2-2, 1-2), 5-2 pen
171
210
  (...
172
- 3-2 Arbnor Nuraj (p)
173
- 4-2 Luca Molinari (p)
174
- 5-2 Franz Xaver Bleicher (p))
211
+ 3-2 Arbnor Nuraj (p)
212
+ 4-2 Luca Molinari (p)
213
+ 5-2 Franz Xaver Bleicher (p))
214
+
215
+ -or-
216
+
217
+ England v Spanien 1-1 aet, 1-1 pen
218
+ (0-1 M. Caldentey 25'
219
+ 1-1 Alessia RUSSO 57'
220
+ 1-2 P. Guijarro (p)
221
+ 2-2 A. Greenwood (p)
222
+ 3-2 N. Charles (p)
223
+ 4-2 C. Kelly (p))
175
224
  ```
176
225
 
177
- and there's no way to record missed/saved penalties (??).
226
+ and there's no way to record missed/saved penalties.
178
227
 
179
228
 
180
229
 
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require 'hoe'
4
4
 
5
5
  Hoe.spec 'openliga' do
6
6
 
7
- self.version = '0.0.1'
7
+ self.version = '1.0.0'
8
8
 
9
9
  self.summary = "openliga - openligadb.de api client/wrapper and football.txt format converter"
10
10
  self.description = summary
@@ -1,4 +1,7 @@
1
1
 
2
+ ###
3
+ # see https://www.openligadb.de/Leagues?season=2026 for more
4
+
2
5
 
3
6
  code, season, league_name, league_season, league_shortcut
4
7
 
@@ -13,7 +16,7 @@ code, season, league_name, league_season, league_shortcut
13
16
  ## UEFA CL 2021/22, 2021, uefacl
14
17
  # UEFA Europa League 2021, el21
15
18
 
16
-
19
+ uefa.cl, 2026/27, Champions League 2026/2027, 2026, ucl
17
20
  uefa.cl, 2025/26, Champions League 2025/2026, 2025, ucl
18
21
  uefa.cl, 2024/25, UEFA Champions League, 2024, ucl24
19
22
  uefa.cl, 2023/24, UEFA Champions League 2023/2024, 2023, champion1
@@ -37,7 +40,7 @@ uefa.cl, 2022/23, UEFA Champions League 22/23, 2022, uefacl22
37
40
  world, 2026, WM 2026, 2026, wm26
38
41
  world, 2022, WM-KATAR, 2022, WM2022
39
42
 
40
- euro, 2024, UEFA EURO 2024, 2024, em
43
+ euro, 2024, UEFA EURO 2024, 2024, em
41
44
  euro, 2021, UEFA EURO 2020, 2020, em20
42
45
 
43
46
  copa, 2024, Copa América 2024, 2024, CA2024
@@ -33,12 +33,27 @@ class Metal
33
33
  get( "#{BASE_URL}/getavailableleagues" )
34
34
  end
35
35
 
36
+
37
+ ###
38
+ # note - MUST escape URL path e.g. /getmatchdata/BLÖ/2026
39
+ # => /getmatchdata/BL%C3%96/2026
40
+ #
41
+ # Extra Tip:
42
+ # use CGI.escape !!
43
+ # Avoid URI.encode_www_form_component here
44
+ # While URI.encode_www_form_component is also built into Ruby,
45
+ # it turns spaces into plus signs (+) instead of %20.
46
+ # For URL paths (the parts between the slashes /),
47
+ # CGI.escape is usually the safer choice because it strictly
48
+ # uses percent-encoding (%).
49
+
50
+
36
51
  ## api call - /getavailableteams/{code}/{year}
37
52
  def self.teams( code, year )
38
53
  get( teams_url( code, year ) )
39
54
  end
40
55
  def self.teams_url( code, year )
41
- "#{BASE_URL}/getavailableteams/#{code}/#{year}"
56
+ "#{BASE_URL}/getavailableteams/#{CGI.escape(code)}/#{year}"
42
57
  end
43
58
 
44
59
  ## api call - /getmatchdata/{code}/{year}
@@ -46,12 +61,12 @@ class Metal
46
61
  get( matches_url( code, year ) )
47
62
  end
48
63
  def self.matches_url( code, year )
49
- "#{BASE_URL}/getmatchdata/#{code}/#{year}"
64
+ "#{BASE_URL}/getmatchdata/#{CGI.escape(code)}/#{year}"
50
65
  end
51
66
 
52
67
  ## api call - /getgoalgetters/{code}/{year}
53
68
  def self.goalgetters( code, year )
54
- get( "#{BASE_URL}/getgoalgetters/#{code}/#{year}" )
69
+ get( "#{BASE_URL}/getgoalgetters/#{CGI.escape(code)}/#{year}" )
55
70
  end
56
71
 
57
72
 
data/lib/openliga/tool.rb CHANGED
@@ -19,14 +19,14 @@ opts = {
19
19
 
20
20
 
21
21
  parser = OptionParser.new do |parser|
22
- parser.banner = "Usage: #{$PROGRAM_NAME} [options] NAME"
22
+ parser.banner = "Usage: #{$PROGRAM_NAME} [options] CODE"
23
23
 
24
- parser.on( "--metal",
24
+ parser.on( "--metal", "-m",
25
25
  "use openligadb.de shortcuts/codes and seasons/years (default: #{opts[:metal]})" ) do |metal|
26
26
  opts[:metal] = true
27
27
  end
28
28
 
29
- parser.on( "-o PATH", "--output",
29
+ parser.on( "--output=PATH", "-o",
30
30
  "write football.txt conversion to output path (default: #{opts[:outpath]||'none'})" ) do |outpath|
31
31
  opts[:outpath] = outpath
32
32
  end
@@ -104,7 +104,12 @@ end
104
104
  data = Metal.matches( code, year )
105
105
 
106
106
  puts " #{data.size} match(es)"
107
- pp data[0] ## dump first match
107
+
108
+ if data.empty?
109
+ ## do nothing; skip convert (& write)
110
+ else
111
+
112
+ pp data[0] ## dump first match
108
113
 
109
114
  ##################
110
115
  ### step 2 - convert to football.txt
@@ -115,20 +120,22 @@ end
115
120
  ###
116
121
  ### auto-add header
117
122
  ### note - use leagueName from first match
123
+ title = data[0]['leagueName']
124
+
118
125
  header =<<TXT
119
126
  ###
120
127
  # converted from openligadb.de json to Football.TXT
121
128
  # for source, see https://api.openligadb.de/getmatchdata/#{code}/#{year}
122
129
 
123
- = #{data[0]['leagueName']}
130
+ = #{title}
124
131
  TXT
125
132
 
133
+ puts header+body
126
134
 
127
- puts header+body
128
-
129
- if opts[:outpath]
130
- puts " writing football.txt to >#{opts[:outpath]}<"
131
- write_text( opts[:outpath], header+body )
135
+ if opts[:outpath]
136
+ puts " writing football.txt to >#{opts[:outpath]}<"
137
+ write_text( opts[:outpath], header+body )
138
+ end
132
139
  end
133
140
 
134
141
  puts "bye"
data/lib/openliga.rb CHANGED
@@ -2,6 +2,8 @@
2
2
  require 'season/formats' ## add season support
3
3
  require 'webget' ## incl. webget, webcache, webclient, etc.
4
4
 
5
+ require 'cgi' ## todo - check if already required upstream!!!
6
+ ## pulled-in for CGI.escpape (URI path) e.g. /getmatchdata/BLÖ/2026
5
7
 
6
8
 
7
9
  ###
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openliga
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.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: 2026-08-28 00:00:00.000000000 Z
11
+ date: 2026-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocos