Re-commit: #584 & #587 Convert any book format to another format

This commit is contained in:
bodybybuddha
2018-08-28 23:32:30 -04:00
parent a5b188230c
commit 4b006fba99
3 changed files with 198 additions and 13 deletions
+18 -10
View File
@@ -3177,19 +3177,19 @@ def edit_book(book_id):
for authr in book.authors:
author_names.append(authr.name.replace('|', ','))
#Option for showing convertbook button
# Option for showing convertbook button
if config.config_ebookconverter == 2:
display_convertbtn = True
else:
display_convertbtn = False
#Determine what formats don't already exist
allowed_conversion_formats = ALLOWED_EXTENSIONS
# Determine what formats don't already exist
allowed_conversion_formats = ALLOWED_EXTENSIONS.copy()
for file in book.data:
try:
allowed_conversion_formats.remove(file.format.lower())
except Exception:
app.logger.warning(file.formate.lower() + ' already removed from list.')
app.logger.warning(file.format.lower() + ' already removed from list.')
app.logger.debug(allowed_conversion_formats)
@@ -3629,11 +3629,19 @@ def upload():
@login_required_if_no_ano
@edit_required
def convert_bookformat(book_id):
# rtn = convert_book_format(book_id, calibrepath, new_book_format, user_id)
app.logger.debug('got here')
app.logger.debug('book id:' + str(book_id))
app.logger.debug('from format:'+request.form['book_format_from'])
app.logger.debug('to format:' + request.form['book_format_to'])
app.logger.debug('converting: book id: ' + str(book_id) +
' from: ' + request.form['book_format_from'] +
' to: ' + request.form['book_format_to'])
rtn = helper.convert_book_format(book_id, config.config_calibre_dir, request.form['book_format_from'].upper(),
request.form['book_format_to'].upper(), current_user.nickname)
if rtn is None:
flash(_(u"Book successfully queued for converting to %(book_format)s",
book_format=request.form['book_format_from']),
category="success")
else:
flash(_(u"There was an error sending this book: %(res)s", res=rtn), category="error")
return redirect(url_for("get_tasks_status"))
return redirect(url_for("index"))