View Single Post
Old 12-04-2008, 04:54 AM   #1
acidzebra
Liseuse Lover
acidzebra ought to be getting tired of karma fortunes by now.acidzebra ought to be getting tired of karma fortunes by now.acidzebra ought to be getting tired of karma fortunes by now.acidzebra ought to be getting tired of karma fortunes by now.acidzebra ought to be getting tired of karma fortunes by now.acidzebra ought to be getting tired of karma fortunes by now.acidzebra ought to be getting tired of karma fortunes by now.acidzebra ought to be getting tired of karma fortunes by now.acidzebra ought to be getting tired of karma fortunes by now.acidzebra ought to be getting tired of karma fortunes by now.acidzebra ought to be getting tired of karma fortunes by now.
 
acidzebra's Avatar
 
Posts: 869
Karma: 1035404
Join Date: Jul 2008
Location: Netherlands
Device: PRS-505
webcomic2lrf, a brutal and simplistic commandline script

So I've settled into a comfortable routine with my Sony PRS-505, plugging it into my linux box at night which runs Calibre's feeds2lrf via a scheduled job so that in the morning I have my favorite news sources ready for consumption during my daily commute. I also enjoy a webcomic now and then (especially in the morning when my brain is still booting), so I hacked together a crude script that pulls in the latest of my favorite webcomics, zips them, then runs comic2lrf to create a nice LRF file.

To pull in the comics I use dosage, a program specifically designed for creating offline mirrors of various webcomics using 'recipes' which describe the URL and filename format the comic uses. Dosage is completely written in Python, which is why I chose to use it (there is other similar software out there).

Aside from Dosage, you'll need Calibre installed (duh). I run on linux but theoretically it should be possible to port this to other OSes. The script lives in a folder in my home directory called webcomic2lrf, and yes, the code is awkward and painful to behold but it works for me

Code:
#!/bin/bash
# First archive old comics and clean temp
mv -f ~/webcomic2lrf/Comics/ ~/webcomic2lrf/comicarchive/
rm -Rf ~/webcomic2lrf/tempcomic
mkdir ~/webcomic2lrf/tempcomic
# use the dosage binary 'mainline' to grab the comics
mainline ASofterWorld CatAndGirl CtrlAltDel DieselSweeties JerkCity JoyOfTech LittleGamers MakeWithTheFunny NuklearPower RealLife RedMeat QuestionableContent PvPonline TheOrderOfTheStick UserFriendly VGCats Wulffmorgenthaler xkcd Goats Dilbert SchlockMercenary UberSoft
# go to comic folder
cd ~/webcomic2lrf/Comics
# move everything to one folder as dosage creates subfolders for every comic
find . -name "*.*" -exec cp {} ~/webcomic2lrf/tempcomic \;
# go to tempcomic folder
cd ~/webcomic2lrf/tempcomic
# zip the comics
zip -m comic.zip *
# rename to cbz
mv -f comic.zip comic.cbz
# convert to lrf
comic2lrf -r -l -a "Webcomics" -t "Daily Webcomics" comic.cbz
Note that earlier I used the older "comiclrf" script which for some reason didn't like all these different images formats combined so I found it necessary to add one more step before zipping to convert everything to .jpg:
Code:
for img in *.*; do base=`basename $img`; convert "$img" "$base.jpg"; done
But since I switched to comic2lrf it all worked fine without it

Webcomics come in all shapes and sizes so some will be readable on your reader, some might not be. The 'recipes' that Dosage uses are sometimes out of date, but the format is easy enough to understand and adapt to any webcomic out there. Dosage also has some more advanced archiving and 'catching up' functionality but I haven't yet looked into it.

Anyhow, I hope this is of some use to the webcomic/prs-505/linux fans out there, all five of them
acidzebra is offline   Reply With Quote