my first plugin did not work
I have tried the hello world plugin , but it didn't work.
I have set up the environment variable: calibre_develop_from.
D:\Development\Calibredev>dir
25/07/2014 11:57 1,070 __init__.py
D:\Development\Calibredev>calibre-customize -b .
Plugin updated: Hello World Plugin (1, 0, 0)
I added a txt file to calibre , and converted into epub file.
I hope to change the metadata during the converting, just like what the hello world plugin did. but it didn't change anything.
the following is the hello world plugin : any one can kindly help me to do the first plugin? thanks in advance.
import os
from calibre.customize import FileTypePlugin
class HelloWorld(FileTypePlugin):
name = 'Hello World Plugin' # Name of the plugin
description = 'Set the publisher to Hello World for all new conversions'
supported_platforms = ['windows', 'osx', 'linux'] # Platforms this plugin will run on
author = 'Acme Inc.' # The author of this plugin
version = (1, 0, 0) # The version number of this plugin
file_types = set(['epub', 'txt']) # The file types that this plugin will be applied to
on_postprocess = True # Run this plugin after conversion is complete
minimum_calibre_version = (0, 7, 53)
def run(self, path_to_ebook):
from calibre.ebooks.metadata.meta import get_metadata, set_metadata
file = open(path_to_ebook, 'r+b')
ext = os.path.splitext(path_to_ebook)[-1][1:].lower()
mi = get_metadata(file, ext)
mi.publisher = 'Hello World'
set_metadata(file, mi, ext)
return path_to_ebook
|