Added custom subreddit

This commit is contained in:
thevinter 2021-06-03 16:27:28 +02:00
parent bf834a11f0
commit da49b07be1
3 changed files with 9 additions and 9 deletions

View File

@ -10,7 +10,6 @@ reddit(){
sub=${subreddits[$b]} sub=${subreddits[$b]}
sort=$2 sort=$2
top_time=$3 top_time=$3
if [ -z $sort ]; then if [ -z $sort ]; then
sort="hot" sort="hot"
fi fi
@ -18,8 +17,11 @@ reddit(){
if [ -z $top_time ]; then if [ -z $top_time ]; then
top_time="" top_time=""
fi fi
subreddit="$(echo -e "${sub}" | tr -d '[:space:]')" sub="$(echo -e "${sub}" | tr -d '[:space:]')"
url="https://www.reddit.com/r/$subreddit/$sort/.json?raw_json=1&t=$top_time" if [ ! -z $1 ]; then
sub=$1
fi
url="https://www.reddit.com/r/$sub/$sort/.json?raw_json=1&t=$top_time"
content=`wget -T $timeout -U "$useragent" -q -O - $url` content=`wget -T $timeout -U "$useragent" -q -O - $url`
urls=$(echo -n "$content"| jq -r '.data.children[]|select(.data.post_hint|test("image")?) | .data.preview.images[0].source.url') urls=$(echo -n "$content"| jq -r '.data.children[]|select(.data.post_hint|test("image")?) | .data.preview.images[0].source.url')
names=$(echo -n "$content"| jq -r '.data.children[]|select(.data.post_hint|test("image")?) | .data.title') names=$(echo -n "$content"| jq -r '.data.children[]|select(.data.post_hint|test("image")?) | .data.title')
@ -33,14 +35,12 @@ reddit(){
target_url=${arrURLS[$idx]} target_url=${arrURLS[$idx]}
target_name=${arrNAMES[$idx]} target_name=${arrNAMES[$idx]}
target_id=${arrIDS[$idx]} target_id=${arrIDS[$idx]}
echo $target_url
ext=`echo -n "${target_url##*.}"|cut -d '?' -f 1` ext=`echo -n "${target_url##*.}"|cut -d '?' -f 1`
newname=`echo $target_name | sed "s/^\///;s/\// /g"`_"$subreddit"_$target_id.$ext newname=`echo $target_name | sed "s/^\///;s/\// /g"`_"$subreddit"_$target_id.$ext
wget -T $timeout -U "$useragent" --no-check-certificate -q -P down -O "wallpaper.jpg" $target_url &>/dev/null wget -T $timeout -U "$useragent" --no-check-certificate -q -P down -O "wallpaper.jpg" $target_url &>/dev/null
} }
while getopts h:w:s:l:b:r: flag
while getopts h:w:s:l:b flag
do do
case "${flag}" in case "${flag}" in
b) bgtype=${OPTARG};; b) bgtype=${OPTARG};;
@ -48,6 +48,7 @@ do
h) height=${OPTARG};; h) height=${OPTARG};;
w) width=${OPTARG};; w) width=${OPTARG};;
l) link=${OPTARG};; l) link=${OPTARG};;
r) sub=${OPTARG};;
esac esac
done done
@ -72,14 +73,13 @@ if [ ! -z $bgtype ]; then
else else
feh+=(--bg-scale) feh+=(--bg-scale)
fi fi
if [ $link = "reddit" ] if [ $link = "reddit" ] || [ ! -z $sub ]
then then
reddit reddit "$sub"
feh+=(wallpaper.jpg) feh+=(wallpaper.jpg)
"${feh[@]}" "${feh[@]}"
else else
if [ ! -z $height ] || [ ! -z $width ]; then if [ ! -z $height ] || [ ! -z $width ]; then
echo debug
link="${link}${width}x${height}"; link="${link}${width}x${height}";
else else
link="${link}1920x1080"; link="${link}1920x1080";

BIN
wallpaper

Binary file not shown.

Before

Width:  |  Height:  |  Size: 143 KiB

After

Width:  |  Height:  |  Size: 173 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 852 KiB

After

Width:  |  Height:  |  Size: 1.3 MiB