use seed from initial response if available fetching a different page

This commit is contained in:
Adithya 2023-10-15 22:27:11 +05:30
parent ff657ed754
commit 9b756835a2
Signed by: adtya
GPG key ID: 48FC9915FFD326D0

View file

@ -76,7 +76,11 @@ RANDOM_ITEM="$(shuf -i 0-$((NO_OF_IMAGES-1)) -n 1 --random-source=/dev/urandom)"
ITEM_PAGE=$((RANDOM_ITEM/24)) ITEM_PAGE=$((RANDOM_ITEM/24))
ITEM_NUMBER=$((RANDOM_ITEM%24)) ITEM_NUMBER=$((RANDOM_ITEM%24))
if [ "${ITEM_PAGE}" -gt 0 ]; then if [ "${ITEM_PAGE}" -gt 0 ]; then
CURL_CMD="${CURL_BASE_CMD} \"${URL}page=$((ITEM_PAGE+1))\"" SEED="$(printf "${RESULT}" | jq -r '.meta.seed // empty')"
if [ -n "${SEED}" ]; then
SEED="seed=${SEED}&"
fi
CURL_CMD="${CURL_BASE_CMD} \"${URL}${SEED}page=$((ITEM_PAGE+1))\""
RESULT="$(eval ${CURL_CMD})" RESULT="$(eval ${CURL_CMD})"
fi fi
ID="$(printf "${RESULT}" | jq -r ".data[${ITEM_NUMBER}].id")" ID="$(printf "${RESULT}" | jq -r ".data[${ITEM_NUMBER}].id")"