Make embed metadata configurable
This commit is contained in:
parent
d341faf204
commit
1086296d1d
|
@ -1745,6 +1745,7 @@ def _configuration_update_helper():
|
||||||
|
|
||||||
_config_checkbox_int(to_save, "config_uploading")
|
_config_checkbox_int(to_save, "config_uploading")
|
||||||
_config_checkbox_int(to_save, "config_unicode_filename")
|
_config_checkbox_int(to_save, "config_unicode_filename")
|
||||||
|
_config_checkbox_int(to_save, "config_embed_metadata")
|
||||||
# Reboot on config_anonbrowse with enabled ldap, as decoraters are changed in this case
|
# Reboot on config_anonbrowse with enabled ldap, as decoraters are changed in this case
|
||||||
reboot_required |= (_config_checkbox_int(to_save, "config_anonbrowse")
|
reboot_required |= (_config_checkbox_int(to_save, "config_anonbrowse")
|
||||||
and config.config_login_type == constants.LOGIN_LDAP)
|
and config.config_login_type == constants.LOGIN_LDAP)
|
||||||
|
|
|
@ -144,6 +144,7 @@ class _Settings(_Base):
|
||||||
config_rarfile_location = Column(String, default=None)
|
config_rarfile_location = Column(String, default=None)
|
||||||
config_upload_formats = Column(String, default=','.join(constants.EXTENSIONS_UPLOAD))
|
config_upload_formats = Column(String, default=','.join(constants.EXTENSIONS_UPLOAD))
|
||||||
config_unicode_filename = Column(Boolean, default=False)
|
config_unicode_filename = Column(Boolean, default=False)
|
||||||
|
config_embed_metadata = Column(Boolean, default=True)
|
||||||
|
|
||||||
config_updatechannel = Column(Integer, default=constants.UPDATE_STABLE)
|
config_updatechannel = Column(Integer, default=constants.UPDATE_STABLE)
|
||||||
|
|
||||||
|
|
|
@ -942,14 +942,13 @@ def do_download_file(book, book_format, client, data, headers):
|
||||||
df = gd.getFileFromEbooksFolder(book.path, book_name + "." + book_format)
|
df = gd.getFileFromEbooksFolder(book.path, book_name + "." + book_format)
|
||||||
# log.debug('%s', time.time() - startTime)
|
# log.debug('%s', time.time() - startTime)
|
||||||
if df:
|
if df:
|
||||||
if config.config_binariesdir:
|
if config.config_binariesdir and config.config_embed_metadata:
|
||||||
output_path = os.path.join(config.config_calibre_dir, book.path)
|
output_path = os.path.join(config.config_calibre_dir, book.path)
|
||||||
if not os.path.exists(output_path):
|
if not os.path.exists(output_path):
|
||||||
os.makedirs(output_path)
|
os.makedirs(output_path)
|
||||||
output = os.path.join(config.config_calibre_dir, book.path, book_name + "." + book_format)
|
output = os.path.join(config.config_calibre_dir, book.path, book_name + "." + book_format)
|
||||||
gd.downloadFile(book.path, book_name + "." + book_format, output)
|
gd.downloadFile(book.path, book_name + "." + book_format, output)
|
||||||
filename, download_name = do_calibre_export(book, book_format)
|
filename, download_name = do_calibre_export(book, book_format)
|
||||||
# ToDo: delete path in calibre-folder structure
|
|
||||||
else:
|
else:
|
||||||
return gd.do_gdrive_download(df, headers)
|
return gd.do_gdrive_download(df, headers)
|
||||||
else:
|
else:
|
||||||
|
@ -963,7 +962,7 @@ def do_download_file(book, book_format, client, data, headers):
|
||||||
if client == "kobo" and book_format == "kepub":
|
if client == "kobo" and book_format == "kepub":
|
||||||
headers["Content-Disposition"] = headers["Content-Disposition"].replace(".kepub", ".kepub.epub")
|
headers["Content-Disposition"] = headers["Content-Disposition"].replace(".kepub", ".kepub.epub")
|
||||||
|
|
||||||
if config.config_binariesdir:
|
if config.config_binariesdir and config.config_embed_metadata:
|
||||||
filename, download_name = do_calibre_export(book, book_format)
|
filename, download_name = do_calibre_export(book, book_format)
|
||||||
else:
|
else:
|
||||||
download_name = book_name
|
download_name = book_name
|
||||||
|
|
|
@ -238,19 +238,12 @@ class TaskConvert(CalibreTask):
|
||||||
def _convert_calibre(self, file_path, format_old_ext, format_new_ext, has_cover):
|
def _convert_calibre(self, file_path, format_old_ext, format_new_ext, has_cover):
|
||||||
book_id = self.book_id
|
book_id = self.book_id
|
||||||
try:
|
try:
|
||||||
# Linux py2.7 encode as list without quotes no empty element for parameters
|
if config.config_embed_metadata:
|
||||||
# linux py3.x no encode and as list without quotes no empty element for parameters
|
|
||||||
# windows py2.7 encode as string with quotes empty element for parameters is okay
|
|
||||||
# windows py 3.x no encode and as string with quotes empty element for parameters is okay
|
|
||||||
# separate handling for windows and linux
|
|
||||||
|
|
||||||
quotes = [3, 5]
|
quotes = [3, 5]
|
||||||
tmp_dir = get_temp_dir()
|
tmp_dir = get_temp_dir()
|
||||||
#tmp_dir = os.path.join(gettempdir(), 'calibre_web')
|
|
||||||
#if not os.path.isdir(tmp_dir):
|
|
||||||
# os.mkdir(tmp_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"])
|
||||||
opf_command = [calibredb_binarypath, 'show_metadata', '--as-opf', str(book_id), '--with-library', config.config_calibre_dir]
|
opf_command = [calibredb_binarypath, 'show_metadata', '--as-opf', str(book_id),
|
||||||
|
'--with-library', config.config_calibre_dir]
|
||||||
p = process_open(opf_command, quotes)
|
p = process_open(opf_command, quotes)
|
||||||
p.wait()
|
p.wait()
|
||||||
path_tmp_opf = os.path.join(tmp_dir, "metadata_" + str(current_milli_time()) + ".opf")
|
path_tmp_opf = os.path.join(tmp_dir, "metadata_" + str(current_milli_time()) + ".opf")
|
||||||
|
@ -259,7 +252,9 @@ class TaskConvert(CalibreTask):
|
||||||
|
|
||||||
quotes = [1, 2, 4, 6]
|
quotes = [1, 2, 4, 6]
|
||||||
command = [config.config_converterpath, (file_path + format_old_ext),
|
command = [config.config_converterpath, (file_path + format_old_ext),
|
||||||
(file_path + format_new_ext), '--from-opf', path_tmp_opf]
|
(file_path + format_new_ext)]
|
||||||
|
if config.config_embed_metadata:
|
||||||
|
command.extend('--from-opf', path_tmp_opf)
|
||||||
if has_cover:
|
if has_cover:
|
||||||
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 = 3
|
quotes_index = 3
|
||||||
|
|
|
@ -103,6 +103,10 @@
|
||||||
<input type="checkbox" id="config_unicode_filename" name="config_unicode_filename" {% if config.config_unicode_filename %}checked{% endif %}>
|
<input type="checkbox" id="config_unicode_filename" name="config_unicode_filename" {% if config.config_unicode_filename %}checked{% endif %}>
|
||||||
<label for="config_unicode_filename">{{_('Convert non-English characters in title and author while saving to disk')}}</label>
|
<label for="config_unicode_filename">{{_('Convert non-English characters in title and author while saving to disk')}}</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<input type="checkbox" id="config_embed_metadata" name="config_embed_metadata" {% if config.config_embed_metadata %}checked{% endif %}>
|
||||||
|
<label for="config_embed_metadata">{{_('Embed Metadata to Ebook File on Download and Conversion')}}</label>
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input type="checkbox" id="config_uploading" data-control="upload_settings" name="config_uploading" {% if config.config_uploading %}checked{% endif %}>
|
<input type="checkbox" id="config_uploading" data-control="upload_settings" name="config_uploading" {% if config.config_uploading %}checked{% endif %}>
|
||||||
<label for="config_uploading">{{_('Enable Uploads')}} {{_('(Please ensure that users also have upload permissions)')}}</label>
|
<label for="config_uploading">{{_('Enable Uploads')}} {{_('(Please ensure that users also have upload permissions)')}}</label>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user