mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-08 15:13:41 +02:00
HTML2ZIP import plugin works again
This commit is contained in:
parent
c3ff54c319
commit
29c172b95e
4 changed files with 16 additions and 7 deletions
|
|
@ -2,7 +2,7 @@
|
|||
__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 @@ class HTML2ZIP(FileTypePlugin):
|
|||
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 @@ def run(self):
|
|||
return
|
||||
|
||||
for id in ids:
|
||||
print 11111111, id
|
||||
progress(id)
|
||||
|
||||
for job in jobs:
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ def add(self, books):
|
|||
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):
|
||||
|
|
|
|||
1
todo
1
todo
|
|
@ -5,4 +5,3 @@
|
|||
|
||||
* Replace single application stuff with Listener from multiprocessing
|
||||
|
||||
* Fix HTML-to-ZIP plugin
|
||||
|
|
|
|||
Loading…
Reference in a new issue