diff --git a/cps/kobo.py b/cps/kobo.py index 39032f3b..d019e918 100644 --- a/cps/kobo.py +++ b/cps/kobo.py @@ -176,6 +176,10 @@ def HandleSyncRequest(): reading_states_in_new_entitlements = [] for book in changed_entries: + formats = [data.format for data in book.Books.data] + if not 'KEPUB' in formats and config.config_kepubifypath and 'EPUB' in formats: + helper.convert_book_format(book.Books.id, config.config_calibre_dir, 'EPUB', 'KEPUB', current_user.nickname) + kobo_reading_state = get_or_create_reading_state(book.Books.id) entitlement = { "BookEntitlement": create_book_entitlement(book.Books, archived=(book.is_archived == True)), @@ -1004,7 +1008,6 @@ def HandleInitRequest(): @requires_kobo_auth @download_required def download_book(book_id, book_format): - return get_download_link(book_id, book_format, "kobo") diff --git a/cps/kobo_auth.py b/cps/kobo_auth.py index 1ede03a4..8f18db49 100644 --- a/cps/kobo_auth.py +++ b/cps/kobo_auth.py @@ -64,10 +64,10 @@ from datetime import datetime from os import urandom from flask import g, Blueprint, url_for, abort, request -from flask_login import login_user, login_required +from flask_login import login_user, current_user, login_required from flask_babel import gettext as _ -from . import logger, ub, lm +from . import logger, config, calibre_db, db, helper, ub, lm from .render_template import render_title_template try: @@ -148,6 +148,14 @@ def generate_auth_token(user_id): ub.session.add(auth_token) ub.session_commit() + + books = calibre_db.session.query(db.Books).join(db.Data).all() + + for book in books: + formats = [data.format for data in book.data] + if not 'KEPUB' in formats and config.config_kepubifypath and 'EPUB' in formats: + helper.convert_book_format(book.id, config.config_calibre_dir, 'EPUB', 'KEPUB', current_user.nickname) + return render_title_template( "generate_kobo_auth_url.html", title=_(u"Kobo Setup"),