Fix for #1227 (Download books not possible with gevent IPV6 connection)
Fix issue where books aren't correctly ordered by Date Added
This commit is contained in:
commit
202b6121ab
31
cps/kobo.py
31
cps/kobo.py
@ -21,6 +21,7 @@ import sys
|
||||
import base64
|
||||
import os
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
from time import gmtime, strftime
|
||||
try:
|
||||
from urllib import unquote
|
||||
@ -213,13 +214,22 @@ def HandleMetadataRequest(book_uuid):
|
||||
|
||||
def get_download_url_for_book(book, book_format):
|
||||
if not current_app.wsgi_app.is_proxied:
|
||||
return "{url_scheme}://{url_base}:{url_port}/download/{book_id}/{book_format}".format(
|
||||
url_scheme=request.environ['wsgi.url_scheme'],
|
||||
url_base=request.environ['SERVER_NAME'],
|
||||
url_port=config.config_port,
|
||||
book_id=book.id,
|
||||
book_format=book_format.lower()
|
||||
)
|
||||
if request.environ['SERVER_NAME'] != '::':
|
||||
return "{url_scheme}://{url_base}:{url_port}/download/{book_id}/{book_format}".format(
|
||||
url_scheme=request.environ['wsgi.url_scheme'],
|
||||
url_base=request.environ['SERVER_NAME'],
|
||||
url_port=config.config_port,
|
||||
book_id=book.id,
|
||||
book_format=book_format.lower()
|
||||
)
|
||||
else:
|
||||
return "{url_scheme}://{url_base}:{url_port}/download/{book_id}/{book_format}".format(
|
||||
url_scheme=request.environ['wsgi.url_scheme'],
|
||||
url_base=request.host, # ToDo: both server ??
|
||||
url_port=config.config_port,
|
||||
book_id=book.id,
|
||||
book_format=book_format.lower()
|
||||
)
|
||||
else:
|
||||
return url_for(
|
||||
"web.download_link",
|
||||
@ -234,14 +244,14 @@ def create_book_entitlement(book):
|
||||
return {
|
||||
"Accessibility": "Full",
|
||||
"ActivePeriod": {"From": current_time(),},
|
||||
"Created": book.timestamp,
|
||||
"Created": book.timestamp.strftime("%Y-%m-%dT%H:%M:%SZ"),
|
||||
"CrossRevisionId": book_uuid,
|
||||
"Id": book_uuid,
|
||||
"IsHiddenFromArchive": False,
|
||||
"IsLocked": False,
|
||||
# Setting this to true removes from the device.
|
||||
"IsRemoved": False,
|
||||
"LastModified": book.last_modified,
|
||||
"LastModified": book.last_modified.strftime("%Y-%m-%dT%H:%M:%SZ"),
|
||||
"OriginCategory": "Imported",
|
||||
"RevisionId": book_uuid,
|
||||
"Status": "Active",
|
||||
@ -376,7 +386,7 @@ def TopLevelEndpoint():
|
||||
@kobo.route("/v1/library/tags/<shelf_name>", methods=["POST"])
|
||||
@kobo.route("/v1/library/tags/<tag_id>", methods=["DELETE"])
|
||||
def HandleUnimplementedRequest(dummy=None, book_uuid=None, shelf_name=None, tag_id=None):
|
||||
log.debug("Alternative Request received:")
|
||||
log.debug("Unimplemented Library Request received: %s", request.base_url)
|
||||
return redirect_or_proxy_request()
|
||||
|
||||
|
||||
@ -397,6 +407,7 @@ def HandleUserRequest(dummy=None):
|
||||
@kobo.route("/v1/products/<dummy>/reviews", methods=["GET", "POST"])
|
||||
@kobo.route("/v1/products/books/<dummy>", methods=["GET", "POST"])
|
||||
@kobo.route("/v1/products/dailydeal", methods=["GET", "POST"])
|
||||
@kobo.route("/v1/products", methods=["GET", "POST"])
|
||||
def HandleProductsRequest(dummy=None):
|
||||
log.debug("Unimplemented Products Request received: %s", request.base_url)
|
||||
return redirect_or_proxy_request()
|
||||
|
Loading…
Reference in New Issue
Block a user