From d951ee4b83a9e67c3296f2ef0a3dcb6f7570f0f0 Mon Sep 17 00:00:00 2001 From: Dave Mogle Date: Mon, 17 Aug 2020 10:31:07 -0400 Subject: [PATCH 1/4] Prefer kepub (#1439) Only offer kepub download URL over Kobo sync API when available --- cps/kobo.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cps/kobo.py b/cps/kobo.py index a6dfc3f6..8d97785e 100644 --- a/cps/kobo.py +++ b/cps/kobo.py @@ -344,7 +344,9 @@ def get_seriesindex(book): def get_metadata(book): download_urls = [] - for book_data in book.data: + kepub = [data for data in book.data if data.format == 'KEPUB'] + + for book_data in kepub if len(kepub) > 0 else book.data: if book_data.format not in KOBO_FORMATS: continue for kobo_format in KOBO_FORMATS[book_data.format]: From 88ea998f8be14b15a5fc960355c1526d8574d194 Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Fri, 11 Dec 2020 15:53:45 +0100 Subject: [PATCH 2/4] Only register gdrive callback if gdrive is enabled With enabled gdrive return on change if no watch callback is configured, instead of send request to google drive --- cps.py | 5 +++-- cps/gdrive.py | 4 +++- cps/gdriveutils.py | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cps.py b/cps.py index 3601e4b6..20aa9cac 100755 --- a/cps.py +++ b/cps.py @@ -31,7 +31,7 @@ else: sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'vendor')) -from cps import create_app +from cps import create_app, config from cps import web_server from cps.opds import opds from cps.web import web @@ -64,7 +64,8 @@ def main(): app.register_blueprint(about) app.register_blueprint(shelf) app.register_blueprint(admi) - app.register_blueprint(gdrive) + if config.config_use_google_drive: + app.register_blueprint(gdrive) app.register_blueprint(editbook) if kobo_available: app.register_blueprint(kobo) diff --git a/cps/gdrive.py b/cps/gdrive.py index 584c90cf..90b83e64 100644 --- a/cps/gdrive.py +++ b/cps/gdrive.py @@ -123,10 +123,12 @@ def revoke_watch_gdrive(): @gdrive.route("/gdrive/watch/callback", methods=['GET', 'POST']) def on_received_watch_confirmation(): + if not config.config_google_drive_watch_changes_response: + return '' if request.headers.get('X-Goog-Channel-Token') != gdrive_watch_callback_token \ or request.headers.get('X-Goog-Resource-State') != 'change' \ or not request.data: - return redirect(url_for('admin.configuration')) + return '' # redirect(url_for('admin.configuration')) log.debug('%r', request.headers) log.debug('%r', request.data) diff --git a/cps/gdriveutils.py b/cps/gdriveutils.py index 489bc6f5..3e00c9af 100644 --- a/cps/gdriveutils.py +++ b/cps/gdriveutils.py @@ -20,6 +20,8 @@ from __future__ import division, print_function, unicode_literals import os import json import shutil +import chardet +import ssl from flask import Response, stream_with_context from sqlalchemy import create_engine From 9130aceb5a6e90fd4417ba1c631e0fcda883b223 Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Fri, 11 Dec 2020 20:55:09 +0100 Subject: [PATCH 3/4] Changed admin page --- cps/static/css/style.css | 1 + cps/templates/admin.html | 43 ++++++++++++--------- cps/templates/stats.html | 2 +- cps/translations/de/LC_MESSAGES/messages.po | 2 +- 4 files changed, 28 insertions(+), 20 deletions(-) diff --git a/cps/static/css/style.css b/cps/static/css/style.css index 3d6256b2..47b0c4cb 100644 --- a/cps/static/css/style.css +++ b/cps/static/css/style.css @@ -318,6 +318,7 @@ input.pill:not(:checked) + label .glyphicon { display: none; } .editable-submit { margin-bottom: 0px !important; } .filterheader { margin-bottom: 20px; } .errorlink { margin-top: 20px; } +.emailconfig { margin-top: 10px; } .modal-body .comments { max-height: 300px; diff --git a/cps/templates/admin.html b/cps/templates/admin.html index e014935b..3fa86722 100644 --- a/cps/templates/admin.html +++ b/cps/templates/admin.html @@ -51,23 +51,31 @@

{{_('E-mail Server Settings')}}

- - - - - - - - - - - - - - - -
{{_('SMTP Hostname')}}{{_('SMTP Port')}}{{_('Encryption')}}{{_('SMTP Login')}}
{{email.mail_server}}{{email.mail_port}}{% if email.mail_use_ssl %}{% else %}{% endif %}{{email.mail_login}}
- + {% if config.get_mail_server_configured() %} +
+
+
{{_('SMTP Hostname')}}
+
{{email.mail_server}}
+
+
+
{{_('SMTP Port')}}
+
{{email.mail_port}}
+
+
+
{{_('Encryption')}}
+
{{ display_bool_setting(email.mail_use_ssl) }}
+
+
+
{{_('SMTP Login')}}
+
{{email.mail_login}}
+
+
+
{{_('From E-mail')}}
+
{{email.mail_from}}
+
+
+ {% endif %} +
@@ -140,7 +148,6 @@
{{_('Reconnect Calibre Database')}}
{{_('Restart')}}
{{_('Shutdown')}}
-
diff --git a/cps/templates/stats.html b/cps/templates/stats.html index 966abf2a..052c920a 100644 --- a/cps/templates/stats.html +++ b/cps/templates/stats.html @@ -26,7 +26,7 @@ {% if g.user.role_admin() %} -

{{_('Linked Libraries')}}

+

{{_('System Statistics')}}

diff --git a/cps/translations/de/LC_MESSAGES/messages.po b/cps/translations/de/LC_MESSAGES/messages.po index 07c41adf..bb41c493 100644 --- a/cps/translations/de/LC_MESSAGES/messages.po +++ b/cps/translations/de/LC_MESSAGES/messages.po @@ -1251,7 +1251,7 @@ msgstr "Bücher pro Seite" #: cps/templates/admin.html:104 msgid "Uploads" -msgstr "Lade hoch" +msgstr "Hochladen" #: cps/templates/admin.html:108 msgid "Anonymous Browsing" From f4412ee96bca31b2dc481ddbf56fb5189dd73a75 Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Sat, 12 Dec 2020 06:41:12 +0100 Subject: [PATCH 4/4] Fix #1753 (errorhandling on route serve_book) --- cps/web.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cps/web.py b/cps/web.py index f41c3e0d..1d37ce50 100644 --- a/cps/web.py +++ b/cps/web.py @@ -1479,7 +1479,9 @@ def get_robots(): def serve_book(book_id, book_format, anyname): book_format = book_format.split(".")[0] book = calibre_db.get_book(book_id) - data = calibre_db.get_book_format(book.id, book_format.upper()) + data = calibre_db.get_book_format(book_id, book_format.upper()) + if not data: + abort(404) log.info('Serving book: %s', data.name) if config.config_use_google_drive: headers = Headers() @@ -1490,6 +1492,7 @@ def serve_book(book_id, book_format, anyname): return send_from_directory(os.path.join(config.config_calibre_dir, book.path), data.name + "." + book_format) + @web.route("/download//", defaults={'anyname': 'None'}) @web.route("/download///") @login_required_if_no_ano