Updated to make more reliable and verbose to diagnose a /tmp/null issue
This commit is contained in:
parent
2382989299
commit
34172b09be
@ -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&tags=${TAGS_SEARCH}"`
|
||||
|
||||
[ -z "$RESULT" ] && echo "Empty response for ${TAGS_SEARCH}" && exit 1
|
||||
LENGTH="$(echo "$RESULT" | jq -r '. | .post | length')"
|
||||
[ "$LENGTH" = 0 ] && echo "Zero length for ${TAGS_SEARCH}" && exit 1
|
||||
|
||||
LAST_INDEX=`expr $LENGTH - 1`
|
||||
SELECTION=`seq 0 $LAST_INDEX | shuf`
|
||||
|
||||
@ -81,6 +83,9 @@ for i in $SELECTION;do
|
||||
|
||||
PICKED="/tmp/$(basename "$URL_FILE")"
|
||||
|
||||
# This may be quirk of gelbooru
|
||||
[ "$PICKED" = "/tmp/null" ] && continue
|
||||
|
||||
# Always delete the temporary file
|
||||
trap "rm ${PICKED} ${TMP}" EXIT
|
||||
|
||||
@ -90,7 +95,7 @@ for i in $SELECTION;do
|
||||
[ "$RATING" = "general" ] && 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
|
||||
*': image/'*) ;;
|
||||
@ -103,4 +108,5 @@ for i in $SELECTION;do
|
||||
"$ENTRY" "$DEFAULT_CREDENTIALS" "$DEFAULT_KEYFILE" "$NSFW" "$@" "$TEXT" "$PICKED"
|
||||
exit 0
|
||||
done
|
||||
echo "Exited 1 for ${TAGS_SEARCH}"
|
||||
exit 1
|
||||
|
Loading…
Reference in New Issue
Block a user