1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-12-26 10:00:37 +00:00

When serving a download URL via KoboSync, use a URL that is specific to Kobo

This commit is contained in:
Julian Naydichev 2020-10-31 14:50:08 +01:00
parent 5701e08db9
commit ae33aee3f6

View File

@ -47,9 +47,10 @@ from sqlalchemy.exc import StatementError
import requests import requests
from . import config, logger, kobo_auth, db, calibre_db, helper, shelf as shelf_lib, ub from . import config, logger, kobo_auth, db, calibre_db, helper, shelf as shelf_lib, ub
from .helper import get_download_link
from .services import SyncToken as SyncToken from .services import SyncToken as SyncToken
from .web import download_required from .web import download_required
from .kobo_auth import requires_kobo_auth from .kobo_auth import requires_kobo_auth, get_auth_token
KOBO_FORMATS = {"KEPUB": ["KEPUB"], "EPUB": ["EPUB3", "EPUB"]} KOBO_FORMATS = {"KEPUB": ["KEPUB"], "EPUB": ["EPUB3", "EPUB"]}
KOBO_STOREAPI_URL = "https://storeapi.kobo.com" KOBO_STOREAPI_URL = "https://storeapi.kobo.com"
@ -270,10 +271,11 @@ def get_download_url_for_book(book, book_format):
else: else:
host = request.host host = request.host
return "{url_scheme}://{url_base}:{url_port}/download/{book_id}/{book_format}".format( return "{url_scheme}://{url_base}:{url_port}/kobo/{auth_token}/download/{book_id}/{book_format}".format(
url_scheme=request.scheme, url_scheme=request.scheme,
url_base=host, url_base=host,
url_port=config.config_external_port, url_port=config.config_external_port,
auth_token=get_auth_token(),
book_id=book.id, book_id=book.id,
book_format=book_format.lower() book_format=book_format.lower()
) )
@ -976,6 +978,14 @@ def HandleInitRequest():
return response return response
@kobo.route("/download/<book_id>/<book_format>")
@requires_kobo_auth
@download_required
def download_book(book_id, book_format):
return get_download_link(book_id, book_format, "kobo")
def NATIVE_KOBO_RESOURCES(): def NATIVE_KOBO_RESOURCES():
return { return {
"account_page": "https://secure.kobobooks.com/profile", "account_page": "https://secure.kobobooks.com/profile",