Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

optimisizing my code

Name: Anonymous 2011-04-19 10:29



#!/bin/sh

#huge piece of shit thread image downloader and watcher
#to use just "dumper urlofthread"
#it will stop when the thread 404's or you break with ^c

loop=loop
looper() {

newimage() {
image=`echo $1 | perl -nle 'm/(\d+\.[jpg][pni][gf])/; print $1'`
if [[ -e $image ]]
then return
else wget -q $1 && echo "$image aquired."
images=found
fi
}

for x in `curl -s $1 | perl -nle 'm/.*(http\:\/\/images\.4chan\.org\/.?.?.?\/src\/[0123456789]*\.jpg).*/;print $1' | uniq`;do newimage ${x};done

if curl -s $1 | perl -nle 'm/.*4chan.?-.?(404).*/; print $1' | uniq | grep 404
then
echo 'The thread died.'
exit
fi

if [[ $images = found ]]

then
echo 'Checking for new images every 15 seconds.'
images=notfound
sleep 15;
else
sleep 15;
fi
}

while true; do looper $1;done


I've trimmed this a fair bit. Is there anything else ?

Name: anonymous@eecs.berkeley.edy 2011-04-19 11:14

You should be banned from the internet. Seriously. Go back to working your hourly job.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List