apprenticeharper / DeDRM_tools

DeDRM tools for ebooks
14.56k stars 1.52k forks source link

Is it possible to use via the CLI #1062

Open maverick1872 opened 4 years ago

maverick1872 commented 4 years ago

Hey all!

Looking to work on a personal project that would leverage these tools but I would need to run them independent of Calibre. Is it possible to do something like this?

Been focusing on using k4mobidedrm.py as my cli tool to strip the DRM. Testing it on an AZW3 file downloaded from ''manage my content and devices" via the "Download and transfer via USB'' method comes back with This book is not encrypted. Attempting to run it on a KFX archive I built from a book stored on my kindle providing the kindle serial number with the -s argument I get a Exception: Failed to decrypt KFX DRM voucher with any key

Am I just using the scripts incorrectly or is there something I'm missing here? Like possibly generating an improper KFX archive?

ElleKayEm commented 4 years ago

You're missing what the KFX Input plugin does. Basically gather up all the files that make up the KFX format into a zip file with the extension kfx-zip. Then after DeDRM handles DRM removal, converts it.

j-howell commented 4 years ago

A KFX-ZIP file should be a zip of all of the KFX container files that make up the book along with the DRM voucher file. They are usually constructed by gather_filetype.py inside of the KFX Input plugin for calibre.

DeDRM will only work with KFX files that come from specific older versions of e-ink Kindle firmware and Kindle for PC/Mac. See Method 4 in the post Dealing with Kindle for PC/Mac 1.19 (and later) and KFX in calibre for more information.

I have no experience with the DeDRM CLI.

maverick1872 commented 4 years ago

A KFX-ZIP file should be a zip of all of the KFX container files that make up the book along with the DRM voucher file. They are usually constructed by gather_filetype.py inside of the KFX Input plugin for calibre.

DeDRM will only work with KFX files that come from specific older versions of e-ink Kindle firmware and Kindle for PC/Mac. See Method 4 in the post Dealing with Kindle for PC/Mac 1.19 (and later) and KFX in calibre for more information.

I have no experience with the DeDRM CLI.

@j-howell I'm assuming there is no way to run the KFX input plugin (at least the portion to build the kfx-zip) standalone from Calibre without making changes to gather-filetype.py correct?

j-howell commented 4 years ago

@j-howell I'm assuming there is no way to run the KFX input plugin (at least the portion to build the kfx-zip) standalone from Calibre without making changes to gather-filetype.py correct?

That is correct. However, If you know Python you can extract the simple algorithm it uses.

maverick1872 commented 4 years ago

Sounds good - I may reach out with questions if you're alright with that if I hit any major hurdles. Since that plugin is your work do you have any qualms with me tinkering with it to get working in a stand-alone sense?

j-howell commented 4 years ago

Sounds good - I may reach out with questions if you're alright with that if I hit any major hurdles. Since that plugin is your work do you have any qualms with me tinkering with it to get working in a stand-alone sense?

That is fine with me. I am happy for someone to make use of my work.

The gathering of files is really pretty simple. The real magic is in the DeDRM part and I can’t help with that.

maverick1872 commented 4 years ago

Yea I've got it all working as a stand-alone script now. Are you aware if the dir structure of the resulting zip make and difference in it's processing during the deDrm logic?

j-howell commented 4 years ago

Are you aware if the dir structure of the resulting zip make and difference in it's processing during the deDrm logic?

I am not sure.

maik-s commented 4 years ago

Yea I've got it all working as a stand-alone script now. Are you aware if the dir structure of the resulting zip make and difference in it's processing during the deDrm logic?

Hey @Maverick1872 would you mind pushing these scripts into a github repository? I think it would be helpful for some

maverick1872 commented 4 years ago

@maik-s I would if I had something I was confident in working well. I haven't been able to connect all the dots on how it functions integrated with Calibre, the KFX-Input plugin, and De-DRM. I had some automation that I was hoping to accomplish using these outside of Calibre but I am unsure if I have things working. I need to get better test files to validate.

maik-s commented 3 years ago

@Maverick1872 any updates on that?

maverick1872 commented 3 years ago

@maik-s Thought I had responded. I haven't done anything with this in a while. Busy with other projects.

maverick1872 commented 3 years ago

Maybe @apprenticeharper can chime in on how to get them working as a standalone from Calibre?

StevenACoffman commented 3 years ago

You might be happy with this: https://github.com/apprenticeharper/DeDRM_tools/blob/master/CALIBRE_CLI_INSTRUCTIONS.md

maverick1872 commented 3 years ago

@StevenACoffman That's for using Calibre as a whole via the CLI. I'm looking to make the DeDRM tools standalone.