From 46148dedf6aed6e65ce3a69bc83257435fa4e5ae Mon Sep 17 00:00:00 2001 From: filifa Date: Sat, 3 Aug 2024 15:54:35 -0500 Subject: [PATCH] check games table for live games --- mlbhighlightsave.sh | 6 ++++-- mlbplaysave.sh | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/mlbhighlightsave.sh b/mlbhighlightsave.sh index ed47dcc..6779098 100755 --- a/mlbhighlightsave.sh +++ b/mlbhighlightsave.sh @@ -30,8 +30,10 @@ then exit 1 fi -# grab most recently started live pk, if multiple -gamePk=$(mlblive schedule -t $team | jq '.dates[].games | map(select(.status.abstractGameState == "Live"))[-1].gamePk') +# grab the game pk of a single live game, if multiple (in case of spring +# training) +gamePk=$(sqlite3 $db "select gamePk from games where teamId='$team' and state='In Progress' limit 1") +if [[ -z "$gamePk" ]] if [[ "$gamePk" = 'null' ]] then echo "$0:" 'no live games found' >&2 diff --git a/mlbplaysave.sh b/mlbplaysave.sh index 865db56..6a36e33 100755 --- a/mlbplaysave.sh +++ b/mlbplaysave.sh @@ -30,9 +30,10 @@ then exit 1 fi -# grab most recently started live pk, if multiple -gamePk=$(mlblive schedule -t $team | jq '.dates[].games | map(select(.status.abstractGameState == "Live"))[-1].gamePk') -if [[ "$gamePk" = 'null' ]] +# grab the game pk of a single live game, if multiple (in case of spring +# training) +gamePk=$(sqlite3 $db "select gamePk from games where teamId='$team' and state='In Progress' limit 1") +if [[ -z "$gamePk" ]] then echo "$0:" 'no live games found' >&2 exit 1