Updated to make more reliable and verbose to diagnose a /tmp/null issue

This commit is contained in:
Anon 2024-05-05 15:30:32 -07:00
parent 2382989299
commit 34172b09be

View File

@ -64,8 +64,10 @@ 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}"` RESULT=`curl -s --get "https://${BOORU_URL}/index.php" -d "page=dapi&s=post&q=index&json=1&tags=${TAGS_SEARCH}"`
[ -z "$RESULT" ] && echo "Empty response for ${TAGS_SEARCH}" && exit 1
LENGTH="$(echo "$RESULT" | jq -r '. | .post | length')" LENGTH="$(echo "$RESULT" | jq -r '. | .post | length')"
[ "$LENGTH" = 0 ] && echo "Zero length for ${TAGS_SEARCH}" && exit 1
LAST_INDEX=`expr $LENGTH - 1` LAST_INDEX=`expr $LENGTH - 1`
SELECTION=`seq 0 $LAST_INDEX | shuf` SELECTION=`seq 0 $LAST_INDEX | shuf`
@ -81,6 +83,9 @@ for i in $SELECTION;do
PICKED="/tmp/$(basename "$URL_FILE")" PICKED="/tmp/$(basename "$URL_FILE")"
# This may be quirk of gelbooru
[ "$PICKED" = "/tmp/null" ] && continue
# Always delete the temporary file # Always delete the temporary file
trap "rm ${PICKED} ${TMP}" EXIT trap "rm ${PICKED} ${TMP}" EXIT
@ -90,7 +95,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}" && sleep 30 && continue [ ! -f "$PICKED" ] && echo "Failed to download: ${URL_FILE} to ${PICKED}" && sleep 30 && continue
case "$(file --mime-type "$PICKED")" in case "$(file --mime-type "$PICKED")" in
*': image/'*) ;; *': image/'*) ;;
@ -103,4 +108,5 @@ for i in $SELECTION;do
"$ENTRY" "$DEFAULT_CREDENTIALS" "$DEFAULT_KEYFILE" "$NSFW" "$@" "$TEXT" "$PICKED" "$ENTRY" "$DEFAULT_CREDENTIALS" "$DEFAULT_KEYFILE" "$NSFW" "$@" "$TEXT" "$PICKED"
exit 0 exit 0
done done
echo "Exited 1 for ${TAGS_SEARCH}"
exit 1 exit 1