From 614818a28c5db26a0bd38466ef3923b47d82bf26 Mon Sep 17 00:00:00 2001 From: n8x0b7T Date: Mon, 3 May 2021 12:27:25 -0400 Subject: [PATCH 1/4] Set a less conspicuous user agent --- redyt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/redyt b/redyt index 98d6433..043035f 100755 --- a/redyt +++ b/redyt @@ -51,10 +51,14 @@ limit=100 # Send a notification $notifier "Redyt" "📩 Downloading your 🖼️ Memes" +# Set user agent +$useragent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36" + # Download the subreddit feed, containing only the # first 100 entries (limit), and store it inside # cachedir/tmp.json -curl -H "User-agent: 'your bot 0.1'" "https://www.reddit.com/r/$subreddit/hot.json?limit=$limit" > "$cachedir/tmp.json" +curl -H "User-agent: '$useragent'" "https://www.reddit.com/r/$subreddit/hot.json?limit=$limit" > "$cachedir/tmp.json" + # Create a list of images imgs=$(jq '.' < "$cachedir/tmp.json" | grep url_overridden_by_dest | grep -Eo "http(s|)://.*(jpg|png)\b" | sort -u) From 46a44856f15e4f5019b5c51354844dac2f8f6783 Mon Sep 17 00:00:00 2001 From: n8x0b7T Date: Wed, 12 May 2021 18:45:33 -0400 Subject: [PATCH 2/4] Randomize user agent --- redyt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redyt b/redyt index 043035f..63d7a8b 100755 --- a/redyt +++ b/redyt @@ -52,7 +52,7 @@ limit=100 $notifier "Redyt" "📩 Downloading your 🖼️ Memes" # Set user agent -$useragent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36" +useragent=$(shuf -e "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4482.0 Safari/537.36 Edg/92.0.874.0" "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1 Safari/605.1.15" -n 1) # Download the subreddit feed, containing only the # first 100 entries (limit), and store it inside From 59533e14c6a24734516b5d135de0dd9263be2be0 Mon Sep 17 00:00:00 2001 From: n8x0b7T Date: Thu, 18 Nov 2021 08:43:33 -0500 Subject: [PATCH 3/4] set image scaling to fit --- redyt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/redyt b/redyt index 9ce85fc..a26990d 100755 --- a/redyt +++ b/redyt @@ -93,7 +93,7 @@ imgs=$(jq '.' < "$cachedir/tmp.json" | grep url_overridden_by_dest | grep -Eo "h # Download images to $cachedir for img in $imgs; do if [ ! -e "$cachedir/${img##*/}" ]; then - wget -P "$cachedir" $img + wget -U "$useragent" -P "$cachedir" $img fi done @@ -103,9 +103,9 @@ rm "$cachedir/tmp.json" # Display the images if [ $FILTER -eq 1 ]; then - sxiv -a -o "$cachedir" + sxiv -a -o -s f "$cachedir" else - sxiv -a "$cachedir" + sxiv -a -s f "$cachedir" fi # Once finished, remove all of the cached images From 424c228f2603fc074142d1583b642f6357d85902 Mon Sep 17 00:00:00 2001 From: n8x0b7T Date: Thu, 18 Nov 2021 09:59:34 -0500 Subject: [PATCH 4/4] fix logic and change to bash --- redyt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/redyt b/redyt index a26990d..aa2bb35 100755 --- a/redyt +++ b/redyt @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Check if necessary programs are installed for prog in dmenu jq sxiv; do @@ -73,7 +73,7 @@ if [ ! -d "$cachedir" ]; then fi # Send a notification -[ $VERBOSE -eq 1 ] && $notifier "Redyt" "📩 Downloading your 🖼️ Memes" +[[ "$VERBOSE" == "1" ]] && $notifier "Redyt" "📩 Downloading your 🖼️ Memes" # Set user agent useragent=$(shuf -e "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4482.0 Safari/537.36 Edg/92.0.874.0" "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1 Safari/605.1.15" -n 1) @@ -98,15 +98,15 @@ for img in $imgs; do done # Send a notification -[ $VERBOSE -eq 1 ] && $notifier "Redyt" "👍 Download Finished, Enjoy! 😊" +[[ "$VERBOSE" == "1" ]] && $notifier "Redyt" "👍 Download Finished, Enjoy! 😊" rm "$cachedir/tmp.json" # Display the images -if [ $FILTER -eq 1 ]; then +if [ "$FILTER" == "1" ]; then sxiv -a -o -s f "$cachedir" else sxiv -a -s f "$cachedir" fi # Once finished, remove all of the cached images -[ ! $KEEP -eq 1 ] && rm "${cachedir:?}"/* +[[ "$KEEP" != "1" ]] && rm "${cachedir:?}"/*