You are not logged in.
Pages: 1
I would love to see some kind of tool, a script that download every xkcd comic and the alt text and put them in a pdf file. It would be great to print and put on the can for everyone to read.
Anybody of you guys that knows of a script that does this? Or are willing to create one?
Offline
I think the download is quiet easy but how to put them into PDF Doesn´t the print tool support PDF?
Offline
Offline
OMG, I've completely forgot about Latex. Anyway, here is my quick and dirty code, it uses community/python-reportlab and extra/python-imaging. Resulting PDF file with the first 3 comics is here
P.S. I haven't found how to specify a font in reportlab apart from using an absolute path, so replace '/tmp/tahoma.ttf' in the source with the path to your favorite font.
Last edited by Atragor (2010-02-14 16:51:05)
Offline
OMG, I've completely forgot about Latex. Anyway, here is my quick and dirty code, it uses community/python-reportlab and extra/python-imaging. Resulting PDF file with the first 3 comics is here
P.S. I haven't found how to specify a font in reportlab apart from using an absolute path, so replace '/tmp/tahoma.ttf' in the source with the path to your favorite font.
Thanks mate! That works perfectly!
I'm downing them all now
I wonder if this is possible with Cyanide and Happiness too...
Last edited by sand_man (2010-02-18 00:35:20)
Offline
I've modified my script to add support for Latex and Cyanide & Happiness.
Notes:
1) now '-s', '-g' and '-d' command-line options can be used to specify a site, a PDF generation method and a cache directory accordingly
2) the cache directory now has two subdirectories (xkcd_cache, cyanide_cache)
3) YouTube movies on Cyanide & Happiness are not supported, also GIF images are skipped in Latex mode because Latex doesn't support GIF
Offline
Really cool script!
Dependencies needed to run the script: python-imaging and python-reportlab
It would be nice if the script put more then one strip per page, maybe two or three and the alt-text below every comic instead of above.
Offline
oh, i forgot, http://www.amazingsuperpowers.com should be added too!
Offline
Thanks Atragor, works perfectly!
Edit:
One small problem is that it doesn't seem to like file names with spaces in it. At least with cyanide.
Adding #359
Downloading http://www.explosm.net/db/files/Comics/jump rope0001.jpg
Traceback etc etc
*
*
*
Sorry I had to type it manually because copy+paste isn't working from my VM for some reason.
Last edited by sand_man (2010-02-23 01:16:41)
Offline
New version is here.
1) Fixed problem with spaces
2) Now as much images as possible are placed on one page when using reportlab
3) Added --scale option to allow zooming of images
4) Added support for amazingsuperpowers.com. Example:
./comics_pdf.py -s asp asp.pdf '11-2009' '01-2010'
This command will download all comics having date from November 2009 to January 2010 inclusive.
Last edited by Atragor (2010-02-24 22:22:10)
Offline
2) Now as much images as possible are placed on one page when using reportlab
Thanks, I was gonna ask about that too.
Last edited by sand_man (2010-02-25 01:07:28)
Offline
Wouldn't it better if the alt-text was below the image, not above it?
The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...
Offline
New version is here.
1) Fixed problem with spaces
2) Now as much images as possible are placed on one page when using reportlab
3) Added --scale option to allow zooming of images
4) Added support for amazingsuperpowers.com. Example:./comics_pdf.py -s asp asp.pdf '11-2009' '01-2010'
This command will download all comics having date from November 2009 to January 2010 inclusive.
Great! You are our god!
But "putting more then one comic on one page" doesnt seem to work with xkcd comics
I just had an idea. maybe it would be easier to instead of pdf, use html. To put the comics in a html-file instead. I think this would solve the "putting more then one comic on one page"-issue and then if one would want a pdf one could just use firefox "print to pdf"-option.
What do you guys think?
Offline
...Or as Picard would say it: "Make it so!"
Offline
But "putting more then one comic on one page" doesnt seem to work with xkcd comics
It works, but since most images are too large, reportlab places only one image per page. Use --scale option to decrease sizes of images.
Wouldn't it better if the alt-text was below the image, not above it?
Done.
Updated the script.
1) Added --margin-{left,right,top,bottom} options to specify margins (in inches) when using reportlab
2) Added an ability to output comics to a HTML-file
3) Added --title-font-size and --alt-font-size options (guess what they do )
4) --scale option renamed into --image-scale
Output to HTML currently doesn't support image scaling to remove the dependence on python-imaging when using this mode.
Last edited by Atragor (2010-03-02 18:34:47)
Offline
Try this:
number=100; for a in $(seq 1 $number); do curl -sL xkcd.com/$a | grep '<img [^>]*/><br/>' | sed -r 's|<img src="(.*)" title="(.*)" alt="(.*)" /><br/>|\1\t\2\t\3|' > /tmp/a; curl -s $(cat /tmp/a | cut -f1) | convert - -gravity south -draw "text 0,0 \"$(cat /tmp/a | cut -f2)\"" pdf:- > /tmp/$a.pdf; done; gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=xkcd.pdf $(seq 1 $number | sed -r 's/(.*)/\/tmp\/\1.pdf/'); rm /tmp/a /tmp/*.pdf
Last edited by matthewbauer (2010-03-04 01:45:19)
Libertarian Arch Linux User
Offline
@Atragor really nice! we ask, you deliver!
@matthewbauer that creates pdf-files for every strip, not very usable.
Offline
yea thats pretty cool what you did there
Offline
Now more feature requests by me!
The progam need a name and to be put into the aur.
a name suggestion: "comichämter" - a mix between english and swedish languages wich means somethinh like "comicget"
And now a impossible feature request:
It would be really really nice to have some kind of program that monitor xkcd.com and download the comic, converts it to pdf and print it, all automatically at every new release.
Offline
Pages: 1