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