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

Joel Grunbaum
2021-08-27 a03b71fd0ca338372854e8978235e681bf0d8da7
reddit-wallpaper-fetcher
@@ -4,7 +4,7 @@
#Default variables
SUBREDDITS=("Wallpapers")
SORT=new
SORT="new"
USER=$(whoami)
SIZE=1920x1080
WRITE_TITLE=1
@@ -41,6 +41,9 @@
for i in "${SUBREDDITS[@]}"; do
    temp=$(curl "$LOUD" --user-agent "$USER" "https://www.reddit.com/r/$i.json?sort=$SORT&limit=1")
    time=$(echo "$temp" | jq -r ".data.children[-1].data.created_utc")
    if [ "$time" == "null" ]; then
       continue
    fi
    if [ $(awk -v n1="$time" -v n2="$LATEST_TIME" 'BEGIN {printf (n1>n2?"1":"")}') ]; then
   LATEST="$temp"
   LATEST_TIME="$time"
@@ -65,6 +68,7 @@
echo "$LATEST" > "$WALLDIR"/json
title=$(echo "$LATEST" | jq -r ".data.children[-1].data.title")
echo "$title" > "$WALLDIR"/data.txt
echo $LATEST | jq -r ".data.children[-1].data.subreddit" >> "$WALLDIR"/data.txt
echo "$url" >> "$WALLDIR"/data.txt
echo https://reddit.com$(echo "$LATEST" | jq -r ".data.children[-1].data.permalink" | sed 's/"//g') >> "$WALLDIR"/data.txt