Download MLB game calendar for a given team
Project description
mlbcal
Download the schedule for a given team using the MLB Stats API.
installation
pip install mlbcal
No external dependencies to run. Need pytest to run the tests.
usage
usage: mlbcal [-h] [--year YEAR] [--full] [--nopre] [--csv] team
CLI to download MLB calendar for a given team. Default output is json
positional arguments:
team Team name, abbreviation, or city
options:
-h, --help show this help message and exit
--year YEAR Change schedule year (default: current year)
--full Return unparsed response (cannot use --csv and --nopre)
--nopre Filter out preseason spring training games
--csv Format results as csv (default: json)
examples
json default
All outputs are to stdout so you need to redirect to save files. The default format is json with two space indents:
$ mlbcal mariners > mariners.json
csv
$ mlbcal yankees --csv > yankees.csv
flags
The default year is the current year but you can change it. I don't know how far back the MLB API will respond with data:
$ mlbcal "San Diego" --csv --year 2021 > padres_last_year.csv
You can also filter out preseason games with a flag:
$ mlbcal LAA --csv --nopre > angels.csv
You can also get the unfurled but otherwise unparsed response this way:
$ mlbcal mets --full > mets.json
note on the team name lookup
data/teams.json
contains a lookup of team ids and different variations of the team names including abbreviations and city names to allow for flexible user input for the team names. The lookup data shipped in this repo was pulled in March 2022 which means it may not align with historical team names if you lookup past schedules.
You can download the team lookup for previous seasons by providing a year argument to the utils/download_teams.py
helper script.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file mlbcal-0.0.3.tar.gz
.
File metadata
- Download URL: mlbcal-0.0.3.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1af960fe350eccfcd0b1c3da402dff6d9540a2110c585afca5cb0f76ba3bf8a1 |
|
MD5 | b44407b19e62f0c50001496c0f959d29 |
|
BLAKE2b-256 | b5b126cfed91f109082b1063fcb36c4b44ec33cb2a207c50b8c2718cbb93ebc5 |
File details
Details for the file mlbcal-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: mlbcal-0.0.3-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b23d93aee5f0c00b3306dab6708bbbcb3dd5babd28f052310959609b7eff73fe |
|
MD5 | 7e01f1dfeee0985ca37efd4b5b1abeeb |
|
BLAKE2b-256 | 06d8c26f059629f5091390f59a39c8afa4ed573c4784359d46e927c6ee80e41a |