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

Joel Grunbaum
2021-08-27 8db5795f3cf446bda85822b4bc2ea527dc1db4b9
Check for no time, meaning cant fetch json
1 files modified
3 ■■■■■ changed files
reddit-wallpaper-fetcher 3 ●●●●● patch | view | raw | blame | history
reddit-wallpaper-fetcher
@@ -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"