Downloading ebooks and using them via Linux is a diabolically difficult, stupid and possibly legally dangerous situation. You'd be forgiven for thinking that the reason is merely the reality that desktop Linux users are the one percenters and that the system is biased towards Windows and OSX users, but it's actually more insidious than that – copyright has sabotaged any kind of simplicity here.
This is a joke. Only in the land of intellectual property law (and possibly high end encryption) does one find that the world is actually getting more complicated, rather than simpler.
I've just spent the best part of the last couple of days attempting to try to load my computer with the usual fixes to ensure that my computer can have the DRM cracked off it, which is necessary for using Linux with DRM-protected ebooks. It's a time-consuming and wasteful job, and it's made worse by the fact that I totally fluked it the last couple of times and then didn't write the steps down. Oh sure, there are plenty of web pages out there that have the steps, but no one seems to have the order right.
Thus, there was a great deal of foul language as I faced error after error and glitch after glitch. In the end, it's still a time consuming job, but just getting each of these wretched steps done was an effort in itself. This time, I'm writing the little catches down, at least for me, if no one else.
So please allow me to show you the right way to go about ensuring that you're in a position to get your freshly purchased ebook in a fit state to read if you are using a Linux PC.
Note that for this exercise, I'm using Linux Mint 14 (Nadia) XFCE. Also, I'm assuming that the ebook that you purchased was DRM protected by Adobe's Digital Editions software and is in the .epub format. Most lending libraries use the .epub format for their ebooks, so if you plan on using a library, this will help. Bad luck if you've got a Kindle: none of this will help you.
Note also that this cracks DRM off files. This is necessary for fair use, such as in this instance, but can also potentially be misused. Misuse is very much illegal. Don't misuse this - just imagine what kind of moronic lengths publishers will go to next if they aren't getting paid. Goodness knows, most of their authors aren't getting anything.
Also note that this is just one method, possibly even the long method. I may blog in the future about Calibre plugins which are, in my opinion, way easier. But this is well and truly worth knowing.
Edit (21/01/2012): The method using Calibre plugins may be found here.
1. Install Calibre
Calibre is still the best ebook library manager, and you will need it for this. Make sure you get this installed – if you haven't done so yet, copy and paste this into your terminal:sudo apt-get install calibre
2. Install Wine with a useful front end
Wine is a hateful program which has been solely designed to give me a nervous breakdown. I've hated it ever since I started using Linux. Nevertheless, there are easier ways to use this thing than liaising with the program directly. Like a good front end. So the first thing to do is ensure that you have a decent front end on it. I prefer PlayOnLinux, myself. I'm using version 4.1.1 of that but I think that this is one of the rare times that this could be unimportant. Of course, I say this now...I'm going to assume that you're using PlayOnLinux all the way through this, but you could be using a variety of front ends, like Winetricks or something else. Or not.
If you're not using a front end, ensure that you are using nothing after Wine 1.3, because this will simply not work, otherwise. PlayOnLinux will allow you to select versions, but we'll get to that later.
To install Play On Linux and Winetricks, enter this into your terminal:
sudo apt-get install playonlinux winetricks
If you haven't already got Wine installed, this will install it for you, however for users of Linux Mint 14 (or any recent version of other distros) you will end up with Wine 1.4 by default.
Again, we'll look into version 1.3 of Wine a little later on.
3. Download the Windows version of Adobe Digital Editions 1.7
Folks, I cannot impress enough on you that you need to use specific versions of the applications that I am mentioning in this post. Get this wrong, and you end up like me, stuffing around looking for glitches that aren't there, installing patches that aren't needed and generally getting very ornery.Adobe have moved on to version 2.0, now. It doesn't seem to like Wine much. Goodness knows that Adobe doesn't really care for Linux users terribly much, either. So do a search on Google for where you can download version 1.7, or click on the link below, which is one that I found.
Click here to download Adobe Digital Editions 1.7 for Windows
Right-click on the "Free download" link and save it somewhere where you can get to it when you need it. Your Downloads folder is quite fine. If you use the link above, note that it comes with the usual sponsored links and toolbars which you will have to de-select upon installation.
4. Install Adobe Digital Editions 1.7 in Wine
Again, I'm using PlayOnLinux, and you might like to do something else, but here it is, step by bleeding step.(a) Start up PlayOnLinux.
(b) Click on the big, friendly + button with "Install" written underneath it.
(c) You will see the PlayOnLinux install menu. Move your eyes all the way down to the bottom left corner and click on "Install a non-listed program"
(d) You are now in the manual installation wizard. Click "Next"
(e) Select the "Install the program in a new virtual drive" and click "Next"
(f) Give your new drive a name. Something that you will remember that is easy not to misspell - I used "ADE" for Adobe Digital Editions. Click "Next"
(g) IMPORTANT: Remember how I said to use Wine 1.3, not 1.4 or later? Here's where you ensure that your new virtual drive is running on that. Select "Use another version of Wine" and click "Next"
(h) If you don't have version 1.3 available to you here, select "System" and speed through with the "Next" button. I'll cover off on an additional method for changing versions of Wine later.
(i) Wait for the virtual drive to be created - you shouldn't need to click on "Next" this time. You'll see some Wine dialogues pop up along the way. Browse for your Adobe Digital Editions 1.7 install file to run and then click "Next".
(j) Another Wine pop up will ask you to accept the terms and conditions of the download and install. Click "Next" within the dialogue. The next screen is a sponsored toolbar, and you'll need to wait until it loads fully or you will get delayed. Deselect everything and select "Install".
(k) It will have another bite at the cherry for installing the toolbar. Click "Cancel" only to the small pop up that appears next. If the small pop up doesn't appear, you've accidentally selected something on the previous screen. Never mind.
(l) Click "Next", then click "Install", then "Close". You should then be prompted with the licence agreement for Adobe Digital Editions. Click "I Agree". Adobe Digital Editions should then set itself up. You should be able to navigate your way through this bit, but read each bit carefully.
Edit (21/01/2012): Reader Arc has pointed out that if you deselect "make start menu item", PlayOnLinux has a cow. Don't deselect that. It doesn't reaqlly matter anyway, because Wine doesn't have a Start menu. (Neither does Windows 8, either, for that matter!)
(m) Close Digital Editions and then click "Close". PlayOnLinux will then finish installation. This may take some time, and is one of the annoying things that occupied my time. When it finishes, ensure that you select "digitaleditions.exe" and click "Next". Things get painful if you don't.
(n) Name it something. I strongly suggest "Adobe Digital Editions 1.7". Click "Next"
(o) Select "I don't want to make another shortcut" and click "Next". You're done.
5. Alternate step - Change versions of Wine
Remember in (h) in the previous step, I mentioned that if you didn't have the opportunity to switch your ADE virtual drive to Wine 1.3, we'd discuss what you could do later? Well, here we are.(a) In your main PlayOnLinux screen, click on the cog button Configure.
(b) Over on the left, ensure that your ADE drive (or whatever you named your virtual drive) is selected, and then click on the + button nest to Wine version (in the General tab):
(c) Another screen will pop up. Select an option (1.3.37 is recommended) from the Available Wine versions, and click on the > button. An installer will take you through the steps. And then you'll be done.
Click on the x-boxes at the top of each screen when you're done until you are back at the PlayOnLinux configuration screen. Select your newly installed version of Wine (1.3.37) and then close out of that screen.
It's now time to install Python.
6. Download the Python stuff
More correctly, you need Python 2.6 (for Windows), PyCrypto 2.1 (for Windows) and two Python scripts that are in the following set:Click here to download these.
Right click and save into your Downloads folder, and then open it up and extract the contents into a nice, new, clearly labelled folder that you are going to remember. We'll come to these in the next few steps.
7. Install Python 2.6 in Wine
Follow the same steps as in step 4 to install Python in Wine from PlayOnLinux, but do the following:- Ensure that "Install a program in a new virtual drive" is selected;
- Type "ADE" (or the name of your virtual drive) exactly with NO TYPOS;
- IMPORTANT: Select 1.3.37 as your version of Wine to run;
- Select the python-2.6.2.msi file from wherever it was that you unzipped the files from Step 6 into;
- Select the defaults for everything through the Wine screens;
- Select "python.exe" to make a shortcut and name it "Python 2.6"; and
- Finish by not making another shortcut.
8. Run PyCrypto in your new virtual Wine drive
Click on Configure in your PlayOnLinux main screen. Ensure that your ADE drive is selected and then go into the Miscellaneous tab. Select "Run a .exe file in this virtual drive":Select the pycrypto-2.1.0.win32-py2.6.exe file from wherever it was that you unzipped the files from Step 6 into, click "Next" to everything, and you're done!
9. Set file associations
This has to be done eventually, so you may as well do it now.From the PlayOnLinux main screen, go up to Settings and select "File Associations" from the drop down menu:
You'll be met by a new screen, the Settings screen and you should be in the File Associations tab. Select "New" down on the bottom left and enter ".pyw" as the file extension before clicking "OK".
You will see .pyw appear in a list. Select .pyw and then, from the drop down menu that appears at the bottom, select Python. And then hit "Apply". You're done.
You'll need to restart PlayOnLinux. so do that and then exit again. It's time for the fun part.
10. Buy a DRM-protected ebook
I used Angus & Robertson online for this, but presuming that your online bookstore sells in the .epub format, you will need something from their stock to test this out on.Note, I haven't included Barnes & Noble who use a different type of DRM encryption - I may cover theirs in a future post.
After you've selected your ebook and "purchased" it, you should be presented with an .acsm link. Right-click and select "Save as" - I find the .acsm file just that easier to work with once downloaded.
11. Download file to Adobe Digital Editions
Easy step this - open Digital Editions from PlayOnLinux and drag and drop your .acsm file into it. Digital editions will do the rest, as well as saving a copy of the "decrypted" file in a folder in your home folder, called My Digital Editions.Simple? It's now time to run the Python scripts.
12. Run the Python scripts
The set that you downloaded in Step 6 included two Python scripts that now should be run in Wine. Open a terminal and navigate your way into the folder that contains your Python scripts.Start with the ineptkey script. Copy and paste this into your terminal:
playonlinux ineptkey.pyw
You'll see a few things happen, and even a couple of errors. Hopefully, though, none of these should be fatal. If all goes well, you should be met by this message:
Woo hoo!
But where's the key? Go into your virtual ADE drive, in the drive_c/Python26 folder and you should be able to find a file named "adeptkey.der". Copy and past this into both the folder where you kept Python, PyCrypto and the Python scripts, and also into your .config/calibre
Edit (21/01/2012): Reader Arc has pointed out that the adeptkey.der file needs to go into ~/.config/calibre, not the /plugins folder that is within that. I did both and didn't notice.
Now, the ineptepub script. It may be spelled "aineptepub.pyw" or "ineptepub.pyw" but either way, it's the script that will administer the coup de grace to your DRM-protected file.
Before you do that, go into your My Digital Editions folder, locate the .epub file that you just "decrypted" with digital editions and copy it. Go back to your Books folder and create two new folders in that. I call one "Dirty" and one "Clean". Paste the .epub file that you copied into the Dirty folder.
You now should start a new terminal session, again, ensuring that you've navigated to the folder containing the Python scripts, and enter this:
playonlinux aineptepub.pyw
You should be met with a window with three fields. Your adeptkey.der file should already be in the first field, as it's in the same folder as you are.
Browse to your Dirty folder for the second field (Input path), and to the Clean folder for the third field (Output path) and click on Decrypt whole directory. You can do this with a whole bunch of ebooks that Digital Editions has left for you.
Voila! Mission accomplished, and only one more thing left to do.
13. Add file to your Calibre library
You can do this a number of ways. You can add a file using the buttons in Calibre. You can drag or drop the file, or you can do it from the command line as follows.Open a terminal, navigate to your Clean folder and type:
calibredb add filename.epub
You are now free to move the file on to your e-reader in Calibre.
Happy? Good, I'm exhausted. Happy reading.











5 comments:
Hey, thanks a bunch for your detailed instructions! I now have my first-ever ebook unencumbered by naughty DRM, which is good because i need to have it read in a fortnight.
I probably would have given up in frustration without your help.
One small thing, though, playonlinux had it's cylon-eye worm thing going on for literally hours while it was performing the installation. I had to cancel it.
This was because I unchecked 'install start menu shortcut' on ADE's installation menu.
Thought it would be worth making that clear.
it looks like the directory to copy adeptkey.der to is actually ~/.config/calibre
Thanks for that, Arc. I normally just clicked straight through that screen, knowing full well that it was selecting something that wasn't ever going to appear.
I'll try to silp an edit in shortly.
Also, that's interesting about the folder to paste adaptkey.der into I must have pasted mine in there by accident, because I can see it's there, too. I'll edit to make this clear, too.
Thanks a bundle for your help, Arc.
Thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, from the bottom of my newbie heart.
Glad you liked it!
Post a Comment