mirror of
https://github.com/janeczku/calibre-web
synced 2024-11-28 12:30:00 +00:00
Support Epub downloads
This commit is contained in:
parent
c238367b64
commit
d81dbb13e4
25
cps/kobo.py
25
cps/kobo.py
@ -43,8 +43,7 @@ import requests
|
|||||||
from . import config, logger, kobo_auth, db, helper
|
from . import config, logger, kobo_auth, db, helper
|
||||||
from .web import download_required
|
from .web import download_required
|
||||||
|
|
||||||
# TODO: Test more formats :) .
|
KOBO_FORMATS = {"KEPUB": ["KEPUB"], "EPUB": ["EPUB", "EPUB3"]}
|
||||||
KOBO_SUPPORTED_FORMATS = {"KEPUB"}
|
|
||||||
KOBO_STOREAPI_URL = "https://storeapi.kobo.com"
|
KOBO_STOREAPI_URL = "https://storeapi.kobo.com"
|
||||||
|
|
||||||
kobo = Blueprint("kobo", __name__, url_prefix="/kobo/<auth_token>")
|
kobo = Blueprint("kobo", __name__, url_prefix="/kobo/<auth_token>")
|
||||||
@ -238,7 +237,7 @@ def HandleSyncRequest():
|
|||||||
db.session.query(db.Books)
|
db.session.query(db.Books)
|
||||||
.join(db.Data)
|
.join(db.Data)
|
||||||
.filter(func.datetime(db.Books.last_modified) > sync_token.books_last_modified)
|
.filter(func.datetime(db.Books.last_modified) > sync_token.books_last_modified)
|
||||||
.filter(db.Data.format.in_(KOBO_SUPPORTED_FORMATS))
|
.filter(db.Data.format.in_(KOBO_FORMATS))
|
||||||
.all()
|
.all()
|
||||||
)
|
)
|
||||||
for book in changed_entries:
|
for book in changed_entries:
|
||||||
@ -374,14 +373,17 @@ def get_metadata(book):
|
|||||||
download_urls = []
|
download_urls = []
|
||||||
|
|
||||||
for book_data in book.data:
|
for book_data in book.data:
|
||||||
if book_data.format in KOBO_SUPPORTED_FORMATS:
|
if book_data.format not in KOBO_FORMATS:
|
||||||
|
continue
|
||||||
|
for kobo_format in KOBO_FORMATS[book_data.format]:
|
||||||
download_urls.append(
|
download_urls.append(
|
||||||
{
|
{
|
||||||
"Format": book_data.format,
|
"Format": kobo_format,
|
||||||
"Size": book_data.uncompressed_size,
|
"Size": book_data.uncompressed_size,
|
||||||
"Url": get_download_url_for_book(book, book_data.format),
|
"Url": get_download_url_for_book(book, book_data.format),
|
||||||
|
# The Kobo forma accepts platforms: (Generic, Android)
|
||||||
|
"Platform": "Generic",
|
||||||
# "DrmType": "None", # Not required
|
# "DrmType": "None", # Not required
|
||||||
"Platform": "Android", # Required field.
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -404,7 +406,7 @@ def get_metadata(book):
|
|||||||
"IsSocialEnabled": True,
|
"IsSocialEnabled": True,
|
||||||
"Language": "en",
|
"Language": "en",
|
||||||
"PhoneticPronunciations": {},
|
"PhoneticPronunciations": {},
|
||||||
"PublicationDate": "2019-02-03T00:25:03.0000000Z", # current_time(),
|
"PublicationDate": book.pubdate,
|
||||||
"Publisher": {"Imprint": "", "Name": get_publisher(book),},
|
"Publisher": {"Imprint": "", "Name": get_publisher(book),},
|
||||||
"RevisionId": book_uuid,
|
"RevisionId": book_uuid,
|
||||||
"Title": book.title,
|
"Title": book.title,
|
||||||
@ -490,7 +492,12 @@ def HandleInitRequest():
|
|||||||
|
|
||||||
calibre_web_url = url_for("web.index", _external=True).strip("/")
|
calibre_web_url = url_for("web.index", _external=True).strip("/")
|
||||||
kobo_resources["image_host"] = calibre_web_url
|
kobo_resources["image_host"] = calibre_web_url
|
||||||
kobo_resources["image_url_quality_template"] = calibre_web_url + "/{ImageId}/{Width}/{Height}/{Quality}/{IsGreyscale}/image.jpg"
|
kobo_resources["image_url_quality_template"] = (
|
||||||
kobo_resources["image_url_template"] = calibre_web_url + "/{ImageId}/{Width}/{Height}/false/image.jpg"
|
calibre_web_url
|
||||||
|
+ "/{ImageId}/{Width}/{Height}/{Quality}/{IsGreyscale}/image.jpg"
|
||||||
|
)
|
||||||
|
kobo_resources["image_url_template"] = (
|
||||||
|
calibre_web_url + "/{ImageId}/{Width}/{Height}/false/image.jpg"
|
||||||
|
)
|
||||||
|
|
||||||
return make_response(store_response_json, store_response.status_code)
|
return make_response(store_response_json, store_response.status_code)
|
||||||
|
Loading…
Reference in New Issue
Block a user