02-10-2010, 07:44 PM | #1 |
Member
Posts: 10
Karma: 10
Join Date: Nov 2007
Device: EZReader Pro
|
Error importing mobi files [solved]
I am receiving the following error when I attempt to add mobi files to Calibre. This is just one example, it happens on every one.
WARNING: Failed to read metadata: Failed to read metadata from the following: Any ideas where I should look first? The file is added to Calibre, but I have to add all of the metadata manually. The_Buried_Pyramid.mobi Traceback (most recent call last): File "site-packages\calibre\ebooks\metadata\worker.py", line 54, in read_metadata_ File "shutil.py", line 52, in copyfile IOError: [Errno 13] Permission denied: 'C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\calibre - E-book Management' (Windows 7, Calibre 0.6.39) Last edited by Nomadin; 02-10-2010 at 08:33 PM. |
02-10-2010, 08:17 PM | #2 |
creator of calibre
Posts: 44,356
Karma: 23661992
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Do you have a plugin for removing drm from mobi files?
|
Advert | |
|
02-10-2010, 08:24 PM | #3 |
Enthusiast
Posts: 43
Karma: 376
Join Date: Jan 2009
Location: California, USA
Device: K3, KFire, iPad, iPhone
|
I was also receiving this error while adding prc/mobi files and using the mobidedrm plugin, but after updating the plugin to the latest version of mobidedrm, 0.10, the error no longer occurs and calibre is again able to read the metadata successfully.
|
02-10-2010, 08:25 PM | #4 |
Member
Posts: 10
Karma: 10
Join Date: Nov 2007
Device: EZReader Pro
|
Yes, I de-protected my Kindle books for future protection. I guess that script is interfering?
|
02-10-2010, 08:32 PM | #5 | |
Member
Posts: 10
Karma: 10
Join Date: Nov 2007
Device: EZReader Pro
|
Quote:
Thank you both for the incredibly quick reply! |
|
Advert | |
|
02-16-2010, 05:11 AM | #6 | |
The Grand Mouse 高貴的老鼠
Posts: 72,195
Karma: 308792702
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
|
Quote:
I attach a dummy import plug-in. It does nothing except make a temporary copy of the file and returns that to Calibre. (In a very similar manner to MobiDeDRM, but without doing any manipulation of the file.) Perhaps people who've had problems with the MobiDeDRM plug-in could try this plug-in (removing any other mobi/prc/azw plugin first) and see if they still have a problem with import. If they do, perhaps Kovid could take a look and suggest what the problem is with this (completely innocuous) code. |
|
02-16-2010, 05:23 AM | #7 |
eBook Enthusiast
Posts: 85,544
Karma: 93383043
Join Date: Nov 2006
Location: UK
Device: Kindle Oasis 2, iPad Pro 10.5", iPhone 6
|
It looks as if it's attempting to create a file in a directory in which it doesn't have write access.
|
02-16-2010, 05:40 AM | #8 | |
The Grand Mouse 高貴的老鼠
Posts: 72,195
Karma: 308792702
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
|
Quote:
http://calibre-ebook.com/user_manual...filetypeplugin Now, it might be that the code isn't implementing a FileTypePlugin correctly. Or perhaps there's a problem with Calibre. that's why I created this dummy plug-in. Now I need (1) someone who's had a problem with Mobipocket import plug-ins to try this dummy plug-in and see if there's still a problem (2) If there is still a problem, for someone who knows more about Calibre plug-ins that me to take a look at the plug-in and see if there's something wrong with it (3) If there isn't, for someone to try to work out what's wrong with the Calibre/Plug-in interaction. |
|
02-16-2010, 06:07 AM | #9 |
The Grand Mouse 高貴的老鼠
Posts: 72,195
Karma: 308792702
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
|
Hmm.. I've been looking at this bit of code and the documentation, and I can see a potential problem or two.
Here's the guts of the plugin: Code:
def run(self, path_to_ebook): of = self.temporary_file('.mobi') data_file = file(path_to_ebook, 'rb').read() file(of.name, 'wb').write(data_file) return of.name So the plug-in uses the file path from the open to make a new file object, open it for binary writing, and writes the input file to the temporary file. * Should the plug-in be using the of.name in this way, and opening the file as binary write itself? * Should the plug-in be closing the temporary_file in seom explicit way? Last edited by pdurrant; 02-16-2010 at 06:09 AM. Reason: added code tags |
02-16-2010, 01:27 PM | #10 |
creator of calibre
Posts: 44,356
Karma: 23661992
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Temporary files are always opened in w+b (write, random access, binary)
Code:
of = self.temporary_file('.mobi') of.write(data) of.close() return of.name |
02-16-2010, 02:44 PM | #11 |
The Grand Mouse 高貴的老鼠
Posts: 72,195
Karma: 308792702
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
|
|
02-17-2010, 06:19 AM | #12 | |
The Grand Mouse 高貴的老鼠
Posts: 72,195
Karma: 308792702
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
|
Quote:
A couple more questions: Suppose a Filetype plugin was unable to successfully import a file for some reason. 1. What would be the best way to report this error to the user? 2. How would is be best to tell Calibre that the import had failed? |
|
02-17-2010, 08:04 AM | #13 |
Comparer of the Ephemeris
Posts: 1,496
Karma: 424697
Join Date: Mar 2009
Device: iPad
|
Here's a template that lets you display a simple dialog:
Code:
import os from calibre.customize import FileTypePlugin class HelloWorld(FileTypePlugin): name = 'HelloWorld' description = 'A shell for creating plugins' supported_platforms = ['windows', 'osx', 'linux'] author = 'your_name_here' version = (1, 0, 0) file_types = set(['your_file_type_here']) on_import = True def run(self, path_to_ebook): from calibre.gui2 import is_ok_to_use_qt from PyQt4.Qt import QMessageBox if is_ok_to_use_qt(): QMessageBox.question( None, 'Hello World Plugin', "path_to_ebook: %s" % path_to_ebook, QMessageBox.Ok) return path_to_ebook G |
02-17-2010, 12:23 PM | #14 |
The Grand Mouse 高貴的老鼠
Posts: 72,195
Karma: 308792702
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
|
|
02-17-2010, 01:09 PM | #15 |
The Grand Mouse 高貴的老鼠
Posts: 72,195
Karma: 308792702
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
|
I have a message box appearing now - thank you.
But returning None doesn't stop Calibre trying to import the file. Perhaps when a script can't do the intended conversion, it would be best just to return the original file path. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Issues importing mobi books from Fictionwise. | splat | Calibre | 14 | 02-22-2010 02:35 AM |
Error importing epub book to calibre and ipod touch | BigHoss | Calibre | 0 | 01-24-2010 10:21 AM |
unencrypted azw books - error importing | abrinton | Calibre | 4 | 01-19-2010 02:57 PM |
Error when importing MobiPocket files. | mbovenka | Calibre | 7 | 08-16-2008 10:07 AM |
Importing multiple files into Mobi Reader | Calamity | Bookeen | 0 | 07-25-2008 10:57 AM |