Handle entries with no image download link (e.g. videos)
This commit is contained in:
parent
4d7450727c
commit
10ec3a3a37
1 changed files with 8 additions and 2 deletions
|
|
@ -19,11 +19,17 @@ echo "Received response from API"
|
|||
# shellcheck disable=SC2005
|
||||
echo "$(printf '%s' "${response}" | jq '.')"
|
||||
echo "Parsing data"
|
||||
picture_date="$(printf '%s' "${response}" | jq --raw-output .date)"
|
||||
picture_url="$(printf '%s' "${response}" | jq --raw-output .hdurl)"
|
||||
rate_remaining="$(printf '%s' "${response}" | jq '."rate-limit"')"
|
||||
echo "Remaining requests until rate limit: ${rate_remaining}"
|
||||
|
||||
if [ "$(printf '%s' "${response}" | jq 'has("hdurl")')" == "false" ]; then
|
||||
echo "Response contains no download URL"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
picture_date="$(printf '%s' "${response}" | jq --raw-output .date)"
|
||||
picture_url="$(printf '%s' "${response}" | jq --raw-output .hdurl)"
|
||||
|
||||
echo "Generating output filename"
|
||||
extension="${picture_url##*.}"
|
||||
filename="${picture_date}.${extension}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue