View Single Post
Old 09-20-2014, 07:49 AM   #4
plugin_dev
Junior Member
plugin_dev began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Sep 2014
Location: Edinburgh
Device: Kindle
Thanks, that seems cleaner and easier than my meta-date manipulation.

However it doesn't solve the specific problem I'm having - that the postimport method is not being called.

I've upgraded to the latest, 2.3.0, release, and reset my ~/.config/calibre directroy. With those things done the following code shows output from "run" but not "postimport".

Code:
import os
from calibre.customize import FileTypePlugin
from calibre.ebooks.metadata.meta import get_metadata, set_metadata

class RatingReset(FileTypePlugin):

    name                = 'Rating-Reset Plugin'
    description         = 'When a book is imported set the rating to zero.'
    supported_platforms = ['windows', 'osx', 'linux']
    author              = 'Moi.'
    version             = (0, 0, 2)
    file_types          = set(['epub', 'mobi', 'lit', 'prc'])
    on_postimport       = True
    minimum_calibre_version = (2,3,0)

    print "RatingReset::loaded"

    def run(self, path_to_ebook):
        print "RatingReset::run(%s)" % path_to_ebook
        return path_to_ebook

    def postimport( book_id, book_format, db):
        print "RatingReset::postimport()"
        db.new_api.set_field('rating', {book_id:0})
plugin_dev is offline   Reply With Quote