noDRM / DeDRM_tools

DeDRM tools for ebooks
6.59k stars 287 forks source link

Unable to remove KFX DRM with Calibre 6.29 + Kindle Paperwhite + DeDRM #429

Closed evsv closed 8 months ago

evsv commented 8 months ago

Question / bug report

Hi! I'm trying to use the DeDRM plugin to remove the DRMs on my Kindle KFX files. I've unfortunately been unable to do so. I used both the stable version (10.0.3) and the RC1 (10.0.9) on Calibre 6.29, and nothing seems to be working. Looking into the log file, the specific line of error reads "Failed to decrypt with error: The .kfx-zip archive contains an encrypted DRMION file without a DRM voucher:. The same error occurs both in version 10.0.3 and 10.0.9.

Other specs: I'm running calibre on Fedora 38, installed using the installation script provided on their website.

Thanks in advance, and thanks for all your hard work!

Which version of Calibre are you running?

6.29

Which version of the DeDRM plugin are you running?

10.0.9

If applicable, which version of the Kindle software are you running?

Kindle FW: 5.16.2.1.1

Log output

Using calibre Qt style: True
calibre Debug log
calibre 6.29  embedded-python: True
Linux-6.5.9-200.fc38.x86_64-x86_64-with-glibc2.37 Linux ('64bit', 'ELF')
('Linux', '6.5.9-200.fc38.x86_64', '#1 SMP PREEMPT_DYNAMIC Wed Oct 25 20:40:49 UTC 2023')
Python 3.10.1
Interface language: None
Successfully initialized third party plugins: Gather KFX-ZIP (from KFX Input) (2, 5, 0) && DeDRM (10, 0, 9) && Package KFX (from KFX Input) (2, 5, 0) && KFX metadata reader (from KFX Input) (2, 5, 0) && KFX Input (2, 5, 0) && KePub Input (3, 6, 6) && KePub Metadata Reader (3, 4, 3) && KePub Metadata Writer (3, 4, 3) && KePub Output (3, 6, 6) && Kobo Books (1, 9, 2) && Kobo Metadata (1, 2, 0) && Kobo Utilities (2, 16, 10) && KoboTouchExtended (3, 6, 6)
calibre 6.29  embedded-python: True
Linux-6.5.9-200.fc38.x86_64-x86_64-with-glibc2.37 Linux ('64bit', 'ELF')
('Linux', '6.5.9-200.fc38.x86_64', '#1 SMP PREEMPT_DYNAMIC Wed Oct 25 20:40:49 UTC 2023')
Python 3.10.1
Interface language: None
Successfully initialized third party plugins: Gather KFX-ZIP (from KFX Input) (2, 5, 0) && DeDRM (10, 0, 9) && Package KFX (from KFX Input) (2, 5, 0) && KFX metadata reader (from KFX Input) (2, 5, 0) && KFX Input (2, 5, 0) && KePub Input (3, 6, 6) && KePub Metadata Reader (3, 4, 3) && KePub Metadata Writer (3, 4, 3) && KePub Output (3, 6, 6) && Kobo Books (1, 9, 2) && Kobo Metadata (1, 2, 0) && Kobo Utilities (2, 16, 10) && KoboTouchExtended (3, 6, 6)
QPA platform: wayland
devicePixelRatio: 2.0
logicalDpi: 96.0 x 96.0
physicalDpi: 204.65142857142857 x 201.06105263157892
[0.00] Starting up...
[0.00] Showing splash screen...
[0.14] splash screen shown
[0.14] Initializing db...
[0.15] db initialized
[0.15] Constructing main UI...
DEBUG:    0.0 Kobo Utilities Configuration - CreateNewCustomColumn is supported
DEBUG:    0.0 KoboUtilites::action.py - loading translations
DEBUG:    0.0 KoboUtilites::dialogs.py - loading translations
DEBUG:    0.0 KoboUtilites::action.py - loading translations
DEBUG:    0.7 No Kobo Touch, Glo or Mini appears to be connected
DEBUG:    0.7 rebuild_menus - self.supports_ratings=None, self.supports_tiles=None
DEBUG:    0.7 KoboUtilities:set_toolbar_button_tooltip - start: text='None'
DEBUG:    0.7 KoboUtilities:set_toolbar_button_tooltip - setting to text='Utilities to use with Kobo ereaders

Driver: KoboTouchExtended'
[1.13] main UI initialized...
[1.13] Hiding splash screen
Starting QuickView
[3.12] splash screen hidden
[3.12] Started up in 3.12 seconds with 0 books
['zenity', '--modal', '--file-selection', '--title=Select books', '--separator=\n', '--attach=2', '--filename=/home/vishwanathevs/Documents/ebook_management/kindle_library/.fgdfg.gdfhjdhf*&^839', '--file-filter=Books | *.lrf *.rtf *.lit *.txt *.txtz *.text *.htm *.xhtm *.html *.htmlz *.xhtml *.pdf *.pdb *.updb *.pdr *.prc *.mobi *.azw *.doc *.epub *.fb2 *.fbz *.djv *.djvu *.lrx *.cbr *.cb7 *.cbz *.cbc *.oebzip *.rb *.imp *.odt *.chm *.tpz *.azw1 *.pml *.pmlz *.mbp *.tan *.snb *.xps *.oxps *.azw4 *.book *.zbf *.pobi *.docx *.docm *.md *.textile *.markdown *.ibook *.ibooks *.iba *.azw3 *.ps *.kepub *.kfx *.kpf *.azw8 *.kfx-zip', '--file-filter=EPUB books | *.epub *.kepub', '--file-filter=Kindle books | *.mobi *.prc *.azw *.azw3 *.kfx *.tpz *.azw1 *.azw4', '--file-filter=PDF books | *.pdf *.azw4', '--file-filter=HTML books | *.htm *.html *.xhtm *.xhtml', '--file-filter=LIT books | *.lit', '--file-filter=Text books | *.txt *.text *.rtf *.md *.markdown *.textile *.txtz', '--file-filter=Comics | *.cbz *.cbr *.cbc *.cb7', '--file-filter=Archives | *.zip *.rar *.7z', '--file-filter=Wordprocessor files | *.odt *.doc *.docx', '--file-filter=All files | *', '--multiple']
Gather KFX-ZIP (from KFX Input) 2.5.0: Importing /home/vishwanathevs/Documents/ebook_management/kindle_library/Witches Abroad_ A Novel of Discworld_B001AW2OYC.kfx
Gather KFX-ZIP (from KFX Input): Cannot locate some files needed for the book. KFX files must remain in their original folder structure for successful import. 
Gather KFX-ZIP (from KFX Input): Gathered 1 file(s) as /tmp/calibre_6.29.0_tmp__9xmidgo/9900jfc2.kfx-zip
DeDRM v10.0.9: Trying to decrypt 9900jfc2.kfx-zip
Decrypting KFX-ZIP ebook: 9900jfc2
Found 1 keys to try after 1.0 seconds
DeDRM v10.0.9: Failed to decrypt with error: The .kfx-zip archive contains an encrypted DRMION file without a DRM voucher
DeDRM v10.0.9: Looking for new default Kindle Key after 1.0 seconds
DeDRM v10.0.9: Exception when getting default Kindle Key after 1.0 seconds
Traceback (most recent call last):
  File "calibre_plugins.dedrm.__init__", line 931, in KindleMobiDecrypt
    book = k4mobidedrm.GetDecryptedBook(path_to_ebook,kindleDatabases,androidFiles,serials,pids,self.starttime)
  File "/home/vishwanathevs/.config/calibre/plugins/DeDRM.zip/k4mobidedrm.py", line 203, in GetDecryptedBook
    mb.processBook(totalpids)
  File "/home/vishwanathevs/.config/calibre/plugins/DeDRM.zip/kfxdedrm.py", line 67, in processBook
    self.decrypt_voucher(totalpids)
  File "/home/vishwanathevs/.config/calibre/plugins/DeDRM.zip/kfxdedrm.py", line 88, in decrypt_voucher
    raise Exception("The .kfx-zip archive contains an encrypted DRMION file without a DRM voucher")
Exception: The .kfx-zip archive contains an encrypted DRMION file without a DRM voucher

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "calibre_plugins.dedrm.__init__", line 949, in KindleMobiDecrypt
    defaultkeys, defaultnames = WineGetKeys(scriptpath, ".k4i",dedrmprefs['kindlewineprefix'])
  File "/home/vishwanathevs/.config/calibre/plugins/DeDRM.zip/wineutils.py", line 96, in WineGetKeys
    pyexec = WinePythonCLI(wineprefix)
  File "/home/vishwanathevs/.config/calibre/plugins/DeDRM.zip/wineutils.py", line 59, in __init__
    self.check_call(["-c", self.py3_test])
  File "/home/vishwanathevs/.config/calibre/plugins/DeDRM.zip/wineutils.py", line 84, in check_call
    subprocess.check_call(self.python_exec + cli_args, env=env_dict,
  File "subprocess.py", line 364, in check_call
  File "subprocess.py", line 345, in call
  File "subprocess.py", line 966, in __init__
  File "subprocess.py", line 1842, in _execute_child
FileNotFoundError: [Errno 2] No such file or directory: 'wine'
DeDRM v10.0.9: Ultimately failed to decrypt after 1.0 seconds. Read the FAQs at noDRM's repository: https://github.com/noDRM/DeDRM_tools/blob/master/FAQs.md
Running file type plugin DeDRM failed with traceback:
Traceback (most recent call last):
  File "calibre_plugins.dedrm.__init__", line 931, in KindleMobiDecrypt
    book = k4mobidedrm.GetDecryptedBook(path_to_ebook,kindleDatabases,androidFiles,serials,pids,self.starttime)
  File "/home/vishwanathevs/.config/calibre/plugins/DeDRM.zip/k4mobidedrm.py", line 203, in GetDecryptedBook
    mb.processBook(totalpids)
  File "/home/vishwanathevs/.config/calibre/plugins/DeDRM.zip/kfxdedrm.py", line 67, in processBook
    self.decrypt_voucher(totalpids)
  File "/home/vishwanathevs/.config/calibre/plugins/DeDRM.zip/kfxdedrm.py", line 88, in decrypt_voucher
    raise Exception("The .kfx-zip archive contains an encrypted DRMION file without a DRM voucher")
Exception: The .kfx-zip archive contains an encrypted DRMION file without a DRM voucher

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "calibre/customize/ui.py", line 187, in _run_filetype_plugins
  File "calibre_plugins.dedrm.__init__", line 1030, in run
    decrypted_ebook = self.KindleMobiDecrypt(path_to_ebook)
  File "calibre_plugins.dedrm.__init__", line 981, in KindleMobiDecrypt
    raise DeDRMError("{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at noDRM's repository: https://github.com/noDRM/DeDRM_tools/blob/master/FAQs.md".format(PLUGIN_NAME, PLUGIN_VERSION,time.time()-self.starttime))
calibre_plugins.dedrm.DeDRMError: DeDRM v10.0.9: Ultimately failed to decrypt after 1.0 seconds. Read the FAQs at noDRM's repository: https://github.com/noDRM/DeDRM_tools/blob/master/FAQs.md
Package KFX (from KFX Input) 2.5.0: Packaging /tmp/calibre_6.29.0_tmp__9xmidgo/9900jfc2.kfx-zip
Processing container: Witches Abroad_ A Novel of Discworld_B001AW2OYC.kfx
Running file type plugin Package KFX (from KFX Input) failed with traceback:
Traceback (most recent call last):
  File "calibre/customize/ui.py", line 187, in _run_filetype_plugins
  File "calibre_plugins.kfx_input.package_filetype", line 21, in run
    return self.run_kfx(path_to_ebook)
  File "calibre_plugins.kfx_input.package_filetype", line 32, in run_kfx
    kfx_data = YJ_Book(path_to_ebook).convert_to_single_kfx()
  File "calibre_plugins.kfx_input.kfxlib.yj_book", line 79, in convert_to_single_kfx
    self.decode_book()
  File "calibre_plugins.kfx_input.kfxlib.yj_book", line 210, in decode_book
    container = self.get_container(datafile)
  File "calibre_plugins.kfx_input.kfxlib.yj_book", line 317, in get_container
    raise KFXDRMError("Book container %s has DRM and cannot be converted" % datafile.name)
calibre_plugins.kfx_input.kfxlib.utilities.KFXDRMError: Book container Witches Abroad_ A Novel of Discworld_B001AW2OYC.kfx has DRM and cannot be converted
KFX metadata reader (from KFX Input) activated for /tmp/calibre_6.29.0_tmp__9xmidgo/9uj4r6wy_add_books/0/Witches Abroad_ A Novel of Discworld_B001AW2OYC.kfx-zip
Traceback (most recent call last):
  File "calibre/customize/ui.py", line 469, in get_file_type_metadata
  File "calibre_plugins.kfx_input.metadata_reader", line 28, in get_metadata
    md = YJ_Book(stream).get_metadata()
  File "calibre_plugins.kfx_input.kfxlib.yj_book", line 148, in get_metadata
    raise Exception("Failed to locate a KFX container with metadata")
Exception: Failed to locate a KFX container with metadata
Added Witches Abroad A Novel of Discworld B001AW2OYC to db in: 0.1
Added 1 books in 2.3 seconds
ElleKayEm commented 8 months ago

As the log says:

Cannot locate some files needed for the book. KFX files must remain in their original folder structure for successful import.

evsv commented 8 months ago

@ElleKayEm , thank you so much! I was initially using calibre to transfer the files to disk, and that copied only the kfx over. It works perfectly now that I copy the kfx from it's original folder structure. Thanks again!!