Mobileread
[Plugin] KindleImport Sigil plugin
#1  DiapDealer 09-27-2014, 06:40 PM
Import Amazon Kindlebooks into Sigil


** NOTE: this plugin periodically checks for updated versions by connecting to github (where the source is maintained). Read the full post for more details **

If you're using Sigil v0.9.0 or later on OSX or Windows, all dependencies should already be met so long as you're using the bundled Python interpreter (default).

Linux users will have to make sure that the Tk or PyQt5 graphical python module is present if it's not already. On Debian-based flavors this can be done with "sudo apt-get install python-tk (or python-pyqt5)" for python 2.7 or "sudo apt-get install python3-tk (or python3-pyqt5)" for Python 3.4. On Arch distributions it can be done with pacman -S tk and/or pacman -S python-pyqt5).

*Note: Do not rename any Sigil plugin zip files before attempting to install them *

This plugin will work with either Python 3.4+ or Python 2.7+ (defaults to 3.x if both are present).
The absolute minimum version of Sigil required is v0.8.3 (Python must be installed separately prior to v0.9.0)


In addition to being able to unpack/open the KF8 sections of files, it also takes a pretty serious stab at opening the older style mobi-only files (thanks to KevinH for contributions/suggestions on that front). Also, if the original source package is a part of the file (think kindlegen output) and the original source is an epub, then the plugin will open that instead of using the unpacked version.

* Please note that there's some atrociously bad markup in many older mobi files (even retail ones), so while the plugin tries its best to whip that markup into some semblance of validity, it's still in your best interest to allow Sigil to correct any issues it may detect upon first opening. *

Configurable preferences (available after first run in the plugin's corresponding json prefs file) are:
As of v0.80.3
added in v0.80.6

For those who don't know where to find the plugin's json preferences file, the easiest way is to open the Sigil Preferences location from within Sigil. This can be achieved by 'Edit->Preferences' (or F5) and looking for the "Open Preferences Location' button in the bottom-left portion of the Sigil Preferences dialog. After clicking that button, you open the 'plugins_prefs' folder, and then the 'KindleImport' folder. There you should find a file named 'KindleImport.json', which is the one you want. If that file is missing, you probably haven't used the plugin yet. It needs to be run once before the file will be created.

KindleImport's code is hosted/maintained on Github.

This plugin's update checker will only try to check for updates after at least 12 hours has elapsed since its last check. The plugin will only notify you about updates once for each new version released.

Changes
Spoiler Warning below







v0.80.3
- Updated to the latest developer version of the underlying KindleUnpack engine to incorporate a few bug fixes/improvements.
- Utilize the autostart/autoclose plugin features (preparing for their availability in Sigil v0.9.3)
- If using the bundled Python Interpreter (or if cssutils is installed), the css in a mobi7 import will be "pretty-printed."
- The addition of three configurable preference variables to fine-tune behavior.
v0.80.4
- faulty version

v0.80.5
- Add an update checker
v0.80.6
- Fixed an issue where NCX files were being truncated whenever incorrect ampersands made their way into a navItem's text element (thanks dhdurgee for helping track it down).
- Added configurable boolean preferences "asin_for_kindlegen_plugin" and "preserve_kindleunpack_meta".
v0.80.7
- Add support for PyQt5 QFileDialog (available in Sigil v0.9.8). Cosmetic only.
v0.80.8
- Make sure an EPUB3-compliant AMAZON identifier is created when preference "asin_for_kindlegen_plugin" is set to "true", and "azw3_epub_version" is set to "3" (when importing azw3s).
v0.80.9
- Update to use latest upstream KindleUnpack commits.
v0.82.1
- Update to use latest upstream KindleUnpack commits
- Add support for dark mode in Sigil 1.1 (PyQt5)
v0.83.0
- update to use latest upstream KindleUnpack core (which fixes a mobiheader issue in some magazines)
- fix so latest version can still run on Sigil versions earlier than 1.3.0
- keep unmanifested cover thumbnail image from being included when converting an old-style mobi to epub
- added icon for Sigil's plugin shortcut toolbar
[zip] KindleImport_v0.83.0.zip (96.3 KB, 349 views)
Reply 

#2  varlog 09-28-2014, 06:58 PM
Feature request :
Epub file not new.epub but BookTitle.epub?
Reply 

#3  DiapDealer 09-28-2014, 07:35 PM
That's out of the Input plugin developer's hands.
Reply 

#4  varlog 09-29-2014, 03:05 PM
This is for testing and only for DD .
[zip] for_testing.zip (368.3 KB, 565 views)
Reply 

#5  varlog 09-29-2014, 03:50 PM
Quote DiapDealer
That's out of the Input plugin developer's hands.
Not really understanding that, I will try to persist .
Reply 

#6  KevinH 09-29-2014, 04:12 PM
Hi varlog,

I do think that it is controllable by the plugin. The problem is that you would not want to use the book title as the file name without cleaning up all of the possibly nasty characters, control chars, forward and backward slashes, any character with special meaning in the shell, spaces at the end, etc that can come from a book title used to create a file name. So using "new.epub" is safer and since the file itself is passed into Sigil via temp directories/scratchfiles, the user will need to rename it and save it someplace anyway ... which makes "new.epub" as good a temporary file name as any.

KevinH

Quote varlog
Not really understanding that, I will try to persist .
Reply 

#7  DiapDealer 09-29-2014, 04:15 PM
Quote varlog
Not really understanding that, I will try to persist .
It's a good thing you decided to persist ... because I clearly didn't know what I was talking about.

Should be doable.
Reply 

#8  varlog 09-29-2014, 04:23 PM
Quote DiapDealer
It's a good thing you decided to persist ... because I clearly didn't know what I was talking about.

Should be doable.
YES!
Reply 

#9  JSWolf 09-29-2014, 04:56 PM
I've come across an error trying to import a Mobi eBook from Amazon. I am using Windows 7 32-bit and Python 32-bit (version 2.7.6) from Python.org with the 32-bit Sigil.

Code
Status: failed
Traceback (most recent call last): File "C:\Program Files\Sigil\plugin_launchers\\python\launcher.py", line 137, in launch self.exitcode = target_script.run(container) File "C:\Users\Jon\AppData\Local\sigil-ebook\sigil\plugins\KindleImport\plugin.py", line 111, in run mobidir, mobi_html, mobi_opf, mobiBaseName = mp.unpackMOBI(temp_dir) File "C:\Users\Jon\AppData\Local\sigil-ebook\sigil\plugins\KindleImport\mobi_stuff.py", line 92, in unpackMOBI mu = _mu.unpackBook(self.infile, outdir, epubver=self.ePubVersion, use_hd=self.useHDImages) File "C:\Users\Jon\AppData\Local\sigil-ebook\sigil\plugins\KindleImport\kindleunpack\kindleunpack.py", line 871, in unpackBook process_all_mobi_headers(files, apnxfile, sect, mhlst, K8Boundary, False, epubver, use_hd) File "C:\Users\Jon\AppData\Local\sigil-ebook\sigil\plugins\KindleImport\kindleunpack\kindleunpack.py", line 794, in process_all_mobi_headers processMobi7(mh, metadata, sect, files, imgnames) File "C:\Users\Jon\AppData\Local\sigil-ebook\sigil\plugins\KindleImport\kindleunpack\kindleunpack.py", line 641, in processMobi7 opf.writeOPF() File "C:\Users\Jon\AppData\Local\sigil-ebook\sigil\plugins\KindleImport\kindleunpack\mobi_opf.py", line 529, in writeOPF data = self.buildMobi7OPF() File "C:\Users\Jon\AppData\Local\sigil-ebook\sigil\plugins\KindleImport\kindleunpack\mobi_opf.py", line 467, in buildMobi7OPF opf_metadata = self.buildOPFMetadata(metadata_tag) File "C:\Users\Jon\AppData\Local\sigil-ebook\sigil\plugins\KindleImport\kindleunpack\mobi_opf.py", line 300, in buildOPFMetadata imageName = self.imgnames[imageNumber]
IndexError: cannot fit 'long' into an index-sized integer
Error: cannot fit 'long' into an index-sized integer
Reply 

#10  varlog 09-29-2014, 05:00 PM
Quote KevinH
Hi varlog,

I do think that it is controllable by the plugin. The problem is that you would not want to use the book title as the file name without cleaning up all of the possibly nasty characters, control chars, forward and backward slashes, any character with special meaning in the shell, spaces at the end, etc that can come from a book title used to create a file name. So using "new.epub" is safer and since the file itself is passed into Sigil via temp directories/scratchfiles, the user will need to rename it and save it someplace anyway ... which makes "new.epub" as good a temporary file name as any.

KevinH
Simpleton as I am: if the book has some KindleUnpack recognizable metadata the title must be there. Converting it to sane string should be possible?
The overkill would be to include the name of the original file .
Reply 

  Next »  Last »  (1/19)
Today's Posts | Search this Thread | Login | Register