From 1fa0bdc78a28011ec88ce716b23b69f176b68add Mon Sep 17 00:00:00 2001 From: Anon Date: Tue, 16 Apr 2024 21:00:13 -0700 Subject: [PATCH] Updated to make image selections more random --- boorubot.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/boorubot.sh b/boorubot.sh index 5451a9b..197e066 100755 --- a/boorubot.sh +++ b/boorubot.sh @@ -53,10 +53,13 @@ TAGS_FMT=`echo "$TAGS" | tr ' ' '\n' | xargs echo | tr ' ' '+'` TAGS_BLK_FMT=`xargs -a "$TAGS_BLACKLIST" echo | sed 's|\ |+-|g'` TAGS_SEARCH="${TAGS_FMT}+sort:random+-${TAGS_BLK_FMT}" -RESULT=`curl -s --get "https://${BOORU_URL}/index.php" -d "page=dapi&s=post&q=index&json=1&limit=1&tags=${TAGS_SEARCH}"` +# RESULT=`curl -s --get "https://${BOORU_URL}/index.php" -d "page=dapi&s=post&q=index&json=1&limit=1&tags=${TAGS_SEARCH}"` +RESULT=`curl -s --get "https://${BOORU_URL}/index.php" -d "page=dapi&s=post&q=index&json=1&tags=${TAGS_SEARCH}"` -URL_FILE="$(echo "$RESULT" | jq -r '. | .post[0].file_url')" -RATING="$(echo "$RESULT" | jq -r '. | .post[0].rating')" +LENGTH="$(echo "$RESULT" | jq -r '. | .post | length')" +SELECTED=`shuf -i 0-$(expr $LENGTH - 1) -n 1` +URL_FILE="$(echo "$RESULT" | jq -r '. | .post['"$SELECTED"'].file_url')" +RATING="$(echo "$RESULT" | jq -r '. | .post['"$SELECTED"'].rating')" NSFW="--nsfw" TEXT="$MSG_NSFW"