Simple shell function to download images from 4chan threads in parallel

This is an old function that I wrote a while back to download content from 4chan threads. It stopped working recently since they changed the link format. Fixed it up because I was bored.

It uses xargs to dispatch downloads to threads and uses only commonly used unix tools. If we replace the \d regex with [0-9] it’ll work with plain grep without relying on PCRE.

1
2
3
4
5
6
function 4get() {
curl -k -s $1 | egrep -o \
"\/\/is\d?\.4chan\.org\/gif\/\d+\.(webm|gif|jpeg|jpg|png)" | \
sed 's/^/https:/; s/is\d?\.4chan\.org/i\.4cdn\.org/' | uniq | \
xargs -n 1 -P 12 curl -# -O
}

The script can also be found on gist.