Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
douban-api-proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
douban-api-proxy
Commits
46b87dc7
Commit
46b87dc7
authored
Mar 09, 2020
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for testability of kobo
parent
5ba4801a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
4 deletions
+14
-4
kobo.py
cps/kobo.py
+14
-4
No files found.
cps/kobo.py
View file @
46b87dc7
...
...
@@ -214,9 +214,13 @@ def HandleMetadataRequest(book_uuid):
def
get_download_url_for_book
(
book
,
book_format
):
if
not
current_app
.
wsgi_app
.
is_proxied
:
if
':'
in
request
.
host
and
not
request
.
host
.
endswith
(
']'
)
:
host
=
""
.
join
(
request
.
host
.
split
(
':'
)[:
-
1
])
else
:
host
=
request
.
host
return
"{url_scheme}://{url_base}:{url_port}/download/{book_id}/{book_format}"
.
format
(
url_scheme
=
request
.
scheme
,
url_base
=
request
.
host
,
url_base
=
host
,
url_port
=
config
.
config_port
,
book_id
=
book
.
id
,
book_format
=
book_format
.
lower
()
...
...
@@ -352,15 +356,17 @@ def reading_state(book):
@
kobo
.
route
(
"/<book_uuid>/image.jpg"
)
@
requires_kobo_auth
def
HandleCoverImageRequest
(
book_uuid
):
log
.
debug
(
"Cover request received for book
%
s"
%
book_uuid
)
book_cover
=
helper
.
get_book_cover_with_uuid
(
book_uuid
,
use_generic_cover_on_failure
=
False
)
if
not
book_cover
:
if
config
.
config_kobo_proxy
:
log
.
debug
(
"Cover for unknown book:
%
s proxied to kobo"
%
book_uuid
)
return
redirect
(
get_store_url_for_current_request
(),
307
)
else
:
abort
(
404
)
log
.
debug
(
"Cover for unknown book:
%
s requested"
%
book_uuid
)
return
redirect_or_proxy_request
()
log
.
debug
(
"Cover request received for book
%
s"
%
book_uuid
)
return
book_cover
...
...
@@ -456,9 +462,13 @@ def HandleInitRequest():
if
not
current_app
.
wsgi_app
.
is_proxied
:
log
.
debug
(
'Kobo: Received unproxied request, changed request port to server port'
)
if
':'
in
request
.
host
and
not
request
.
host
.
endswith
(
']'
):
host
=
""
.
join
(
request
.
host
.
split
(
':'
)[:
-
1
])
else
:
host
=
request
.
host
calibre_web_url
=
"{url_scheme}://{url_base}:{url_port}"
.
format
(
url_scheme
=
request
.
scheme
,
url_base
=
request
.
host
,
url_base
=
host
,
url_port
=
config
.
config_port
)
else
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment