mirror of
https://github.com/janeczku/calibre-web
synced 2024-12-27 02:20:31 +00:00
Improved code quality
This commit is contained in:
parent
0f1db18eae
commit
772f978b45
50
cps/web.py
50
cps/web.py
@ -1306,41 +1306,27 @@ def read_book(book_id, book_format):
|
|||||||
return render_title_template('readpdf.html', pdffile=book_id, title=_(u"Read a Book"))
|
return render_title_template('readpdf.html', pdffile=book_id, title=_(u"Read a Book"))
|
||||||
elif book_format.lower() == "txt":
|
elif book_format.lower() == "txt":
|
||||||
return render_title_template('readtxt.html', txtfile=book_id, title=_(u"Read a Book"))
|
return render_title_template('readtxt.html', txtfile=book_id, title=_(u"Read a Book"))
|
||||||
elif book_format.lower() == "mp3":
|
|
||||||
entries = db.session.query(db.Books).filter(db.Books.id == book_id).filter(common_filters()).first()
|
|
||||||
return render_title_template('listenmp3.html', mp3file=book_id, audioformat=book_format.lower(),
|
|
||||||
title=_(u"Read a Book"), entry=entries, bookmark=bookmark)
|
|
||||||
elif book_format.lower() == "m4b":
|
|
||||||
entries = db.session.query(db.Books).filter(db.Books.id == book_id).filter(common_filters()).first()
|
|
||||||
return render_title_template('listenmp3.html', mp3file=book_id, audioformat=book_format.lower(),
|
|
||||||
title=_(u"Read a Book"), entry=entries, bookmark=bookmark)
|
|
||||||
elif book_format.lower() == "m4a":
|
|
||||||
entries = db.session.query(db.Books).filter(db.Books.id == book_id).filter(common_filters()).first()
|
|
||||||
return render_title_template('listenmp3.html', mp3file=book_id, audioformat=book_format.lower(),
|
|
||||||
title=_(u"Read a Book"), entry=entries, bookmark=bookmark)
|
|
||||||
else:
|
else:
|
||||||
book_dir = os.path.join(config.get_main_dir, "cps", "static", str(book_id))
|
for fileExt in ["mp3", "m4b", "m4a"]:
|
||||||
if not os.path.exists(book_dir):
|
if book_format.lower() == fileExt:
|
||||||
os.mkdir(book_dir)
|
entries = db.session.query(db.Books).filter(db.Books.id == book_id).filter(common_filters()).first()
|
||||||
for fileext in ["cbr", "cbt", "cbz"]:
|
return render_title_template('listenmp3.html', mp3file=book_id, audioformat=book_format.lower(),
|
||||||
if book_format.lower() == fileext:
|
title=_(u"Read a Book"), entry=entries, bookmark=bookmark)
|
||||||
all_name = str(book_id) # + "/" + book.data[0].name + "." + fileext
|
for fileExt in ["cbr", "cbt", "cbz"]:
|
||||||
# tmp_file = os.path.join(book_dir, book.data[0].name) + "." + fileext
|
if book_format.lower() == fileExt:
|
||||||
# if not os.path.exists(all_name):
|
all_name = str(book_id)
|
||||||
# cbr_file = os.path.join(config.config_calibre_dir, book.path, book.data[0].name) + "." + fileext
|
|
||||||
# copyfile(cbr_file, tmp_file)
|
|
||||||
return render_title_template('readcbr.html', comicfile=all_name, title=_(u"Read a Book"),
|
return render_title_template('readcbr.html', comicfile=all_name, title=_(u"Read a Book"),
|
||||||
extension=fileext)
|
extension=fileExt)
|
||||||
'''if feature_support['rar']:
|
# if feature_support['rar']:
|
||||||
extensionList = ["cbr","cbt","cbz"]
|
# extensionList = ["cbr","cbt","cbz"]
|
||||||
else:
|
# else:
|
||||||
extensionList = ["cbt","cbz"]
|
# extensionList = ["cbt","cbz"]
|
||||||
for fileext in extensionList:
|
# for fileext in extensionList:
|
||||||
if book_format.lower() == fileext:
|
# if book_format.lower() == fileext:
|
||||||
return render_title_template('readcbr.html', comicfile=book_id,
|
# return render_title_template('readcbr.html', comicfile=book_id,
|
||||||
extension=fileext, title=_(u"Read a Book"), book=book)
|
# extension=fileext, title=_(u"Read a Book"), book=book)
|
||||||
flash(_(u"Error opening eBook. File does not exist or file is not accessible."), category="error")
|
flash(_(u"Error opening eBook. File does not exist or file is not accessible."), category="error")
|
||||||
return redirect(url_for("web.index"))'''
|
return redirect(url_for("web.index"))
|
||||||
|
|
||||||
|
|
||||||
@web.route("/book/<int:book_id>")
|
@web.route("/book/<int:book_id>")
|
||||||
|
Loading…
Reference in New Issue
Block a user