From bdf6052388ede46c99b9cc8bec57f93382881fb0 Mon Sep 17 00:00:00 2001 From: norangebit Date: Thu, 3 Sep 2020 21:57:14 +0200 Subject: [PATCH] Conversion to kepub when creating a sync token --- cps/kobo_auth.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cps/kobo_auth.py b/cps/kobo_auth.py index 0f6cd174..f21d1cb6 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 current_user, login_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 .web 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"),