use flag for $db

This commit is contained in:
filifa 2024-07-26 19:14:39 -05:00
parent 3c3a6062d1
commit 0342594993
3 changed files with 37 additions and 19 deletions

View File

@ -2,9 +2,12 @@
set -e
while getopts 't:' opt
while getopts 'd:t:' opt
do
case $opt in
d)
db=$OPTARG
;;
t)
team=$OPTARG
;;
@ -14,17 +17,17 @@ do
esac
done
if [[ -z $db ]]
then
echo "$0:" '-d is required' >&2
exit 1
fi
gamePk=$(./livepk.sh -t $team)
if [[ -z $gamePk || "$gamePk" = 'null' ]]
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/' | ./writedb.sh -d $DB -t highlights -c ''
mlblive content -g $gamePk | jq -Sc --unbuffered "$jqFilter" | sed -u 's/$/0/' | ./writedb.sh -d $db -t highlights -c ''

View File

@ -2,10 +2,22 @@
set -e
if [[ -z $DB ]]
while getopts 'd:' opt
do
case $opt in
d)
db=$OPTARG
;;
?)
exit 1
;;
esac
done
if [[ -z $db ]]
then
echo "$0:" '$DB not set' >&2
echo "$0:" '-d is required' >&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}'
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}'

View File

@ -2,9 +2,12 @@
set -e
while getopts 't:' opt
while getopts 'd:t:' opt
do
case $opt in
d)
db=$OPTARG
;;
t)
team=$OPTARG
;;
@ -14,17 +17,17 @@ do
esac
done
if [[ -z $db ]]
then
echo "$0:" '-d is required' >&2
exit 1
fi
gamePk=$(./livepk.sh -t $team)
if [[ -z $gamePk || "$gamePk" = 'null' ]]
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/' | ./writedb.sh -d $DB -t playinfo -c ''
mlblive subscribe -g $gamePk | jq -Sc --unbuffered "$jqFilter" | sed -u 's/$/0/' | ./writedb.sh -d $db -t playinfo -c ''