mirror of https://github.com/Chizi123/Reddit-wallpaper-fetcher.git

Joel Grunbaum
2020-12-15 b8d0593ecf5a52f74a40518be32fe538e2bd7f9f
reddit-wallpaper-fetcher
@@ -32,6 +32,9 @@
    LATEST=$(cat "$WALLDIR"/json)
    LATEST_TIME=$(echo "$LATEST" | jq ".data.children[-1].data.created_utc")
fi
if [ "$LATEST_TIME" == "null" ]; then
    LATEST_TIME=0
fi
#Try subreddits for new images
for i in "${SUBREDDITS[@]}"; do
@@ -50,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