mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
HTML2ZIP import plugin works again
This commit is contained in:
parent
c3ff54c319
commit
29c172b95e
@ -2,7 +2,7 @@ from __future__ import with_statement
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import textwrap, os
|
||||
import textwrap, os, glob
|
||||
from calibre.customize import FileTypePlugin, MetadataReaderPlugin, MetadataWriterPlugin
|
||||
from calibre.constants import __version__
|
||||
|
||||
@ -20,9 +20,20 @@ every time you add an HTML file to the library.\
|
||||
on_import = True
|
||||
|
||||
def run(self, htmlfile):
|
||||
of = self.temporary_file('_plugin_html2zip.zip')
|
||||
from calibre.ebooks.html import gui_main as html2oeb
|
||||
html2oeb(htmlfile, of)
|
||||
from calibre.ptempfile import TemporaryDirectory
|
||||
from calibre.gui2.convert.gui_conversion import gui_convert
|
||||
from calibre.customize.conversion import OptionRecommendation
|
||||
from calibre.ebooks.epub import initialize_container
|
||||
|
||||
with TemporaryDirectory('_plugin_html2zip') as tdir:
|
||||
gui_convert(htmlfile, tdir, [('debug_input', tdir,
|
||||
OptionRecommendation.HIGH)])
|
||||
of = self.temporary_file('_plugin_html2zip.zip')
|
||||
opf = glob.glob(os.path.join(tdir, '*.opf'))[0]
|
||||
epub = initialize_container(of.name, os.path.basename(opf))
|
||||
epub.add_dir(tdir)
|
||||
epub.close()
|
||||
|
||||
return of.name
|
||||
|
||||
class OPFMetadataReader(MetadataReaderPlugin):
|
||||
|
@ -101,7 +101,6 @@ class ReadMetadata(Thread):
|
||||
return
|
||||
|
||||
for id in ids:
|
||||
print 11111111, id
|
||||
progress(id)
|
||||
|
||||
for job in jobs:
|
||||
|
@ -90,7 +90,7 @@ class Adder(QObject):
|
||||
def add_formats(self, id, formats):
|
||||
for path in formats:
|
||||
fmt = os.path.splitext(path)[-1].replace('.', '').upper()
|
||||
self.db.add_format(id, fmt, open(path, 'rb'), index_is_id=True,
|
||||
self.db.add_format_with_hooks(id, fmt, path, index_is_id=True,
|
||||
notify=False)
|
||||
|
||||
def canceled(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user