02-18-2010, 05:53 PM | #1 |
The Grand Mouse 高貴的老鼠
Posts: 72,557
Karma: 310023688
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
|
PDB to PMLZ File type plugin
I'm trying to write a filetype plugin that takes as input one file type, but passes a different file type along to Calibre for further processing.
I see that there is one already that takes a PML file (& associated images) and converts into a PMLZ file, so I think it must be possible, but I don't seem to be able to get mine working. I have been trying to return the new file in a temporary file, as I've done successfully with another File type plugin. But no joy. Is there anything else I need to be doing in the plugin to tell Calibre that the file type has changed? Of course, it might just be that I have something else wrong in the plug-in and it isn't getting called. Is there a way to debug a filetype plugin without having to compile up all of Calibre in a debug version? Thanks for any help. |
02-18-2010, 06:27 PM | #2 | |
Wizard
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
Quote:
|
|
Advert | |
|
02-18-2010, 06:50 PM | #3 |
creator of calibre
Posts: 44,573
Karma: 24495948
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Use
calibredb add and stick print statements in your plugin code, these will then be printed out to the command prompt |
02-18-2010, 06:57 PM | #4 |
The Grand Mouse 高貴的老鼠
Posts: 72,557
Karma: 310023688
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
|
|
02-19-2010, 06:17 AM | #5 |
The Grand Mouse 高貴的老鼠
Posts: 72,557
Karma: 310023688
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
|
OK, I now have it 'working' - in that a book of type PMLZ now gets imported into Calibre.
But by doing it this route, I seem to have bypassed the PMLZ import filter, and so none of the metadata or images work right. I've checked that my PMLZ file is a good file, by re-importing it. Which gets me cover image* and metadata correctly. Is there any way I can get Calibre to reprocess the file I return from my Filetype plugin, to pass it on to the PMLZ import filter? Or am I asking the wrong question, and there's a better way to do what I want? *Well, if I manually change the <pmlname>_img folder name in the archive to "images". I thought the PMLZ import supported the _img folder name, but apparently not. |
Advert | |
|
02-19-2010, 11:59 AM | #6 |
creator of calibre
Posts: 44,573
Karma: 24495948
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
IIRC file import plugins are run after metadata reading plugins, so metadata wont be read from the converted file.
May I ask why you need this plugin at all? Why not just write an input format plugin for the conversion system? |
02-19-2010, 07:04 PM | #7 | |
The Grand Mouse 高貴的老鼠
Posts: 72,557
Karma: 310023688
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
|
Quote:
The only script I have that decrypts eReader files converts them into a PML file and a folder of images, and Calibre seems to like to have those as a zip file -- a PMLZ. It may be that I've misunderstood the way things work, but I thought that for doing things on import a filetype plugin was the way to go. And I'm surprised to hear that metadata plugins getr called before filetype plugins, as I had reports of errors with earlier versions of the Mobipocket plugin where a mis-understanding of how to handle temporary files could lead to the Meta data plugin reporting that it couldn't read the metadata. |
|
02-19-2010, 07:31 PM | #8 |
Sigil Developer
Posts: 8,160
Karma: 5450818
Join Date: Nov 2009
Device: many
|
PMLZ
> The only script I have that decrypts eReader files converts them into a PML file and a folder of images, and Calibre seems to like to have those as a zip file -- a PMLZ.
FWIW - As you know it is trivial to convert that scripts output to create a pmlz archive instead of a pml file and images. In fact, the code to do just that was contributed to the DR list recently. So if I understand things, you want to use those additions and have that script work as a plugin to Calibre and somehow use its pmlz output as a temporary format internal to the plugin and have that be recognized and properly handled by Calibre. Sort of a plugin for one format (pdb) that creates a different intermediate format (pmlz) -- which normally another input plugin would recognize and handle -- but all in one go. Is that right? |
02-19-2010, 08:12 PM | #9 |
Sigil & calibre developer
Posts: 2,487
Karma: 1063785
Join Date: Jan 2009
Location: Florida, USA
Device: Nook STR
|
There is a PML2PMLZ import plugin already. When you import a PML file it will take it plus the images and turn it into a PMLZ. Is this not working?
|
02-20-2010, 05:29 AM | #10 | |
The Grand Mouse 高貴的老鼠
Posts: 72,557
Karma: 310023688
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
|
Quote:
I was hoping that when my filetype plugin returned a PLMZ file instead of a PDB file, that the PMLZ metadata importer would be called. I think it works for Mobipocket because the Mobipocket importer returns a Mobipocket file (just decrypted). I don't have a way to go from encrypted PDB file to decrypted PDB file, only to a PMLZ. |
|
02-20-2010, 05:31 AM | #11 |
The Grand Mouse 高貴的老鼠
Posts: 72,557
Karma: 310023688
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
|
That's working fine (I think - I haven't double-checked just now). But that requires the user to do the conversion from PDB to PML manually, before trying to import anything into Calibre. I was hoping to get a 'one step' import process going, as has been done for Mobipocket.
|
02-20-2010, 05:32 AM | #12 |
creator of calibre
Posts: 44,573
Karma: 24495948
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
I just looked at the code and metadata is read before import plugins are called. Why is the metadata not being read from the PDB file? IIRC calibre has a PDB metadata reader.
|
02-20-2010, 09:58 AM | #13 | |
Sigil & calibre developer
Posts: 2,487
Karma: 1063785
Join Date: Jan 2009
Location: Florida, USA
Device: Nook STR
|
Quote:
|
|
02-20-2010, 11:42 AM | #14 | |
The Grand Mouse 高貴的老鼠
Posts: 72,557
Karma: 310023688
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
|
Quote:
But what about your Archive Extract Filetype plug-in? Doesn't it have the same problem that my plug-in has - no meta data extracted from the file? (goes to check) Yes, it does - If I put a (non-DRMed) Mobipocket file into a zip archive and import it, it imports as a PRC format file, and can be viewed in the viewer, but no metadata has been read for it. Should I raise an enhancement request for this? Of can you think of a work-around? |
|
02-20-2010, 11:48 AM | #15 | |
Sigil Developer
Posts: 8,160
Karma: 5450818
Join Date: Nov 2009
Device: many
|
Quote:
So, FWIW it may be possible to read the metadata without actually decrypting an an ereader pdb. |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Deleting file type | kevinofengland | Calibre | 5 | 10-14-2010 06:10 AM |
New Plugin Type Idea: Library Plugin | cgranade | Plugins | 3 | 09-15-2010 01:11 PM |
Secure .PDB file to file Kindle will read! Help! | mbtravis63 | Kindle Formats | 2 | 01-17-2010 05:20 AM |
Display File Type and Sort by Type | pragmortal | Calibre | 7 | 09-21-2009 09:07 PM |
file type question | dow | Sony Reader | 22 | 02-04-2008 11:05 AM |