View Single Post
Old 08-27-2009, 03:29 PM   #3
macr0t0r
Connoisseur
macr0t0r doesn't littermacr0t0r doesn't litter
 
macr0t0r's Avatar
 
Posts: 91
Karma: 108
Join Date: Jan 2008
Device: Palm Treo 680, Sony Reader
Thanks for the response. So, a couple notes:

PML to HTML code
I'm not sure how much you'd want my code. The purpose of my code is to structure the HTML specifically for the Sony PRS-500 so that the HTML2LRF code makes as near perfect reproduction of the eReader file as possible:
1. Every link target creates a new <div> (as required by the LRF).
2. Footnotes are changed into links, and the footnote itself has a link back to the original text.
3. It assumes no inheritance and there are no "layered" span tags. All text is incapsulated with a single-level span tag. Every time the format changes or there is a new division, then the current span is closed and new one is created with all of the styles defined. It makes for some pretty busy-looking HTML code, but it was the only way to get consistent font and format in the resulting LRF format.

I really doubt my HTML CSS code would pass the ePub test. However, I suppose my footnote/sidebar code could be of use. I haven't checked to see if Calibre already handles it.

Calling another FileTypePlugin
Truth be told, I don't know HOW you call a plugin. I know how to MAKE a plugin that Calibre calls. I found the HTML2ZIP class in the builtins.py (thank you), but for some reason I just couldn't get it to work right. I apologize that I don't have the details with me right now.

In any case, I decided to take another route. I discovered that "adding" a file in the MetaData editor executes the same plugins, so my little project made it impossible for me to add the original eReader file to my Library. I want to keep that file as well for reading on my phone.

So, my workflow is this:
1. I add the eReader file.
--a. My plugin generates the folder with the html and images, but returns the path to the original eReader file.
--b. The default PDB plugin then pulls in a minimal amount of metadata and adds the file to the library.
2. I then open the metadata and add the html file.
--a. The default HTML2ZIP program gathers all links and adds the zip file to my library
3. I then use the new "use metadata from this file" to update the metadata from the zip file.
4. I then convert from the zip file to LRF.

Now, each book of mine is in 3 formats: PDB for our phones, ZIP for FBReader on my Nokia tablet, and LRF for my wife's Sony Reader.

A bit laborious, but it's not like I'm getting 5 new books a day. I think the main thing I want to work on is improving the metadata retrieval from PDB and PML files. I could look into your PML2HTML stuff but...man...it's going to take me some time to figure out that whole path. That code really jumps around a lot.

I DO have a question remaining: If a plugin of a high priority returns a file with a different extension, does Calibre re-evaluate that extension and fires off the appropriate plugin and/or builtin function before adding the file to the database? In my original plugin, I converted the PDB to an HTML file (with links to images), but Calibre then just added the individual HTML file to the database. I had to add a book and re-select the html file to get HTML2ZIP to run and generate the zip file. Is that a bug or a feature?

- Jim
macr0t0r is offline   Reply With Quote