Question

Is there any way of fetching the ISBN number from a .mobi book using python?

Maybe there is a way of reading the .mobi files directely with python and search for 10 ints which is the ISBN number? if I open the mobi file with notepad i can find the number, but when i try to read the file I get a encoding error.

Was it helpful?

Solution

Yes.

Basically, you just need to parse the PalmDB file format. The ISBN is stored in the EXTH header field of type 104.

The Python PalmDB module I have linked above was somewhat immature when I wrote my Kindle collections manager, so I ended up implementing the relevant parts myself, see kiehinen source code for details.

If it is OK for you to use my code (It has non-contagious MIT License, should not be a problem, right?) you can just do:

>>> from kiehinen.ebook import Book
>>> b = Book("hobbit.mobi")
>>> b.exth['isbn'][0]
'9780618260300'

If not, please see the code linked above.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top