From 88870285c88064a3a300eba43da4676e7cd4caf7 Mon Sep 17 00:00:00 2001 From: filifa Date: Wed, 31 Jul 2024 21:39:11 -0500 Subject: [PATCH] simplify a little --- mlbhighlightpost.sh | 7 +++++++ mlbhighlightsave.sh | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/mlbhighlightpost.sh b/mlbhighlightpost.sh index eb139eb..cc4232e 100755 --- a/mlbhighlightpost.sh +++ b/mlbhighlightpost.sh @@ -29,6 +29,13 @@ then exit 1 fi +# summary of what these variables do in the awk script: +# get: download the highlight's url, and wait until it is downloaded before +# continuing +# fmt: print the text of the post +# post: use toot to post the text and the downloaded highlight (also wait until +# the toot is posted before continuing) +# rm: delete the downloaded highlight get='print $3 | "xargs curl >" $2; close("xargs curl >" $2)' fmt='printf "%s\n\n#baseball #highlights\n", $1' post='"toot post -m " $2' diff --git a/mlbhighlightsave.sh b/mlbhighlightsave.sh index 3342569..176b1d2 100755 --- a/mlbhighlightsave.sh +++ b/mlbhighlightsave.sh @@ -37,5 +37,7 @@ then exit 1 fi +# grab select data from response with jq, add 0 to the end of each line (to go +# in the 'posted' db column), then write each line to db 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/' | split -l 1 --filter="sqlite3 $db '.mode ascii' '.separator ' '.import /dev/stdin mlbdata'" +mlblive content -g $gamePk | jq -Sc "$jqFilter" | sed 's/$/0/' | sqlite3 $db '.mode ascii' '.separator  \n' '.import /dev/stdin mlbdata'