From 4ccb6aa4097d46e7a9c189eb3accbd01ac04dc4e Mon Sep 17 00:00:00 2001 From: filifa Date: Thu, 25 Jul 2024 22:48:57 -0500 Subject: [PATCH] check if DB is set --- content.sh | 6 ++++++ postplays.sh | 6 ++++++ subscribe.sh | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/content.sh b/content.sh index 8fa2433..99211d3 100755 --- a/content.sh +++ b/content.sh @@ -20,5 +20,11 @@ then exit 1 fi +if [[ -z $DB ]] +then + echo "$0:" '$DB not set' >&2 + exit 1 +fi + jqFilter='.highlights.highlights.items | map(select(.keywordsAll[].value == "highlight"))[] | {headline, id} + {url: (.playbacks | map(select(.name == "mp4Avc"))[0].url)}' mlblive content -g $gamePk | jq -Sc --unbuffered "$jqFilter" | sed -u 's/$/0/' | split -l 1 --filter="sqlite3 $DB '.mode ascii' '.separator ' '.import /dev/stdin highlights'" diff --git a/postplays.sh b/postplays.sh index 9f9bcc2..bc26b34 100755 --- a/postplays.sh +++ b/postplays.sh @@ -2,4 +2,10 @@ set -e +if [[ -z $DB ]] +then + echo "$0:" '$DB not set' >&2 + exit 1 +fi + sqlite3 $DB < postplays.sql | awk -F  '{printf "%s\n\n%s %s\n#%s %s\n#%s %s\n\n#baseball #live\n", $1, $2, $3, $4, $5, $6, $7}' diff --git a/subscribe.sh b/subscribe.sh index 9f8cf43..1230c32 100755 --- a/subscribe.sh +++ b/subscribe.sh @@ -20,5 +20,11 @@ then exit 1 fi +if [[ -z $DB ]] +then + echo "$0:" '$DB not set' >&2 + exit 1 +fi + jqFilter='{gamePk} + (.gameData.teams | {awayTeam: .away.teamName, homeTeam: .home.teamName}) + (.liveData.plays.allPlays[] | (.result + (.about | {atBatIndex, halfInning, inning, isComplete, isScoringPlay, hasReview})))' mlblive subscribe -g $gamePk | jq -Sc --unbuffered "$jqFilter" | sed -u 's/$/0/' | split -l 1 --filter="sqlite3 $DB '.mode ascii' '.separator ' '.import /dev/stdin playinfo'"