From 885219acd1e6f63136d711061174de5ade034646 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Ostroluck=C3=BD?= Date: Tue, 21 Jan 2020 20:37:08 +0100 Subject: [PATCH] Fix #8: jq: error: null (null) cannot be matched, as it is not a string --- download-subreddit-images.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/download-subreddit-images.sh b/download-subreddit-images.sh index 303afd4..5307237 100644 --- a/download-subreddit-images.sh +++ b/download-subreddit-images.sh @@ -20,9 +20,9 @@ url="https://www.reddit.com/r/$subreddit/$sort/.json?raw_json=1&t=$top_time" content=`wget -T $timeout -U "$useragent" -q -O - $url` mkdir -p $subreddit while : ; do - urls=$(echo -n "$content"| jq -r '.data.children[]|select(.data.post_hint|test("image")) | .data.preview.images[0].source.url') - names=$(echo -n "$content"| jq -r '.data.children[]|select(.data.post_hint|test("image")) | .data.title') - ids=$(echo -n "$content"| jq -r '.data.children[]|select(.data.post_hint|test("image")) | .data.id') + urls=$(echo -n "$content"| jq -r '.data.children[]|select(.data.post_hint|test("image")?) | .data.preview.images[0].source.url') + names=$(echo -n "$content"| jq -r '.data.children[]|select(.data.post_hint|test("image")?) | .data.title') + ids=$(echo -n "$content"| jq -r '.data.children[]|select(.data.post_hint|test("image")?) | .data.id') a=1 wait # prevent spawning too many processes for url in $urls; do