mlblive-mastodon-scripts/mlbhighlightpost.sh

38 lines
569 B
Bash
Raw Normal View History

2024-07-27 02:42:09 +00:00
#!/bin/bash
set -e
2024-07-31 01:05:02 +00:00
while getopts 'd:a:' opt
2024-07-27 02:42:09 +00:00
do
case $opt in
d)
db=$OPTARG
;;
2024-07-31 01:05:02 +00:00
a)
account=$OPTARG
;;
2024-07-27 02:42:09 +00:00
?)
exit 1
;;
esac
done
if [[ -z $db ]]
then
echo "$0:" '-d is required' >&2
exit 1
fi
2024-07-31 01:05:02 +00:00
if [[ -z $account ]]
then
echo "$0:" '-a is required' >&2
exit 1
fi
get='print $3 | "xargs curl >" $2; close("xargs curl >" $2)'
fmt='printf "%s\n\n#baseball #highlights\n", $1'
post='"toot post -m " $2'
post+="\" --using $account\""
del='print $2 | "xargs rm"'
sqlite3 $db < posthighlights.sql | awk -F  "{$get; $fmt | $post; close($post); $del}"