Compare commits

...

10 Commits

Author SHA1 Message Date
filifa 4bfec7c12c update name 2025-05-10 13:29:38 -04:00
filifa 7968e0f8cb change type to int 2025-04-08 00:54:15 -04:00
filifa cddcf64dde refactor 2025-04-08 00:52:21 -04:00
filifa d8bc8be4f1 return body in handleUnexpectedClose 2025-04-07 23:25:56 -04:00
filifa 7c18c0a396 bug bashin 2025-04-07 23:12:44 -04:00
filifa de3a09f145 remove git_push script 2025-04-06 23:12:02 -04:00
filifa 4ea313151f update copyright year 2025-04-06 23:06:47 -04:00
filifa 55d69a552e add copyright header 2025-04-06 23:02:50 -04:00
filifa 551b39652b change int32 to int 2025-04-06 22:29:56 -04:00
filifa 003f7b1309 go fmt 2025-04-06 22:14:30 -04:00
81 changed files with 4115 additions and 3164 deletions

View File

@ -1,49 +1,49 @@
# mlblive
mlblive is a CLI tool for retrieving data from Major League Baseball's Stats
# mlbstats
mlbstats is a CLI tool for retrieving data from Major League Baseball's Stats
API, including efficient retrieval of live game data. Unofficial documentation
on the Stats API can be found
[here](https://github.com/toddrob99/MLB-StatsAPI/wiki/Endpoints) (thanks to
GitHub user toddrob99 for this resource).
## Usage
mlblive provides sub-commands to query a subset of the Stats API endpoints. As
mlbstats provides sub-commands to query a subset of the Stats API endpoints. As
of the time of writing, the sub-commands are:
* `mlblive content` (accesses the `game_content` endpoint)
* `mlblive feed` (accesses the `game` endpoint)
* `mlblive schedule` (accesses the `schedule` endpoint)
* `mlblive standings` (accesses the `standings` endpoint)
* `mlblive subscribe` (accesses the game WebSocket endpoint)
* `mlbstats content` (accesses the `game_content` endpoint)
* `mlbstats feed` (accesses the `game` endpoint)
* `mlbstats schedule` (accesses the `schedule` endpoint)
* `mlbstats standings` (accesses the `standings` endpoint)
* `mlbstats subscribe` (accesses the game WebSocket endpoint)
Each sub-command outputs the raw JSON response from the API. This can then be
piped into other commands like `jq` for further processing. See [this
repo](https://scm.dairydemon.net/filifa/mlblive-mastodon-scripts) for examples
of how the author use this program for posting live score updates and
repo](https://scm.dairydemon.net/filifa/mlbstats-mastodon-scripts) for examples
of how the author uses this program for posting live score updates and
highlights to Mastodon.
Note that mlblive does not provide sub-commands for every endpoint, or flags
Note that mlbstats does not provide sub-commands for every endpoint, or flags
for every parameter of every endpoint. The functionality provided was
prioritized based on the author's own needs. However, the author has made every
effort to make the current functionality's code easy to read, and hopes it will
be similarly easy for other developers to extend functionality as needed.
### subscribe sub-command
`mlblive subscribe` provides an efficient way to obtain live data on active MLB
games. Supply the game's PK (which can be retrieved with `mlblive schedule`) to
`mlbstats subscribe` provides an efficient way to obtain live data on active MLB
games. Supply the game's PK (which can be retrieved with `mlbstats schedule`) to
receive updates as they happen, without needing to blindly query the `game`
endpoint.
### Example
Use `mlblive schedule` to get the game PK(s) for today's Reds game:
Use `mlbstats schedule` to get the game PK(s) for today's Reds game:
```
mlblive schedule -t cin
mlbstats schedule -t cin
```
Optionally, use `jq` to filter this output to *just* the game PK(s):
```
mlblive schedule -t cin | jq '.dates[].games[].gamePk'
mlbstats schedule -t cin | jq '.dates[].games[].gamePk'
```
Then, pass a PK to get live updates:
```
mlblive subscribe -g <gamePk>
mlbstats subscribe -g <gamePk>
```
## Disclaimer

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.
@ -19,7 +34,6 @@ import (
"strings"
)
// AnalyticsAPIService AnalyticsAPI service
type AnalyticsAPIService service

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.
@ -18,7 +33,6 @@ import (
"net/url"
)
// AttendanceAPIService AttendanceAPI service
type AttendanceAPIService service

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.
@ -19,7 +34,6 @@ import (
"strings"
)
// AwardsAPIService AwardsAPI service
type AwardsAPIService service

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.
@ -19,7 +34,6 @@ import (
"strings"
)
// BatTrackingAPIService BatTrackingAPI service
type BatTrackingAPIService service

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.
@ -19,7 +34,6 @@ import (
"strings"
)
// BiomechanicsAPIService BiomechanicsAPI service
type BiomechanicsAPIService service

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.
@ -18,7 +33,6 @@ import (
"net/url"
)
// BroadcastAPIService BroadcastAPI service
type BroadcastAPIService service

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.
@ -19,7 +34,6 @@ import (
"strings"
)
// ConferenceAPIService ConferenceAPI service
type ConferenceAPIService service

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.
@ -19,7 +34,6 @@ import (
"strings"
)
// DivisionAPIService DivisionAPI service
type DivisionAPIService service

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.
@ -19,7 +34,6 @@ import (
"strings"
)
// DraftAPIService DraftAPI service
type DraftAPIService service

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.
@ -19,7 +34,6 @@ import (
"strings"
)
// GameAPIService GameAPI service
type GameAPIService service

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.
@ -18,7 +33,6 @@ import (
"net/url"
)
// GamePaceAPIService GamePaceAPI service
type GamePaceAPIService service

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.
@ -19,7 +34,6 @@ import (
"strings"
)
// HighLowAPIService HighLowAPI service
type HighLowAPIService service

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.
@ -19,7 +34,6 @@ import (
"strings"
)
// HomerunDerbyAPIService HomerunDerbyAPI service
type HomerunDerbyAPIService service

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.
@ -19,7 +34,6 @@ import (
"strings"
)
// JobAPIService JobAPI service
type JobAPIService service

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.
@ -19,7 +34,6 @@ import (
"strings"
)
// LeagueAPIService LeagueAPI service
type LeagueAPIService service

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.
@ -18,7 +33,6 @@ import (
"net/url"
)
// MilestonesAPIService MilestonesAPI service
type MilestonesAPIService service

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.
@ -18,7 +33,6 @@ import (
"net/url"
)
// MiscAPIService MiscAPI service
type MiscAPIService service

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.
@ -19,7 +34,6 @@ import (
"strings"
)
// PersonAPIService PersonAPI service
type PersonAPIService service

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.
@ -18,7 +33,6 @@ import (
"net/url"
)
// PredictionsAPIService PredictionsAPI service
type PredictionsAPIService service

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.
@ -18,7 +33,6 @@ import (
"net/url"
)
// ReviewsAPIService ReviewsAPI service
type ReviewsAPIService service

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.
@ -18,7 +33,6 @@ import (
"net/url"
)
// ScheduleAPIService ScheduleAPI service
type ScheduleAPIService service

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.
@ -19,7 +34,6 @@ import (
"strings"
)
// SeasonAPIService SeasonAPI service
type SeasonAPIService service

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.
@ -19,7 +34,6 @@ import (
"strings"
)
// SkeletalAPIService SkeletalAPI service
type SkeletalAPIService service

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.
@ -19,7 +34,6 @@ import (
"strings"
)
// SportsAPIService SportsAPI service
type SportsAPIService service

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.
@ -19,7 +34,6 @@ import (
"strings"
)
// StandingsAPIService StandingsAPI service
type StandingsAPIService service

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.
@ -18,7 +33,6 @@ import (
"net/url"
)
// StatsAPIService StatsAPI service
type StatsAPIService service

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.
@ -18,7 +33,6 @@ import (
"net/url"
)
// StreaksAPIService StreaksAPI service
type StreaksAPIService service

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.
@ -19,7 +34,6 @@ import (
"strings"
)
// TeamsAPIService TeamsAPI service
type TeamsAPIService service

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.
@ -18,7 +33,6 @@ import (
"net/url"
)
// TransactionsAPIService TransactionsAPI service
type TransactionsAPIService service

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.
@ -18,7 +33,6 @@ import (
"net/url"
)
// UniformsAPIService UniformsAPI service
type UniformsAPIService service

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.
@ -19,7 +34,6 @@ import (
"strings"
)
// VenuesAPIService VenuesAPI service
type VenuesAPIService service

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.
@ -19,7 +34,6 @@ import (
"strings"
)
// WeatherAPIService WeatherAPI service
type WeatherAPIService service

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.
@ -31,14 +46,13 @@ import (
"strings"
"time"
"unicode/utf8"
)
var (
JsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:[^;]+\+)?json)`)
XmlCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:[^;]+\+)?xml)`)
queryParamSplit = regexp.MustCompile(`(^|&)([^&]+)`)
queryDescape = strings.NewReplacer( "%5B", "[", "%5D", "]" )
queryDescape = strings.NewReplacer("%5B", "[", "%5D", "]")
)
// APIClient manages communication with the Stats API Documentation API v2.0.0
@ -218,7 +232,7 @@ func typeCheckParameter(obj interface{}, expected string, name string) error {
return nil
}
func parameterValueToString( obj interface{}, key string ) string {
func parameterValueToString(obj interface{}, key string) string {
if reflect.TypeOf(obj).Kind() != reflect.Ptr {
if actualObj, ok := obj.(interface{ GetActualInstanceValue() interface{} }); ok {
return fmt.Sprintf("%v", actualObj.GetActualInstanceValue())
@ -226,11 +240,11 @@ func parameterValueToString( obj interface{}, key string ) string {
return fmt.Sprintf("%v", obj)
}
var param,ok = obj.(MappedNullable)
var param, ok = obj.(MappedNullable)
if !ok {
return ""
}
dataMap,err := param.ToMap()
dataMap, err := param.ToMap()
if err != nil {
return ""
}
@ -250,8 +264,8 @@ func parameterAddToHeaderOrQuery(headerOrQueryParams interface{}, keyPrefix stri
value = "invalid"
case reflect.Struct:
if t,ok := obj.(MappedNullable); ok {
dataMap,err := t.ToMap()
if t, ok := obj.(MappedNullable); ok {
dataMap, err := t.ToMap()
if err != nil {
return
}
@ -269,7 +283,7 @@ func parameterAddToHeaderOrQuery(headerOrQueryParams interface{}, keyPrefix stri
return
}
var lenIndValue = indValue.Len()
for i:=0;i<lenIndValue;i++ {
for i := 0; i < lenIndValue; i++ {
var arrayValue = indValue.Index(i)
var keyPrefixForCollectionType = keyPrefix
if style == "deepObject" {
@ -286,7 +300,7 @@ func parameterAddToHeaderOrQuery(headerOrQueryParams interface{}, keyPrefix stri
}
iter := indValue.MapRange()
for iter.Next() {
k,v := iter.Key(), iter.Value()
k, v := iter.Key(), iter.Value()
parameterAddToHeaderOrQuery(headerOrQueryParams, fmt.Sprintf("%s[%s]", keyPrefix, k.String()), v.Interface(), style, collectionType)
}
return
@ -317,7 +331,7 @@ func parameterAddToHeaderOrQuery(headerOrQueryParams interface{}, keyPrefix stri
switch valuesMap := headerOrQueryParams.(type) {
case url.Values:
if collectionType == "csv" && valuesMap.Get(keyPrefix) != "" {
valuesMap.Set(keyPrefix, valuesMap.Get(keyPrefix) + "," + value)
valuesMap.Set(keyPrefix, valuesMap.Get(keyPrefix)+","+value)
} else {
valuesMap.Add(keyPrefix, value)
}

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.
@ -94,8 +109,7 @@ func NewConfiguration() *Configuration {
Description: "No description provided",
},
},
OperationServers: map[string]ServerConfigurations{
},
OperationServers: map[string]ServerConfigurations{},
}
return cfg
}

View File

@ -1,57 +0,0 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com"
git_user_id=$1
git_repo_id=$2
release_note=$3
git_host=$4
if [ "$git_host" = "" ]; then
git_host=""
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
fi
if [ "$git_user_id" = "" ]; then
git_user_id=""
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
fi
if [ "$git_repo_id" = "" ]; then
git_repo_id=""
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
fi
if [ "$release_note" = "" ]; then
release_note=""
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
fi
# Initialize the local directory as a Git repository
git init
# Adds the files in the local repository and stages them for commit.
git add .
# Commits the tracked changes and prepares them to be pushed to a remote repository.
git commit -m "$release_note"
# Sets the new remote
git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
git pull origin master
# Pushes (Forces) the changes in the local repository up to the remote repository
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Testing AnalyticsAPIService
@ -10,11 +25,11 @@ Testing AnalyticsAPIService
package api
import (
openapiclient "//"
"context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
openapiclient "//"
)
func Test_api_AnalyticsAPIService(t *testing.T) {

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Testing AttendanceAPIService
@ -10,11 +25,11 @@ Testing AttendanceAPIService
package api
import (
openapiclient "//"
"context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
openapiclient "//"
)
func Test_api_AttendanceAPIService(t *testing.T) {

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Testing AwardsAPIService
@ -10,11 +25,11 @@ Testing AwardsAPIService
package api
import (
openapiclient "//"
"context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
openapiclient "//"
)
func Test_api_AwardsAPIService(t *testing.T) {

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Testing BatTrackingAPIService
@ -10,11 +25,11 @@ Testing BatTrackingAPIService
package api
import (
openapiclient "//"
"context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
openapiclient "//"
)
func Test_api_BatTrackingAPIService(t *testing.T) {

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Testing BiomechanicsAPIService
@ -10,11 +25,11 @@ Testing BiomechanicsAPIService
package api
import (
openapiclient "//"
"context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
openapiclient "//"
)
func Test_api_BiomechanicsAPIService(t *testing.T) {

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Testing BroadcastAPIService
@ -10,11 +25,11 @@ Testing BroadcastAPIService
package api
import (
openapiclient "//"
"context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
openapiclient "//"
)
func Test_api_BroadcastAPIService(t *testing.T) {

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Testing ConferenceAPIService
@ -10,11 +25,11 @@ Testing ConferenceAPIService
package api
import (
openapiclient "//"
"context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
openapiclient "//"
)
func Test_api_ConferenceAPIService(t *testing.T) {

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Testing DivisionAPIService
@ -10,11 +25,11 @@ Testing DivisionAPIService
package api
import (
openapiclient "//"
"context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
openapiclient "//"
)
func Test_api_DivisionAPIService(t *testing.T) {

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Testing DraftAPIService
@ -10,11 +25,11 @@ Testing DraftAPIService
package api
import (
openapiclient "//"
"context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
openapiclient "//"
)
func Test_api_DraftAPIService(t *testing.T) {

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Testing GamePaceAPIService
@ -10,11 +25,11 @@ Testing GamePaceAPIService
package api
import (
openapiclient "//"
"context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
openapiclient "//"
)
func Test_api_GamePaceAPIService(t *testing.T) {

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Testing GameAPIService
@ -10,11 +25,11 @@ Testing GameAPIService
package api
import (
openapiclient "//"
"context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
openapiclient "//"
)
func Test_api_GameAPIService(t *testing.T) {

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Testing HighLowAPIService
@ -10,11 +25,11 @@ Testing HighLowAPIService
package api
import (
openapiclient "//"
"context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
openapiclient "//"
)
func Test_api_HighLowAPIService(t *testing.T) {

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Testing HomerunDerbyAPIService
@ -10,11 +25,11 @@ Testing HomerunDerbyAPIService
package api
import (
openapiclient "//"
"context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
openapiclient "//"
)
func Test_api_HomerunDerbyAPIService(t *testing.T) {

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Testing JobAPIService
@ -10,11 +25,11 @@ Testing JobAPIService
package api
import (
openapiclient "//"
"context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
openapiclient "//"
)
func Test_api_JobAPIService(t *testing.T) {

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Testing LeagueAPIService
@ -10,11 +25,11 @@ Testing LeagueAPIService
package api
import (
openapiclient "//"
"context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
openapiclient "//"
)
func Test_api_LeagueAPIService(t *testing.T) {

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Testing MilestonesAPIService
@ -10,11 +25,11 @@ Testing MilestonesAPIService
package api
import (
openapiclient "//"
"context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
openapiclient "//"
)
func Test_api_MilestonesAPIService(t *testing.T) {

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Testing MiscAPIService
@ -10,11 +25,11 @@ Testing MiscAPIService
package api
import (
openapiclient "//"
"context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
openapiclient "//"
)
func Test_api_MiscAPIService(t *testing.T) {

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Testing PersonAPIService
@ -10,11 +25,11 @@ Testing PersonAPIService
package api
import (
openapiclient "//"
"context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
openapiclient "//"
)
func Test_api_PersonAPIService(t *testing.T) {

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Testing PredictionsAPIService
@ -10,11 +25,11 @@ Testing PredictionsAPIService
package api
import (
openapiclient "//"
"context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
openapiclient "//"
)
func Test_api_PredictionsAPIService(t *testing.T) {

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Testing ReviewsAPIService
@ -10,11 +25,11 @@ Testing ReviewsAPIService
package api
import (
openapiclient "//"
"context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
openapiclient "//"
)
func Test_api_ReviewsAPIService(t *testing.T) {

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Testing ScheduleAPIService
@ -10,11 +25,11 @@ Testing ScheduleAPIService
package api
import (
openapiclient "//"
"context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
openapiclient "//"
)
func Test_api_ScheduleAPIService(t *testing.T) {

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Testing SeasonAPIService
@ -10,11 +25,11 @@ Testing SeasonAPIService
package api
import (
openapiclient "//"
"context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
openapiclient "//"
)
func Test_api_SeasonAPIService(t *testing.T) {

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Testing SkeletalAPIService
@ -10,11 +25,11 @@ Testing SkeletalAPIService
package api
import (
openapiclient "//"
"context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
openapiclient "//"
)
func Test_api_SkeletalAPIService(t *testing.T) {

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Testing SportsAPIService
@ -10,11 +25,11 @@ Testing SportsAPIService
package api
import (
openapiclient "//"
"context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
openapiclient "//"
)
func Test_api_SportsAPIService(t *testing.T) {

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Testing StandingsAPIService
@ -10,11 +25,11 @@ Testing StandingsAPIService
package api
import (
openapiclient "//"
"context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
openapiclient "//"
)
func Test_api_StandingsAPIService(t *testing.T) {

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Testing StatsAPIService
@ -10,11 +25,11 @@ Testing StatsAPIService
package api
import (
openapiclient "//"
"context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
openapiclient "//"
)
func Test_api_StatsAPIService(t *testing.T) {

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Testing StreaksAPIService
@ -10,11 +25,11 @@ Testing StreaksAPIService
package api
import (
openapiclient "//"
"context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
openapiclient "//"
)
func Test_api_StreaksAPIService(t *testing.T) {

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Testing TeamsAPIService
@ -10,11 +25,11 @@ Testing TeamsAPIService
package api
import (
openapiclient "//"
"context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
openapiclient "//"
)
func Test_api_TeamsAPIService(t *testing.T) {

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Testing TransactionsAPIService
@ -10,11 +25,11 @@ Testing TransactionsAPIService
package api
import (
openapiclient "//"
"context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
openapiclient "//"
)
func Test_api_TransactionsAPIService(t *testing.T) {

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Testing UniformsAPIService
@ -10,11 +25,11 @@ Testing UniformsAPIService
package api
import (
openapiclient "//"
"context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
openapiclient "//"
)
func Test_api_UniformsAPIService(t *testing.T) {

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Testing VenuesAPIService
@ -10,11 +25,11 @@ Testing VenuesAPIService
package api
import (
openapiclient "//"
"context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
openapiclient "//"
)
func Test_api_VenuesAPIService(t *testing.T) {

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Testing WeatherAPIService
@ -10,11 +25,11 @@ Testing WeatherAPIService
package api
import (
openapiclient "//"
"context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
openapiclient "//"
)
func Test_api_WeatherAPIService(t *testing.T) {

View File

@ -1,4 +1,19 @@
/*
Copyright © 2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Stats API Documentation
Official API for Major League Baseball.

View File

@ -1,5 +1,5 @@
/*
Copyright © 2024 filifa
Copyright © 2024,2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@ -35,8 +35,7 @@ var statsAPIConfiguration = &api.Configuration{
Description: "No description provided",
},
},
OperationServers: map[string]api.ServerConfigurations{
},
OperationServers: map[string]api.ServerConfigurations{},
}
var statsAPIClient = api.NewAPIClient(statsAPIConfiguration)

View File

@ -1,5 +1,5 @@
/*
Copyright © 2024 filifa
Copyright © 2024,2025 filifa
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -61,6 +61,6 @@ func init() {
// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
contentCmd.Flags().Int32VarP(&gamePk, "gamePk", "g", 0, "game PK")
contentCmd.Flags().IntVarP(&gamePk, "gamePk", "g", 0, "game PK")
contentCmd.MarkFlagRequired("gamePk")
}

View File

@ -1,5 +1,5 @@
/*
Copyright © 2024 filifa
Copyright © 2024,2025 filifa
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -61,6 +61,6 @@ func init() {
// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
feedCmd.Flags().Int32VarP(&gamePk, "gamePk", "g", 0, "game PK")
feedCmd.Flags().IntVarP(&gamePk, "gamePk", "g", 0, "game PK")
feedCmd.MarkFlagRequired("gamePk")
}

View File

@ -1,5 +1,5 @@
/*
Copyright © 2024 filifa
Copyright © 2024,2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@ -20,7 +20,7 @@ import (
)
// retrieved from https://statsapi.mlb.com/api/v1/leagues
var leagueIDs = map[string]int32{
var leagueIDs = map[string]int{
"al": 103,
"nl": 104,
"nn2": 431,

View File

@ -23,7 +23,7 @@ import (
// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "mlblive",
Use: "mlbstats",
Short: "Command line tools for Major League Baseball's Stats API",
Long: `Command line tools for Major League Baseball's Stats API.`,
}

View File

@ -1,5 +1,5 @@
/*
Copyright © 2024 filifa
Copyright © 2024,2025 filifa
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@ -1,5 +1,5 @@
/*
Copyright © 2024 filifa
Copyright © 2024,2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@ -20,7 +20,7 @@ import (
)
// retrieved from https://statsapi.mlb.com/api/v1/sports
var sportIDs = map[string]int32{
var sportIDs = map[string]int{
"mlb": 1,
"aaa": 11,
"aa": 12,

View File

@ -1,5 +1,5 @@
/*
Copyright © 2024 filifa
Copyright © 2024,2025 filifa
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -28,7 +28,7 @@ import (
var league leagueAbbr
func standings(cmd *cobra.Command, args []string) {
var leagueIds []int32
var leagueIds []int
leagueIds = append(leagueIds, leagueIDs[string(league)])
req := statsAPIClient.StandingsAPI.Standings1(context.Background(), "regularSeason")

View File

@ -1,5 +1,5 @@
/*
Copyright © 2024 filifa
Copyright © 2024,2025 filifa
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -30,7 +30,21 @@ import (
"scm.dairydemon.net/filifa/mlbstats/api"
)
var gamePk int32
var gamePk int
func extractTimestamp(body []byte) (any, error) {
var v any
err := json.Unmarshal(body, &v)
if err != nil {
return nil, err
}
vobj := v.(map[string]any)
metaData := vobj["metaData"].(map[string]any)
timestamp := metaData["timeStamp"]
return timestamp, nil
}
func extractPatches(resp []byte) ([]jsonpatch.Patch, error) {
var patches []jsonpatch.Patch
@ -46,49 +60,48 @@ func extractPatches(resp []byte) ([]jsonpatch.Patch, error) {
patches = append(patches, patch)
}
return patches, err
return patches, nil
}
func patch(body []byte, client *api.APIClient) error {
var v any
err := json.Unmarshal(body, &v)
if err != nil {
return err
}
vobj := v.(map[string]any)
metaData := vobj["metaData"].(map[string]any)
timestamp := metaData["timeStamp"]
func requestPatches(timestamp any, client *api.APIClient) ([]jsonpatch.Patch, error) {
req := client.GameAPI.LiveGameDiffPatchV1(context.Background(), gamePk)
req.StartTimecode(timestamp)
req = req.StartTimecode(timestamp)
resp, err := req.Execute()
if err != nil {
return err
return nil, err
}
diffPatch, err := io.ReadAll(resp.Body)
if err != nil {
return err
return nil, err
}
patches, err := extractPatches(diffPatch)
return extractPatches(diffPatch)
}
func patch(body []byte, client *api.APIClient) ([]byte, error) {
timestamp, err := extractTimestamp(body)
if err != nil {
return err
return body, err
}
patches, err := requestPatches(timestamp, client)
if err != nil {
return body, err
}
for _, patch := range patches {
body, err = patch.Apply(body)
if err != nil {
return err
return body, err
}
}
return err
return body, nil
}
func newWebsocket(gamePk int32) (*gamedayWebsocket, <-chan error, error) {
func newWebsocket(gamePk int) (*gamedayWebsocket, <-chan error, error) {
ws, err := newGamedayWebsocket(gamePk)
if err != nil {
return nil, nil, err
@ -97,57 +110,59 @@ func newWebsocket(gamePk int32) (*gamedayWebsocket, <-chan error, error) {
ch := make(chan error)
go ws.keepAlive(10*time.Second, ch)
return ws, ch, err
return ws, ch, nil
}
func handleUnexpectedClose(body []byte, client *api.APIClient) (*gamedayWebsocket, error) {
func handleUnexpectedClose(client *api.APIClient) ([]byte, *gamedayWebsocket, error) {
ws, _, err := newWebsocket(gamePk)
if err != nil {
return nil, err
return nil, nil, err
}
req := client.GameAPI.LiveGameV1(context.Background(), gamePk)
resp, err := req.Execute()
if err != nil {
return ws, err
return nil, ws, err
}
body, err = io.ReadAll(resp.Body)
return ws, err
body, err := io.ReadAll(resp.Body)
return body, ws, err
}
func updateFeed(body []byte, ws *gamedayWebsocket, client *api.APIClient) error {
func handlePush(ws *gamedayWebsocket, client *api.APIClient) ([]byte, error) {
var p push
err := ws.ReadJSON(&p)
if websocket.IsUnexpectedCloseError(err, GameFinalCode, GameUnavailableCode) {
log.Println(err)
newWs, err := handleUnexpectedClose(body, client)
body, newWs, err := handleUnexpectedClose(client)
if err != nil {
return err
return body, err
}
*ws = *newWs
return err
} else if err != nil {
return err
return body, nil
}
err = patch(body, client)
return nil, err
}
func updateFeed(body []byte, client *api.APIClient) ([]byte, error) {
body, err := patch(body, client)
if err != nil {
req := client.GameAPI.LiveGameV1(context.Background(), gamePk)
resp, err := req.Execute()
if err != nil {
return err
return body, err
}
body, err = io.ReadAll(resp.Body)
if err != nil {
return err
return body, err
}
}
return err
return body, nil
}
func subscribe(cmd *cobra.Command, args []string) {
@ -164,15 +179,23 @@ func subscribe(cmd *cobra.Command, args []string) {
log.Fatal(err)
}
for {
body, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
for {
fmt.Println(string(body))
err = updateFeed(body, ws, statsAPIClient)
newBody, err := handlePush(ws, statsAPIClient)
if err != nil {
log.Fatal(err)
} else if newBody != nil {
body = newBody
continue
}
body, err = updateFeed(body, statsAPIClient)
if err != nil {
log.Fatal(err)
}
@ -202,6 +225,6 @@ func init() {
// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
subscribeCmd.Flags().Int32VarP(&gamePk, "gamePk", "g", 0, "game PK")
subscribeCmd.Flags().IntVarP(&gamePk, "gamePk", "g", 0, "game PK")
subscribeCmd.MarkFlagRequired("gamePk")
}

View File

@ -1,5 +1,5 @@
/*
Copyright © 2024 filifa
Copyright © 2024,2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@ -20,7 +20,7 @@ import (
)
// retrieved from https://statsapi.mlb.com/api/v1/teams
var teamIDs = map[string]int32{
var teamIDs = map[string]int{
"laa": 108,
"az": 109,
"bal": 110,

View File

@ -1,5 +1,5 @@
/*
Copyright © 2024 filifa
Copyright © 2024,2025 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@ -43,7 +43,7 @@ type gamedayWebsocket struct {
// NewGamedayWebsocket creates a statsapi.GamedayWebsocket using the Stats API
// websocket URL and establishes a connection.
func newGamedayWebsocket(gamePk int32) (*gamedayWebsocket, error) {
func newGamedayWebsocket(gamePk int) (*gamedayWebsocket, error) {
ws := gamedayWebsocket{
baseURL: url.URL{
Scheme: "wss",
@ -55,9 +55,9 @@ func newGamedayWebsocket(gamePk int32) (*gamedayWebsocket, error) {
return &ws, err
}
func (g *gamedayWebsocket) init(gamePk int32) error {
func (g *gamedayWebsocket) init(gamePk int) error {
endpoint := url.URL{
Path: "api/v1/game/push/subscribe/gameday/" + strconv.Itoa(int(gamePk)),
Path: "api/v1/game/push/subscribe/gameday/" + strconv.Itoa(gamePk),
}
url := g.baseURL.ResolveReference(&endpoint)