Package Details: kindleunpack 0.83-4

Git Clone URL: https://aur.archlinux.org/kindleunpack.git (read-only, click to copy)
Package Base: kindleunpack
Description: Extract text, images, and metadata from Kindle/Mobi files
Upstream URL: https://github.com/kevinhendricks/KindleUnpack
Licenses: GPL-3.0-only
Submitter: perlawk
Maintainer: alerque (eschwartz)
Last Packager: alerque
Votes: 11
Popularity: 0.000447
First Submitted: 2014-12-18 10:16 (UTC)
Last Updated: 2024-12-23 12:41 (UTC)

Latest Comments

frecco2 commented on 2025-01-13 10:21 (UTC)

@dbb Thank you!

dbb commented on 2025-01-06 23:13 (UTC) (edited on 2025-01-06 23:14 (UTC) by dbb)

Unfortunately this no longer works as of Python 3.13 since it depends on the imghdr module which was deprecated in Python 3.11 and removed in Python 3.13. Trying to execute either will cause a ModuleNotFoundError: No module named 'imghdr' exception to be thrown.

Looking at the upstream issue from a couple of years ago seems to indicate that puremagic can be used as a replacement. It's already packaged in extra, but it does not appear to be a pure drop-in replacement as it does not provide a imghdr module, instead the source has to be modified. I patched the source and built the package (adding python-puremagic as a dependency) and it seems to work again, at least for my use.

Here is the patch if you want to apply to locally. Don't know if/when upstream will release an update.

diff -ru a/DumpMobiHeader_v023.py b/DumpMobiHeader_v023.py
--- a/DumpMobiHeader_v023.py    2025-01-06 17:50:16.512665253 -0500
+++ b/DumpMobiHeader_v023.py    2025-01-06 17:52:12.436955214 -0500
@@ -24,7 +24,7 @@
 # one to one mapping of values from 0 - 255

 import os, getopt, struct
-import imghdr
+import puremagic
 import binascii

 def hexlify(bdata):
@@ -730,7 +730,7 @@
             dt = data[0:4]
             dtext = data[0:12]
             desc = ''
-            imgtype = imghdr.what(None, data)
+            imgtype = puremagic.what(None, data)
             if i in headers:
                 hp = headers[i]
                 off =  i
diff -ru a/lib/mobi_cover.py b/lib/mobi_cover.py
--- a/lib/mobi_cover.py 2025-01-06 17:50:16.525998693 -0500
+++ b/lib/mobi_cover.py 2025-01-06 17:52:12.446955298 -0500
@@ -8,7 +8,7 @@

 from .unipath import pathof
 import os
-import imghdr
+import puremagic

 import struct
 # note:  struct pack, unpack, unpack_from all require bytestring format
@@ -34,9 +34,9 @@


 def get_image_type(imgname, imgdata=None):
-    imgtype = unicode_str(imghdr.what(pathof(imgname), imgdata))
+    imgtype = unicode_str(puremagic.what(pathof(imgname), imgdata))

-    # imghdr only checks for JFIF or Exif JPEG files. Apparently, there are some
+    # puremagic only checks for JFIF or Exif JPEG files. Apparently, there are some
     # with only the magic JPEG bytes out there...
     # ImageMagick handles those, so, do it too.
     if imgtype is None:

eschwartz commented on 2016-05-02 06:02 (UTC)

tk, not python-pmw Thanks -- I must have installed tk for something else originally and didn't notice it was needed for this.

Unsttopabull commented on 2016-04-27 11:52 (UTC)

Please add a dependency to "python-pmw" for Tk toolkit or the GUI will not run.