1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-11-01 07:36:20 +00:00

Final fix for #3189 (also working on windows)

This commit is contained in:
Ozzie Isaacs 2024-10-25 12:26:35 +02:00
parent e8cb84136b
commit 4fa7520598

View File

@ -268,14 +268,16 @@ class TaskConvert(CalibreTask):
opf_command = [calibredb_binarypath, 'show_metadata', '--as-opf', str(self.book_id), opf_command = [calibredb_binarypath, 'show_metadata', '--as-opf', str(self.book_id),
'--with-library', library_path] '--with-library', library_path]
p = process_open(opf_command, quotes, my_env) p = process_open(opf_command, quotes, my_env, newlines=False)
p.wait() lines = list()
while p.poll() is None:
lines.append(p.stdout.readline())
check = p.returncode check = p.returncode
calibre_traceback = p.stderr.readlines() calibre_traceback = p.stderr.readlines()
if check == 0: if check == 0:
path_tmp_opf = os.path.join(tmp_dir, "metadata_" + str(uuid4()) + ".opf") path_tmp_opf = os.path.join(tmp_dir, "metadata_" + str(uuid4()) + ".opf")
with open(path_tmp_opf, 'w') as fd: with open(path_tmp_opf, 'wb') as fd:
copyfileobj(p.stdout, fd) fd.write(b''.join(lines))
else: else:
error_message = "" error_message = ""
for ele in calibre_traceback: for ele in calibre_traceback:
@ -287,11 +289,11 @@ class TaskConvert(CalibreTask):
command = [config.config_converterpath, (file_path + format_old_ext), command = [config.config_converterpath, (file_path + format_old_ext),
(file_path + format_new_ext)] (file_path + format_new_ext)]
if config.config_embed_metadata: if config.config_embed_metadata:
quotes.append([4]) quotes.append(4)
quotes_index = 5 quotes_index = 5
command.extend(['--from-opf', path_tmp_opf]) command.extend(['--from-opf', path_tmp_opf])
if has_cover: if has_cover:
quotes.append([6]) quotes.append(6)
command.extend(['--cover', os.path.join(os.path.dirname(file_path), 'cover.jpg')]) command.extend(['--cover', os.path.join(os.path.dirname(file_path), 'cover.jpg')])
quotes_index = 7 quotes_index = 7
if config.config_calibre: if config.config_calibre: