baavgai: (anime)
( Mar. 20th, 2008 09:19 pm)
Thanks to [livejournal.com profile] ladypeyton who pointed out that ElfQuest is now available free, online.

I have fond memories of the comic and rushed right over to see. There they are, ready to be read. Yay! One slow loading jpeg at a time... ack. Worse that than, they're chained into a scaled down web page, hard to read too. I'm a hacker, I can fix this.

I poke about the site, but the web directories don't allow browsing. However, the naming convention is nice and regular. Will it let me cold call the site and download a jpeg?

wget http://www.elfquest.com/gallery/OnlineComics/OQ/OQ01/oq01-1.jpg

Yes, yes it will! I'd intended a simple shell script with a handful of lines, but programming for amusement is why I don't make more blog posts. About an hour later a have a hacked up little thing that happily downloads files automatically and is ready for when they get the rest of the volumes up.

When I run it, I get a bonus surprise. While the site only lists five issues available, I find ten. The rest are waiting for the horrible web paging front end.

I don't believe I've ever felt more geeky. Oh, wait, I'll blog it!

For anyone not impaired by Windows, here's the script I wrote to get the goods. It's ugly and could probably be done in half the size in perl. I believe there are a few smart wget extensions that could have also improved it. However, part of my personal challenge was to use the basic sh environment.


#!/bin/sh

MIN_SIZE=100000
ISSUE_NUM=1

initvars() {
ISSUE_NUM_STR=`printf "%02d" $ISSUE_NUM`
URL_ROOT=http://www.elfquest.com/gallery/OnlineComics/OQ
IMG_PATH=OQ${ISSUE_NUM_STR}
FILE_ROOT=oq${ISSUE_NUM_STR}
N=0
}

initpath() {
if [ ! -e "./$IMG_PATH" ]; then
mkdir "./$IMG_PATH"
fi
cd "./$IMG_PATH"
}

initfn() {
FN=${FILE_ROOT}-${N}.jpg
}

skipem() {
while [ -e "$FN" ]; do
if [ `stat -c%s $FN` -lt $MIN_SIZE ]; then return; fi
N=`expr $N + 1`;
initfn
done
}

getem() {
initfn
if [ -e "$FN" ]; then return; fi
wget "$URL_ROOT/$IMG_PATH/$FN"
if [ ! -e "$FN" ]; then return; fi
if [ `stat -c%s $FN` -lt $MIN_SIZE ]; then return; fi
N=`expr $N + 1`
getem
}

getissues() {
initvars
initpath
initfn
skipem
getem
cd ..
if [ $N -eq 0 ]; then return; fi
ISSUE_NUM=`expr $ISSUE_NUM + 1`
getissues
}

getissues
.

Profile

baavgai: (Default)
baavgai

Links

Most Popular Tags

Page Summary

Powered by Dreamwidth Studios

Style Credit

Expand Cut Tags

No cut tags