40 lines
666 B
Bash
Executable File
40 lines
666 B
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
while getopts 'd:t:' opt
|
|
do
|
|
case $opt in
|
|
d)
|
|
db=$OPTARG
|
|
;;
|
|
t)
|
|
team=$OPTARG
|
|
;;
|
|
?)
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
if [[ -z $db ]]
|
|
then
|
|
echo "$0:" '-d is required' >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ -z $team ]]
|
|
then
|
|
echo "$0:" '-t is required' >&2
|
|
exit 1
|
|
fi
|
|
|
|
gamePk=$(mlblivepk.sh -t $team)
|
|
if [[ -z $gamePk || "$gamePk" = 'null' ]]
|
|
then
|
|
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 ''
|