apprenticeharper / DeDRM_tools

DeDRM tools for ebooks
14.52k stars 1.51k forks source link

DeDRM did work in Calibre - doesn't now. #955

Closed biker-27 closed 4 years ago

biker-27 commented 4 years ago

Hi, I had DeDRM working in Calibre until I tried to add my most recent Kindle purchase. I get the following error now:

calibre Debug log calibre 4.6 [64bit] embedded-python: True is64bit: True Windows-10-10.0.18362-SP0 Windows ('64bit', 'WindowsPE') ('Windows', '10', '10.0.18362') Python 2.7.16+ Windows: ('10', '10.0.18362', 'SP0', u'Multiprocessor Free') Interface language: en_GB Successfully initialized third party plugins: Gather KFX-ZIP (from KFX Input) (1, 25, 0) && DeDRM (6, 6, 3) && Package KFX (from KFX Input) (1, 25, 0) && Amazon.com Multiple Countries (1, 0, 0) && Kindle hi-res covers (0, 4, 0) && KFX metadata reader (from KFX Input) (1, 25, 0) && KFX Input (1, 25, 0) calibre 4.6 [64bit] embedded-python: True is64bit: True Windows-10-10.0.18362-SP0 Windows ('64bit', 'WindowsPE') ('Windows', '10', '10.0.18362') Python 2.7.16+ Windows: ('10', '10.0.18362', 'SP0', u'Multiprocessor Free') Interface language: en_GB Successfully initialized third party plugins: Gather KFX-ZIP (from KFX Input) (1, 25, 0) && DeDRM (6, 6, 3) && Package KFX (from KFX Input) (1, 25, 0) && Amazon.com Multiple Countries (1, 0, 0) && Kindle hi-res covers (0, 4, 0) && KFX metadata reader (from KFX Input) (1, 25, 0) && KFX Input (1, 25, 0) Turning on automatic hidpi scaling devicePixelRatio: 1.0 logicalDpi: 96.0 x 96.0 physicalDpi: 128.0 x 128.186915888 Using calibre Qt style: True [0.00] Starting up... [0.00] Showing splash screen... [0.30] splash screen shown [0.30] Initializing db... [0.58] db initialized [0.58] Constructing main UI... [2.30] main UI initialized... [2.30] Hiding splash screen [6.80] splash screen hidden [6.80] Started up in 6.80 seconds with 8527 books stdout+stderr from file dialog helper: ['', ''] piped data from file dialog helper: ['\xa3\xb2\xca1\xf1&\xf2Z\xee\xb4\x1fp\x87\x0cR\x0cu\x11>\x18\x13\xa3 \xc2\x02b\xec|\x8d\xa24\xf3', 'D:\Karen\eBooks\My Kindle Content\B07P5BPVGM_EBOK'] Gather KFX-ZIP (from KFX Input) 1.25.0: Importing D:\Karen\eBooks\My Kindle Content\B07P5BPVGM_EBOK\B07P5BPVGM_EBOK.azw Gather KFX-ZIP (from KFX Input): Gathered 4 file(s) as C:\Users\Karen\AppData\Local\Temp\calibre_0sethh\jed_4j.kfx-zip DeDRM v6.6.3: Trying to decrypt jed_4j.kfx-zip Using Library AlfCrypto DLL/DYLIB/SO Decrypting KFX-ZIP ebook: jed_4j Got DSN key from database default_key Found 2 keys to try after 0.1 seconds Decrypting KFX DRM voucher: amzn1.drm-voucher.v1.75211b16-2162-4d50-b528-258861e054ed.voucher DeDRM v6.6.3: Failed to decrypt with error: Failed to decrypt KFX DRM voucher with any key DeDRM v6.6.3: Looking for new default Kindle Key after 0.1 seconds searching for kinfoFiles in C:\Users\Karen\AppData\Local Found K4PC 1.9+ kinf2011 file: C:\Users\Karen\AppData\Local\Amazon\Kindle\storage.kinf2011 Decrypted key file using IDString '315165476' and UserName '4b6172656e' DeDRM v6.6.3: Found 1 new key Decrypting KFX-ZIP ebook: jed_4j Got DSN key from database default_key_1 Found 1 keys to try after 0.1 seconds Decrypting KFX DRM voucher: amzn1.drm-voucher.v1.75211b16-2162-4d50-b528-258861e054ed.voucher DeDRM v6.6.3: Ultimately failed to decrypt after 0.1 seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md Running file type plugin DeDRM failed with traceback: Traceback (most recent call last): File "site-packages\calibre\customize\ui.py", line 172, in _run_filetype_plugins File "calibre_plugins.dedrm.init", line 624, in run File "calibre_plugins.dedrm.init", line 574, in KindleMobiDecrypt DeDRMError: DeDRM v6.6.3: Ultimately failed to decrypt after 0.1 seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md Package KFX (from KFX Input) 1.25.0: Packaging C:\Users\Karen\AppData\Local\Temp\calibre_0sethh\jed_4j.kfx-zip Processing container: B07P5BPVGM_EBOK.azw Running file type plugin Package KFX (from KFX Input) failed with traceback: Traceback (most recent call last): File "site-packages\calibre\customize\ui.py", line 172, in _run_filetype_plugins File "calibre_plugins.kfx_input.package_filetype", line 21, in run File "calibre_plugins.kfx_input.package_filetype", line 33, in run_kfx File "calibre_plugins.kfx_input.kfxlib.yj_book", line 88, in convert_to_single_kfx File "calibre_plugins.kfx_input.kfxlib.yj_book", line 161, in decode_book File "calibre_plugins.kfx_input.kfxlib.yj_book", line 268, in get_container KFXDRMError: Book container B07P5BPVGM_EBOK.azw has DRM and cannot be converted KFX metadata reader (from KFX Input) activated for C:\Users\Karen\AppData\Local\Temp\calibre_0sethh\uaqmuadd_books\0\B07P5BPVGM_EBOK.kfx-zip Added Unspeakable Things to db in: 2.4 Added 1 books in 3.2 seconds Worker Launch took: 0.12700009346 Job: 0 Convert book 1 of 1 (Unspeakable Things) finished Convert book 1 of 1 (Unspeakable Things) Conversion options changed from defaults: output_profile: u'kindle_pw3' cover: u'C:\Users\Karen\AppData\Local\Temp\calibre_0sethh\r5h55b.jpeg' read_metadata_from_opf: u'C:\Users\Karen\AppData\Local\Temp\calibre_0sethh\kzafqn.opf' verbose: 2 Resolved conversion options calibre version: 4.6.0 {'allow_conversion_with_errors': False, 'asciiize': False, 'author_sort': None, 'authors': None, 'base_font_size': 0.0, 'book_producer': None, 'change_justification': u'original', 'chapter': u"//[((name()='h1' or name()='h2') and re:test(., '\s((chapter|book|section|part)\s+)|((prolog|prologue|epilogue)(\s+|$))', 'i')) or @class = 'chapter']", 'chapter_mark': u'pagebreak', 'comments': None, 'cover': u'C:\Users\Karen\AppData\Local\Temp\calibre_0sethh\r5h55b.jpeg', 'debug_pipeline': None, 'dehyphenate': True, 'delete_blank_paragraphs': True, 'disable_font_rescaling': False, 'dont_compress': False, 'duplicate_links_in_toc': False, 'embed_all_fonts': False, 'embed_font_family': None, 'enable_heuristics': False, 'expand_css': False, 'extra_css': None, 'extract_to': None, 'filter_css': u'', 'fix_indents': True, 'font_size_mapping': None, 'format_scene_breaks': True, 'html_unwrap_factor': 0.4, 'input_encoding': None, 'input_profile': <calibre.customize.profiles.InputProfile object at 0x0000020D80B41B08>, 'insert_blank_line': False, 'insert_blank_line_size': 0.5, 'insert_metadata': False, 'isbn': None, 'italicize_common_cases': True, 'keep_ligatures': False, 'language': None, 'level1_toc': None, 'level2_toc': None, 'level3_toc': None, 'line_height': 0.0, 'linearize_tables': False, 'margin_bottom': 5.0, 'margin_left': 5.0, 'margin_right': 5.0, 'margin_top': 5.0, 'markup_chapter_headings': True, 'max_toc_links': 50, 'minimum_line_height': 120.0, 'mobi_file_type': u'old', 'mobi_ignore_margins': False, 'mobi_keep_original_images': False, 'mobi_toc_at_start': False, 'no_chapters_in_toc': False, 'no_inline_navbars': True, 'no_inline_toc': False, 'output_profile': <calibre.customize.profiles.KindlePaperWhite3Output object at 0x0000020D80B55388>, 'page_breaks_before': u'/', 'personal_doc': u'[PDOC]', 'prefer_author_sort': False, 'prefer_metadata_cover': False, 'pretty_print': False, 'pubdate': None, 'publisher': None, 'rating': None, 'read_metadata_from_opf': u'C:\Users\Karen\AppData\Local\Temp\calibre_0sethh\kzafqn.opf', 'remove_fake_margins': True, 'remove_first_image': False, 'remove_paragraph_spacing': False, 'remove_paragraph_spacing_indent_size': 1.5, 'renumber_headings': True, 'replace_scene_breaks': u'', 'search_replace': '[]', 'series': None, 'series_index': None, 'share_not_sync': False, 'smarten_punctuation': False, 'sr1_replace': None, 'sr1_search': None, 'sr2_replace': None, 'sr2_search': None, 'sr3_replace': None, 'sr3_search': None, 'start_reading_at': None, 'subset_embedded_fonts': False, 'tags': None, 'timestamp': None, 'title': None, 'title_sort': None, 'toc_filter': None, 'toc_threshold': 6, 'toc_title': None, 'transform_css_rules': '[]', 'unsmarten_punctuation': False, 'unwrap_lines': True, 'use_auto_toc': False, 'verbose': 2} InputFormatPlugin: KFX Input running on C:\Users\Karen\AppData\Local\Temp\calibre_0sethh\rulo3r.kfx-zip Software versions: KFX Input 1.25.0, calibre 4.6 [64bit], Windows-10-10.0.18362-SP0 KFX Input plugin help is available at https://www.mobileread.com/forums/showthread.php?t=291290 Converting C:\Users\Karen\AppData\Local\Temp\calibre_0sethh\rulo3r.kfx-zip Processing container: B07P5BPVGM_EBOK.azw Traceback (most recent call last): File "calibre_plugins.kfx_input.init", line 100, in convert File "calibre_plugins.kfx_input.init", line 195, in convert_from_kfx File "calibre_plugins.kfx_input.kfxlib.yj_book", line 107, in convert_to_epub File "calibre_plugins.kfx_input.kfxlib.yj_book", line 161, in decode_book File "calibre_plugins.kfx_input.kfxlib.yj_book", line 268, in get_container KFXDRMError: Book container B07P5BPVGM_EBOK.azw has DRM and cannot be converted Python function terminated unexpectedly This book has DRM! (Error Code: 1) Traceback (most recent call last): File "site.py", line 114, in main File "site.py", line 88, in run_entry_point File "site-packages\calibre\utils\ipc\worker.py", line 208, in main File "site-packages\calibre\gui2\convert\gui_conversion.py", line 43, in gui_convert_override File "site-packages\calibre\gui2\convert\gui_conversion.py", line 28, in gui_convert File "site-packages\calibre\ebooks\conversion\plumber.py", line 1110, in run File "site-packages\calibre\customize\conversion.py", line 246, in call File "calibre_plugins.kfx_input.init__", line 103, in convert calibre.ebooks.DRMError: This book has DRM!

So two questions really,

  1. Any ideas how to get it working again? and
  2. What is it that's likely to have changed?

Thanks, in advance.

ElleKayEm commented 4 years ago

Was the book downloaded with the current installation of Kindle for PC on the same machine and user as calibre with DeDRM?

biker-27 commented 4 years ago

Hi. Yes, the old Kindle for PC version with no auto updates selected. From memory it's v1.24.3 (whatever the last version that DRM removal worked on was). The only change that happened was when I opened Calibre it had an update which I installed, 4.6.0. Apart from that everything is as it was.

ElleKayEm commented 4 years ago

Ok, asking because I see the book was from D drive. DeDRM tries the keys it already has, then locates a key on C drive, but doesn't like any of them for this book. Not sure what might have changed if that doesn't give you a clue. Only thing I can think to suggest is reinstalling Kindle for PC. Some instructions for a more thorough removal and reinstall are here (Ignore the part that says use 1.17. You're fine with 1.24):

https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md#i-have-installed-the-calibre-plugin-and-the-book-is-not-already-in-calibre-but-the-drm-does-not-get-removed-it-is-a-kindle-book

biker-27 commented 4 years ago

Hmm, that's fine but I've always used the D: drive for storage of both my Calibre database and ebooks and also for the Kindle books. So I'm loathe to start changing all that and unneccesarily reinstalling when it's been fine for the last year or so until now. If I knew I had to then fair enough I'd obviously do it but I'm not convinced that's the issue here.

ElleKayEm commented 4 years ago

Not saying you should move where the programs store things. I was just explaining why I asked about the book coming from D drive. In case it was downloaded with another installation of Kindle for PC and not with the one on C drive. As long as both calibre and K4PC are on the same machine and user, DeDRM should be able to retrieve the key, regardless of where either program stores its books.

I don't know why this book would not have the same key as the ones you been able to successfully decrypt from this installation before. But the only I way I know to get things working again is a fresh install and redownloading books.

ElleKayEm commented 4 years ago

Seeing someone else in another issue also having problems with a KFX file and a reinstall didn't help. So I thought to suggest disabling KFX downloads -- might have better luck with the older formats. See method 2 in this post:

https://www.mobileread.com/forums/showthread.php?t=283371

j-howell commented 4 years ago

I am having the same problem. It appears that there is an incompatibility between DeDRM for KFX and the 4.6 release of calibre.

ElleKayEm commented 4 years ago

Ah, thanks for letting us know.

biker-27 commented 4 years ago

Great, that sounds like it, I'll try to downgrade the Calibre version to the previous one.

Thanks folks. I appreciate the help.

biker-27 commented 4 years ago

Just to confirm, downgrading to the previous Calibre version, 4.5.0 resolves the issue.

ElleKayEm commented 4 years ago

Thanks for reporting back.

bkennelly commented 4 years ago

Calibre changed the name of the lzma library to calibre_lzma. The DeDRM tools need to be updated to use that name.

alianglai commented 4 years ago

I can't install the plg-in, please help, and thanks in advance.

error message as follows:

calibre, version 5.0.1 ERROR: Unhandled exception: SyntaxError:invalid syntax (calibre_plugins.dedrm.init, line 168)

calibre 5.0.1 [64bit] embedded-python: True is64bit: True Windows-10-10.0.19041-SP0 Windows ('64bit', 'WindowsPE') ('Windows', '10', '10.0.19041') Python 3.8.5 Windows: ('10', '10.0.19041', 'SP0', 'Multiprocessor Free') Interface language: None Successfully initialized third party plugins: KindleUnpack - The Plugin (0, 82, 3) Traceback (most recent call last): File "site-packages\calibre\gui2\preferences\plugins.py", line 317, in add_plugin File "site-packages\calibre\customize\ui.py", line 472, in add_plugin File "site-packages\calibre\customize\ui.py", line 61, in load_plugin File "site-packages\calibre\customize\zipplugin.py", line 202, in load File "importlib__init.py", line 127, in import_module File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 975, in _find_and_load_unlocked File "", line 655, in _load_unlocked File "", line 618, in _load_backward_compatible File "site-packages\calibre\customize\zipplugin.py", line 179, in load_module File "calibre_plugins.dedrm.init__", line 168 print u"{0} v{1}: Copying needed library files from plugin's zip".format(PLUGIN_NAME, PLUGIN_VERSION) ^ SyntaxError: invalid syntax

ElleKayEm commented 4 years ago

Use calibre version 4.23 for now. DeDRM is not compatible with calibre 5 yet.