From b8d0593ecf5a52f74a40518be32fe538e2bd7f9f Mon Sep 17 00:00:00 2001 From: Joel Grunbaum <joelgrun@gmail.com> Date: Tue, 15 Dec 2020 04:35:06 +0000 Subject: [PATCH] Added support for image galleries --- reddit-wallpaper-fetcher | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/reddit-wallpaper-fetcher b/reddit-wallpaper-fetcher index 310c97e..a13b916 100755 --- a/reddit-wallpaper-fetcher +++ b/reddit-wallpaper-fetcher @@ -53,8 +53,12 @@ #Download image url=$(echo "$LATEST" | jq ".data.children[-1].data.url" | sed 's/"//g') +if [ -n "$(echo $url | grep gallery)" ]; then + media_id=$(echo "$LATEST" | jq ".data.children[-1].data.gallery_data.items[0].media_id" | sed 's/"//g') + url=$(echo "$LATEST" | jq ".data.children[-1].data.media_metadata.$media_id.p[0].u" | sed 's/"//g;s/\?.*//g;s/preview/i/g') +fi ext="$(echo "$url" | rev | cut -d'.' -f1 | rev)" -curl "$LOUD" -o "$WALLDIR/temp.$ext" "$url" +curl "$url" "$LOUD" --output "$WALLDIR/temp.$ext" #Save image information echo "$LATEST" > "$WALLDIR"/json -- Gitblit v1.10.0