update name of mlbstats

This commit is contained in:
filifa 2025-05-11 19:55:01 -04:00
parent 120604c131
commit a9fe0fbad6
4 changed files with 6 additions and 6 deletions

View File

@ -1,4 +1,4 @@
# mlblive-mastodon-scripts # mlbstats-mastodon-scripts
This repo contains some scripts to help automate posting live MLB game updates This repo contains some scripts to help automate posting live MLB game updates
to Mastodon. to Mastodon.
@ -23,7 +23,7 @@ These are used as delimiters when processing the data.
## How to use ## How to use
### Dependencies ### Dependencies
To run these scripts, you'll need a few other programs: To run these scripts, you'll need a few other programs:
* [mlblive](https://scm.dairydemon.net/filifa/mlblive), another program I wrote * [mlbstats](https://scm.dairydemon.net/filifa/mlbstats), another program I wrote
for retrieving data from MLB's Stats API for retrieving data from MLB's Stats API
* `toot`, a CLI program for Mastodon * `toot`, a CLI program for Mastodon
* `jq`, a program for processing JSON data * `jq`, a program for processing JSON data
@ -38,7 +38,7 @@ scripts:
1. Put all the shell scripts somewhere convenient (I put them in 1. Put all the shell scripts somewhere convenient (I put them in
`~/.local/bin`). `~/.local/bin`).
2. Pick a directory to keep the SQLite database in (I picked 2. Pick a directory to keep the SQLite database in (I picked
`~/.local/share/mlblive`). `~/.local/share/mlbstats`).
3. Create the database with `sqlite3 <filename> < schema.sql` 3. Create the database with `sqlite3 <filename> < schema.sql`
* I recommend making one database for plays and one for highlights * I recommend making one database for plays and one for highlights
(assuming you wish to process both) for each team you want to follow. (assuming you wish to process both) for each team you want to follow.

View File

@ -32,4 +32,4 @@ fi
jqFilter='.dates[].games[]' jqFilter='.dates[].games[]'
fmt="OFS=\"\"; print \$0, 0" fmt="OFS=\"\"; print \$0, 0"
save="\"sqlite3 $db '.mode ascii' '.separator ' '.import /dev/stdin games'\"" save="\"sqlite3 $db '.mode ascii' '.separator ' '.import /dev/stdin games'\""
mlblive schedule -t $team | jq -Sc "$jqFilter" | awk -F  "{$fmt | $save; close($save)}" mlbstats schedule -t $team | jq -Sc "$jqFilter" | awk -F  "{$fmt | $save; close($save)}"

View File

@ -33,4 +33,4 @@ fi
# grab select data from response with jq, add 0 to the end of each line (to go # grab select data from response with jq, add 0 to the end of each line (to go
# in the 'posted' db column), then write each line to db # in the 'posted' db column), then write each line to db
jqFilter='.highlights.highlights.items | map(select(.keywordsAll[].value == "highlight"))[] | {headline, id} + {url: (.playbacks | map(select(.name == "mp4Avc"))[0].url)} | select(.url | startswith("https://mlb-cuts-diamond"))' jqFilter='.highlights.highlights.items | map(select(.keywordsAll[].value == "highlight"))[] | {headline, id} + {url: (.playbacks | map(select(.name == "mp4Avc"))[0].url)} | select(.url | startswith("https://mlb-cuts-diamond"))'
mlblive content -g $gamePk | jq -Sc "$jqFilter" | sed 's/$/0/' | sqlite3 $db '.mode ascii' '.separator  \n' '.import /dev/stdin highlights' mlbstats content -g $gamePk | jq -Sc "$jqFilter" | sed 's/$/0/' | sqlite3 $db '.mode ascii' '.separator  \n' '.import /dev/stdin highlights'

View File

@ -37,4 +37,4 @@ save="\"sqlite3 $db '.mode ascii' '.separator ' '.import /dev/stdin plays'\""
# grab select data from each response with jq, add 0 to the end of each line # grab select data from each response with jq, add 0 to the end of each line
# (to go in the 'posted' db column), then write each line as they come in to db # (to go in the 'posted' db column), then write each line as they come in to db
mlblive subscribe -g $gamePk | jq -Sc "$jqFilter" | awk "{$fmt | $save; close($save)}" mlbstats subscribe -g $gamePk | jq -Sc "$jqFilter" | awk "{$fmt | $save; close($save)}"