diff options
author | Arun Isaac | 2017-09-03 00:34:13 +0530 |
---|---|---|
committer | Arun Isaac | 2017-09-03 01:26:59 +0530 |
commit | 9ad176d854450b7474a4857dae76974249514dea (patch) | |
tree | eba3b6e0c524271f49cc4bccfca60c322dbc4d44 | |
parent | 14f8d7a6af77263c8a4a81971b0b31422c2faceb (diff) | |
download | nasa-apod-gnu-social-bot-9ad176d854450b7474a4857dae76974249514dea.tar.gz nasa-apod-gnu-social-bot-9ad176d854450b7474a4857dae76974249514dea.tar.lz nasa-apod-gnu-social-bot-9ad176d854450b7474a4857dae76974249514dea.zip |
Improve duplicate notice detection.
* apod-bot.sh: Use jq comparison to detect duplicate notice.
-rwxr-xr-x | apod-bot.sh | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/apod-bot.sh b/apod-bot.sh index 67e3a04..81fc5c3 100755 --- a/apod-bot.sh +++ b/apod-bot.sh @@ -40,13 +40,9 @@ page_link=$apod_base_url/ap$date.html notice="$title $page_link $media_link" # Ensure we are not publishing a duplicate notice -previous_notice=$(curl -sSu "$bot_username:$bot_password" $social_api_url/statuses/home_timeline.json \ - | jq -r '.[0] | .text') -if [[ "$notice" = "$previous_notice" ]] -then - echo "Notice \"$notice\" already published. Aborting..." >&2 - exit 1 -fi +curl -sSu "$bot_username:$bot_password" $social_api_url/statuses/home_timeline.json \ + | jq -e --arg notice "$notice" '(.[0] | .text) != $notice' > /dev/null \ + || (echo "Notice \"$notice\" already published. Aborting..." >&2 && exit 1) # Check image and page links exist wget --spider $media_link |