fix embed metadata, split library and download file / convert files

pull/2695/merge
Ozzie Isaacs 3 months ago
parent d659430116
commit 80a2d07009

@ -1007,10 +1007,17 @@ def do_calibre_export(book_id, book_format, ):
tmp_dir = get_temp_dir() tmp_dir = get_temp_dir()
calibredb_binarypath = get_calibre_binarypath("calibredb") calibredb_binarypath = get_calibre_binarypath("calibredb")
temp_file_name = str(uuid4()) temp_file_name = str(uuid4())
opf_command = [calibredb_binarypath, 'export', '--dont-write-opf', '--with-library', config.config_calibre_dir, my_env = os.environ.copy()
if config.config_calibre_split:
my_env['CALIBRE_OVERRIDE_DATABASE_PATH'] = os.path.join(config.config_calibre_dir, "metadata.db")
library_path = config.config_calibre_split_dir
else:
library_path = config.config_calibre_dir
opf_command = [calibredb_binarypath, 'export', '--dont-write-opf', '--with-library', library_path,
'--to-dir', tmp_dir, '--formats', book_format, "--template", "{}".format(temp_file_name), '--to-dir', tmp_dir, '--formats', book_format, "--template", "{}".format(temp_file_name),
str(book_id)] str(book_id)]
p = process_open(opf_command, quotes) # CALIBRE_OVERRIDE_DATABASE_PATH
p = process_open(opf_command, quotes, my_env)
_, err = p.communicate() _, err = p.communicate()
if err: if err:
log.error('Metadata embedder encountered an error: %s', err) log.error('Metadata embedder encountered an error: %s', err)

@ -251,9 +251,16 @@ class TaskConvert(CalibreTask):
quotes = [3, 5] quotes = [3, 5]
tmp_dir = get_temp_dir() tmp_dir = get_temp_dir()
calibredb_binarypath = os.path.join(config.config_binariesdir, SUPPORTED_CALIBRE_BINARIES["calibredb"]) calibredb_binarypath = os.path.join(config.config_binariesdir, SUPPORTED_CALIBRE_BINARIES["calibredb"])
my_env = os.environ.copy()
if config.config_calibre_split:
my_env['CALIBRE_OVERRIDE_DATABASE_PATH'] = os.path.join(config.config_calibre_dir, "metadata.db")
library_path = config.config_calibre_split_dir
else:
library_path = config.config_calibre_dir
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', config.config_calibre_dir] '--with-library', library_path]
p = process_open(opf_command, quotes) p = process_open(opf_command, quotes, my_env)
p.wait() p.wait()
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, 'w') as fd:

@ -18,7 +18,7 @@
</div> </div>
<div class="form-group required"> <div class="form-group required">
<input type="checkbox" id="config_calibre_split" name="config_calibre_split" data-control="split_settings" data-t ="{{ config.config_calibre_split_dir }}" {% if config.config_calibre_split %}checked{% endif %} > <input type="checkbox" id="config_calibre_split" name="config_calibre_split" data-control="split_settings" data-t ="{{ config.config_calibre_split_dir }}" {% if config.config_calibre_split %}checked{% endif %} >
<label for="config_calibre_split">{{_('Separate Book files from Library (Highly experimental, might not work at all)')}}</label> <label for="config_calibre_split">{{_('Separate Book files from Library (Experimental, may lead to unexpected behavior)')}}</label>
</div> </div>
<div data-related="split_settings"> <div data-related="split_settings">
<div class="form-group required input-group"> <div class="form-group required input-group">

Loading…
Cancel
Save