Fixed off by one error, and made the script continue instead of exit on a failed download

This commit is contained in:
Anon 2024-05-04 19:04:21 -07:00
parent a1faa06871
commit 2382989299

View File

@ -66,7 +66,8 @@ 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&tags=${TAGS_SEARCH}"` RESULT=`curl -s --get "https://${BOORU_URL}/index.php" -d "page=dapi&s=post&q=index&json=1&tags=${TAGS_SEARCH}"`
LENGTH="$(echo "$RESULT" | jq -r '. | .post | length')" LENGTH="$(echo "$RESULT" | jq -r '. | .post | length')"
SELECTION=`seq 0 $LENGTH` LAST_INDEX=`expr $LENGTH - 1`
SELECTION=`seq 0 $LAST_INDEX | shuf`
for i in $SELECTION;do for i in $SELECTION;do
MD5="$(echo "$RESULT" | jq -r '. | .post['"$i"'].md5')" MD5="$(echo "$RESULT" | jq -r '. | .post['"$i"'].md5')"
@ -89,7 +90,7 @@ for i in $SELECTION;do
[ "$RATING" = "general" ] && NSFW="--safe" && TEXT="$MSG_SFW" [ "$RATING" = "general" ] && NSFW="--safe" && TEXT="$MSG_SFW"
[ "$RATING" = "sensitive" ] && NSFW="--safe" && TEXT="$MSG_SFW" [ "$RATING" = "sensitive" ] && NSFW="--safe" && TEXT="$MSG_SFW"
[ ! -f "$PICKED" ] && echo "Failed to download: ${PICKED}" && exit 1 [ ! -f "$PICKED" ] && echo "Failed to download: ${PICKED}" && sleep 30 && continue
case "$(file --mime-type "$PICKED")" in case "$(file --mime-type "$PICKED")" in
*': image/'*) ;; *': image/'*) ;;