mlbstats-mastodon-scripts/content.sh

31 lines
569 B
Bash
Raw Normal View History

2024-07-25 02:17:36 +00:00
#!/bin/bash
2024-07-26 03:34:35 +00:00
set -e
2024-07-26 03:27:25 +00:00
while getopts 't:' opt
do
case $opt in
t)
team=$OPTARG
;;
?)
exit 1
;;
esac
done
gamePk=$(./livepk.sh -t $team)
if [[ -z $gamePk || "$gamePk" = 'null' ]]
2024-07-25 02:17:36 +00:00
then
exit 1
fi
2024-07-26 03:48:57 +00:00
if [[ -z $DB ]]
then
echo "$0:" '$DB not set' >&2
exit 1
fi
2024-07-25 02:17:36 +00:00
jqFilter='.highlights.highlights.items | map(select(.keywordsAll[].value == "highlight"))[] | {headline, id} + {url: (.playbacks | map(select(.name == "mp4Avc"))[0].url)}'
2024-07-27 00:02:45 +00:00
mlblive content -g $gamePk | jq -Sc --unbuffered "$jqFilter" | sed -u 's/$/0/' | ./writedb.sh -d $DB -t highlights -c ''