mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-08 15:13:41 +02:00
...
This commit is contained in:
commit
52d1bac2d8
2 changed files with 9 additions and 8 deletions
|
|
@ -437,7 +437,7 @@ def set_metadata(self, stream, mi, type):
|
|||
class MOBIMetadataWriter(MetadataWriterPlugin):
|
||||
|
||||
name = 'Set MOBI metadata'
|
||||
file_types = set(['mobi', 'prc', 'azw'])
|
||||
file_types = set(['mobi', 'prc', 'azw', 'azw4'])
|
||||
description = _('Set metadata in %s files')%'MOBI'
|
||||
author = 'Marshall T. Vandegrift'
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
|
||||
from calibre.ebooks.pdb.formatreader import FormatReader
|
||||
from calibre.ptempfile import TemporaryFile
|
||||
from calibre.ptempfile import PersistentTemporaryFile
|
||||
|
||||
class Reader(FormatReader):
|
||||
|
||||
|
|
@ -23,10 +23,12 @@ def __init__(self, header, stream, log, options):
|
|||
def extract_content(self, output_dir):
|
||||
self.log.info('Extracting PDF...')
|
||||
|
||||
with TemporaryFile() as pdf_n:
|
||||
pdf = open(pdf_n, 'rwb')
|
||||
for x in xrange(self.header.section_count()):
|
||||
pdf.write(self.header.section_data(x))
|
||||
pdf = PersistentTemporaryFile('.pdf')
|
||||
pdf.close()
|
||||
pdf = open(pdf, 'wb')
|
||||
for x in xrange(self.header.section_count()):
|
||||
pdf.write(self.header.section_data(x))
|
||||
pdf.close()
|
||||
|
||||
from calibre.customize.ui import plugin_for_input_format
|
||||
|
||||
|
|
@ -35,5 +37,4 @@ def extract_content(self, output_dir):
|
|||
if not hasattr(self.options, opt.option.name):
|
||||
setattr(self.options, opt.option.name, opt.recommended_value)
|
||||
|
||||
pdf.seek(0)
|
||||
return pdf_plugin.convert(pdf, self.options, 'pdf', self.log, {})
|
||||
return pdf_plugin.convert(open(pdf, 'rb'), self.options, 'pdf', self.log, {})
|
||||
|
|
|
|||
Loading…
Reference in a new issue