From 44db3a28dcb804a6d30b1b73539d5bfdde595215 Mon Sep 17 00:00:00 2001 From: filifa Date: Tue, 30 Jul 2024 20:05:02 -0500 Subject: [PATCH] post with toot --- mlbposthighlights.sh | 18 ++++++++++++++++-- mlbpostplays.sh | 15 +++++++++++++-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/mlbposthighlights.sh b/mlbposthighlights.sh index 05118ba..eb139eb 100755 --- a/mlbposthighlights.sh +++ b/mlbposthighlights.sh @@ -2,12 +2,15 @@ set -e -while getopts 'd:' opt +while getopts 'd:a:' opt do case $opt in d) db=$OPTARG ;; + a) + account=$OPTARG + ;; ?) exit 1 ;; @@ -20,4 +23,15 @@ then exit 1 fi -sqlite3 $db < posthighlights.sql | awk -F  '{print $3 | "xargs curl >" $2; close("xargs curl >" $2); printf "%s\n\n#baseball #highlights\n", $1; print $2 | "xargs rm"}' +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}" diff --git a/mlbpostplays.sh b/mlbpostplays.sh index 3523e9b..5bc2cc8 100755 --- a/mlbpostplays.sh +++ b/mlbpostplays.sh @@ -2,12 +2,15 @@ set -e -while getopts 'd:' opt +while getopts 'd:a:' opt do case $opt in d) db=$OPTARG ;; + a) + account=$OPTARG + ;; ?) exit 1 ;; @@ -20,4 +23,12 @@ then 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}' +if [[ -z $account ]] +then + echo "$0:" '-a is required' >&2 + exit 1 +fi + +fmt='printf "%s\n\n%s %s\n#%s %s\n#%s %s\n\n#baseball #live\n", $1, $2, $3, $4, $5, $6, $7' +post="toot post --using $account" +sqlite3 $db < postplays.sql | awk -F  "{$fmt | \"$post\"}"