Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support downloading and removing DRM from Kindle Digital ebooks (not visible on Audible) #813

Closed
shirakaba opened this issue Dec 27, 2023 · 10 comments
Labels
enhancement New feature or request

Comments

@shirakaba
Copy link

shirakaba commented Dec 27, 2023

Is your feature request related to a problem? Please describe.

Although evidently Libation is capable of downloading and de-DRMing Audible books, I am unable to access the ebooks for Kindle that I have purchased on Amazon Japan. This is despite my using the same account on both amazon.co.jp and audible.co.jp. They simply do not appear in my library (while the Audible audiobooks do).

An example is the light novel for "Spice and Wolf" volume 1 on amazon.co.jp, as well as its corresponding audibook on audible.co.jp. Although there is clearly metadata connecting the two across websites, despite me having purchased both, only the audiobook shows up in Libation.

It may be a problem specific to Amazon Japan, because they're an unusual entity.

Describe the solution you'd like
It would be great if Libation could download and de-DRM these ebooks as well. I am not sure whether the API for downloading Kindle ebooks has been reverse-engineered by anyone (and it may well depend upon having a physical Kindle registered, but that requirement is acceptable), but ideally the app would download the ebook and de-DRM it.

The state-of-the-art for deDRM seems to be the DeDRM plugin for Calibre.

Describe alternatives you've considered
Right now, the only option is to use an alternative workflow like downloading the ebook to a physical Kindle device, then connecting it to the computer, and doing the rest with Calibre and DeDRM, which is very fiddly. It would be incredible to have this all housed in a single app, perhaps with a basis on something like docker-kindle or figuring out the API for downloading a file from Amazon via "Manage Your Content and Devices" on the Amazon shopping site.

@shirakaba shirakaba added the enhancement New feature or request label Dec 27, 2023
@rmcrackan
Copy link
Owner

Libation is for audible audiobooks only. I've toyed with the idea of other audiobook services and/or things like kindle but ultimately decided against it.

I'm clearly a big fan of owning the digital things I buy and I think DRM is a scourge. Although it won't be from me, I do very much hope someone else takes up the challenge for these other services and products like kindle.

@mkb79
Copy link

mkb79 commented Dec 27, 2023

@shirakaba
Some years ago I wrote a Python package which can download and decrypt Kindle ebooks. Maybe this works today?!

@rmcrackan
Copy link
Owner

@mkb79 My first reaction: I didn't know he wrote a kindle de-drm. My immediate second reaction: of course he did; he's just awesome like that :)

@mkb79
Copy link

mkb79 commented Dec 27, 2023

As I wrote the app I had a lot of Kindle ebooks. And it was always very tedious to download and decipher them. And the app worked fine for me. But I last used it 1 or 2 years ago. Therefore, I do not know whether the API and encryption are still unchanged.

Edit:
As far as I know you can reuse the Audible credentials to download the Kindle ebooks.

@shirakaba
Copy link
Author

Oh wow! Well if the de-DRM implementation is based on apprenticeharper's implementation as you say, that hasn't changed since April 2021, so should still work as long as Amazon still serves the files in the same old format from the original API endpoints.

I'll have a look over the code!

@mkb79
Copy link

mkb79 commented Dec 27, 2023

@shirakaba
Yes, I've used the code as a base and rewrote it to use the amazon.ion package. It would be great if you can report back. Thanks.

@shirakaba
Copy link
Author

Can't say whether I can pull it off, but assuming I can some day: @rmcrackan would you accept some integration of @mkb79's solution into Libation, or would you prefer to keep the functionality out of Libation to avoid scope creep?

@rmcrackan
Copy link
Owner

tl;dr: sorry, nope

Longer answer: it's not a simple thing. The entirety of Libation has co-evolved with audible. There are hundreds of tiny choices which are all audible-centric. The idioms in right-click menus, settings for what to do with subscriptions and podcasts, workflows for how to deal with aax vs mp3 files, the audio libraries for chapter splitting and ID3 tag management, and even how the database is structured around audible book ID numbers. Kindle books just wouldn't be a good fit for Libation.

@shirakaba
Copy link
Author

Fair enough! Totally understand.

@CLHatch
Copy link
Contributor

CLHatch commented Dec 27, 2023

I personally use some deDRM plugins for Calibre to download my Kindle books. Rather cumbersome (I really dislike Calibre), but this is the plugin package I use: https://github.com/noDRM/DeDRM_tools

It ends up in a rather useless folder structure, because the Calibre dev doesn't believe in using folder structures, and organizes everything in his internal database instead, but at least you can then do a "Save to disk" to export it into a useful format. Only caveat is the Calibre dev is also an idiot that doesn't think he should allow long pathnames in Windows, with the reasoning that "other apps might not use long paths, so it will break for them". Ah, the irony of a dev being part of the problem, and saying "it's because these other devs' apps will cause a problem".

Anyways, this makes "Save to disk" save out as Author1; Author2; etc/Series/## - (YEAR) - Book Title with Subtitle [ASIN]/Book Title [ASIN].epub (skipping the Series/## - part if it's not in a series):

{authors:re( & ,; )}/{series:re(:,꞉)}/{series_index:0>2s|| - }({pubdate:format_date(yyyy)}) - {title:re(:,꞉)} [{identifiers:select(mobi-asin)}]/{title:sublist(0,1,:)} [{identifiers:select(mobi-asin)}]

Edit:
Here's the matching Libation naming pattern that I based this on, placing files in Account/AudioBooks/Author1; Author2; etc/Series/## - (YEAR) - Book Title with Subtitle [ASIN]/Book Title [ASIN].m4b (podcasts in Account/Podcasts with a slightly different format).

<if podcast->Podcasts\Audible\<account nickname>\<author[separator(; )]>\<if series-><series>\<series#[00.##]> - <-if series>(<pub date>) - <series> - <title> [<id>]<-if podcast><!if podcast->AudioBooks\Audible\<account nickname>\<author[separator(; )]>\<if series-><series>\<series#[00.##]> - <-if series>(<year>) - <title> [<id>]<-if podcast>

<audible title> [<id>]

Edit2:
I missed that you already mentioned Calibre. I did find that you can actually use the Windows Kindle app instead of a "real" Kindle device, btw. Although from what I understand, those will then be using KFX format, which isn't ideal for converting to .epub. But it's what I've been doing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants