Hello together,
thanks again for the information provided, I am looking forward to the final Mobipocket support.
Until then I am trying to help myself with a File Plugin to convert the files using mobigen. However, since these are my first steps with Python I am a bit lost. I scanned over the forum and found a few hints about how to execut other application from a plugin, however, it does not seem to actually execute, this is the source I am using:
Code:
import os, sys
from calibre.customize import FileTypePlugin
class ePubPostProc(FileTypePlugin):
name = 'ePub Postprocessing Plugin'
description = 'Sets the Language of an ePub File to German and converts it to Mobipocket using mobigen.'
supported_platforms = ['windows']
author = 'Torben Nehmer, Nathan Syntronics'
version = (1, 0, 0)
file_types = set(['epub'])
on_postprocess = True
priority = 100
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.language = 'Deutsch'
set_metadata(file, mi, ext)
close(file)
subprocess.call('"c:\program files\calibre\mobigen.exe" "' + path_to_ebook + '"', shell=True);
return path_to_ebook
If I execute the command line in question from an arbitary path, everything works as expected.
Given that the conversion from .epub to .mobi works, two more questions: What are the correct calibre API calls for the following tasks:
1. Add the MOBI File as alternative format to the database. I could use the calibredb command line utility, but I suspect that it easier to do it with the API itself.
2. How to find out if the eBook in question already has a MOBI/PRC file in the library to avoid duplicate conversions?
Greetings,
Torben.