Wednesday, October 27, 2010

Linux and borrowing library ebooks

I think for all of us our XP is dying on the old machines.  There are so many exploits out there, that there is no defense.  So, the rich people can jump on the ms upgrade treadmill, but some of us want to use our old hardware, since it is perfectly good for the internet.

The only trouble with desktop Linux is that every stinking utility out there is for xp!  You buy any device and it only communicates to a computer through windows.  Thus, I maintained an xp machine to the very end.

But you can have your Linux and xp too!  Linux has an emulator called Wine.  On my 64 bit Athlon x2, it runs faster than xp ever did!  Nearly every xp utility runs on it, and only games are a pain, since they always accessed the deep processor instructions.

Now, my major problem was to keep borrowing ebooks from the Toronto library.  I want them to increase their collection, so I use it.  The only problem is that publishers want to stick to useless Digital rights management (DRM), and you can only use this on Windows, since they are closed binaries.  So, on first sight, you are screwed!

But fire up Wine, and start installing windows programs.  You need Firefox for a browser, Adobe Reader and Digital Editions (DE) for the books.  Use Winetricks to install the gecko engine for deep IE features that the Adobe needs.  Now, the trick is to stay totally within Wine when you are doing this.  You go to the library with your wine firefox, and you get your book.  This downloads a small text file with the extension .acsm.  These are just instructions for DE.  Firefox shows the file, and it opens automatically with DE.  Now you can read the book, just like you were a slave to ms!

This was the most difficult part, for you can't download the acsm file using Linux, since you get the whole Unix-Dos text file incompatibility thing.  For those that want to download to their reader (for me Sony PRS700), you are again screwed since DE can't handle the DRM crap right to the sony.  You have to do something Linuxy!  I don't want to tell, but it's quite simple, involving installing Python 2.7 on wine, installing the xp binary for Pycrypto, and running 2 magic 'inept' scripts to 'D-DRM' the epub file.  Then just use your standard sony usb disk connection to put it in the 'books' folder.  Nobody's out of pocket since you are just reading the book!  Don't put the clean epub on the internet, since I like it for authors to eat and write new stuff!  and erase the book after the lending period.

The principle of the drm is fascinating in its stupidity.  DE requires you to 'register' with your email and password.  You are only allowed to do this on 6 machines (or OS versions), and if you screwed up a lot, you can't read old books you bought.  From this registration, DE creates a powerful RSA encryption key, which on the surface seems unbreakable.  It communicates with the library, which pays big bucks for a DE server.  But, the program must have the ability to store the key, and de-en-crypt.  This is held sloppily, and the scripts extract it.

When you buy books, the same drm works, and you can lose the key, so you can't access them anymore, even though you paid for it!  So, I would always clean the epub for bought books for archival purpose, and you can put them on any reader, since the epub standard is common and open.


wingnux said...

W.I.N.E. stands for Wine Is Not an Emulator.

Harold Asmis said...

Ha, Ha! I know, but it plays one on TV!

sgtrock said...

Rather than go through all that hassle, why not suggest to your library that they just buy books from publishers that don't use all that crap? One suggestion, Webscription.Net (

Another is to google around for sources of free e-books. Again, one option is Project Gutenberg ( Another is (

Harold Asmis said...

I go through ebooks like toilet paper. I've read all the open stuff, and the formatting is terrible (especially the not-so-kosher stuff). If you want a new published book, you have to deal with DRM. This is the only way to get money to an established author.

This is the story of my life. I went through all the 'cloud' music, until I'm off music, then all the movies, until I can't stand them, and now all the books. :) Soon they will be available non-drm and I won't want them! :)

Anonymous said...

I'm pretty sure Cory Doctorow would disagree pretty strongly with DRM being described as the only way to get authors able to eat.

Harold Asmis said...

Sorry, not familiar with that opinion. The music industry survives by increasing concert tickets by a factor of 10. The movie industry can do this with 3d Imax. But I don't know what authors can do.