all repos — dotfiles @ 23d363ec964e177b8dbc1f82166d8819ff5d850b

linux dotfiles

bin/scripts/reddit-browse (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
#!/usr/bin/bash

set -o pipefail

[ -z $1 ] && exit 0
after=""

while [ 1 ]
do
    if [ "$2" = "top" ]
    then
        url="reddit.com/r/$1/top.json?t=all&after=$after"
    else
        url="reddit.com/r/$1.json?after=$after"
    fi
    wget --quiet -O - "$url" |\
        tee /tmp/rtmp.json | jq '.data.children[] |.data.url' |\
        grep -E 'jpg|png"$' | xargs feh -F 2>/dev/null

    cat /tmp/rtmp.json | jq -r '.data.children[] |.data.url' |\
        grep -E '(redgifs|gfycat|v.red)' | xargs mpv --loop-file=inf

    after=$(cat /tmp/rtmp.json | jq '.data.after' | tr -d '"')
    printf "continue? [y/n]: "; read ans
    [ $ans = "n" ] && exit 0
done