mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Bulk metadata edit: Fix getting cover from EPUB files that have no cover image by rendering the first page as the cover not working. Fixes #1374243 [Bulk Metadata "Set from ebook file(s)" when no cover image doesn't work](https://bugs.launchpad.net/calibre/+bug/1374243)
This commit is contained in:
parent
04a5ae2c2e
commit
f415c6ad80
@ -8,7 +8,7 @@ from various formats.
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
import traceback, os, re
|
import traceback, os, re
|
||||||
from calibre import CurrentDir
|
from calibre import CurrentDir, prints
|
||||||
|
|
||||||
class ConversionError(Exception):
|
class ConversionError(Exception):
|
||||||
|
|
||||||
@ -123,10 +123,26 @@ def render_html_svg_workaround(path_to_html, log, width=590, height=750):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
if data is None:
|
if data is None:
|
||||||
renderer = render_html(path_to_html, width, height)
|
from calibre.gui2 import is_ok_to_use_qt
|
||||||
data = getattr(renderer, 'data', None)
|
if is_ok_to_use_qt():
|
||||||
|
data = render_html_data(path_to_html, width, height)
|
||||||
|
else:
|
||||||
|
from calibre.utils.ipc.simple_worker import fork_job, WorkerError
|
||||||
|
try:
|
||||||
|
result = fork_job('calibre.ebooks',
|
||||||
|
'render_html_data',
|
||||||
|
(path_to_html, width, height),
|
||||||
|
no_output=True)
|
||||||
|
data = result['result']
|
||||||
|
except WorkerError as err:
|
||||||
|
prints(err.orig_tb)
|
||||||
|
except:
|
||||||
|
traceback.print_exc()
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
def render_html_data(path_to_html, width, height):
|
||||||
|
renderer = render_html(path_to_html, width, height)
|
||||||
|
return getattr(renderer, 'data', None)
|
||||||
|
|
||||||
def render_html(path_to_html, width=590, height=750, as_xhtml=True):
|
def render_html(path_to_html, width=590, height=750, as_xhtml=True):
|
||||||
from PyQt5.QtWebKitWidgets import QWebPage
|
from PyQt5.QtWebKitWidgets import QWebPage
|
||||||
|
Loading…
x
Reference in New Issue
Block a user