mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #1169 (any2epub ignores --metadata-from= for lit files)
This commit is contained in:
parent
483ece52ce
commit
d0b4cce3cd
@ -224,6 +224,10 @@ def convert(htmlfile, opts, notification=None):
|
||||
opts.override_css = open(opts.override_css, 'rb').read().decode(preferred_encoding, 'replace')
|
||||
except:
|
||||
opts.override_css = opts.override_css.decode(preferred_encoding, 'replace')
|
||||
if opts.from_opf:
|
||||
opts.from_opf = os.path.abspath(opts.from_opf)
|
||||
if opts.from_ncx:
|
||||
opts.from_ncx = os.path.abspath(opts.from_ncx)
|
||||
if htmlfile.lower().endswith('.opf'):
|
||||
opf = OPF(htmlfile, os.path.dirname(os.path.abspath(htmlfile)))
|
||||
filelist = opf_traverse(opf, verbose=opts.verbose, encoding=opts.encoding)
|
||||
@ -233,7 +237,7 @@ def convert(htmlfile, opts, notification=None):
|
||||
if htmlfile is None:
|
||||
raise ValueError('Could not find suitable file to convert.')
|
||||
filelist = get_filelist(htmlfile, opts)[1]
|
||||
mi = MetaInformation(opf)
|
||||
mi = merge_metadata(None, opf, opts)
|
||||
else:
|
||||
opf, filelist = get_filelist(htmlfile, opts)
|
||||
mi = merge_metadata(htmlfile, opf, opts)
|
||||
|
@ -906,11 +906,12 @@ def merge_metadata(htmlfile, opf, opts):
|
||||
'''
|
||||
if opf:
|
||||
mi = MetaInformation(opf)
|
||||
else:
|
||||
elif htmlfile:
|
||||
try:
|
||||
mi = get_metadata(open(htmlfile, 'rb'), 'html')
|
||||
except:
|
||||
mi = MetaInformation(None, None)
|
||||
|
||||
if opts.from_opf is not None and os.access(opts.from_opf, os.R_OK):
|
||||
mi.smart_update(OPF(open(opts.from_opf, 'rb'), os.path.abspath(os.path.dirname(opts.from_opf))))
|
||||
for attr in ('title', 'authors', 'publisher', 'tags', 'comments'):
|
||||
|
Loading…
x
Reference in New Issue
Block a user