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
e3e26d41
Commit
e3e26d41
authored
Mar 06, 2017
by
Jack Darlington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finished code to chunk successfully.
parent
10b129cb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
7 deletions
+4
-7
web.py
cps/web.py
+4
-7
No files found.
cps/web.py
View file @
e3e26d41
...
...
@@ -7,7 +7,8 @@ import logging
from
logging.handlers
import
RotatingFileHandler
import
textwrap
from
flask
import
Flask
,
render_template
,
session
,
request
,
Response
,
redirect
,
url_for
,
send_from_directory
,
\
make_response
,
g
,
flash
,
abort
,
send_file
,
Markup
make_response
,
g
,
flash
,
abort
,
send_file
,
Markup
,
\
stream_with_context
from
flask
import
__version__
as
flaskVersion
import
ub
from
ub
import
config
...
...
@@ -767,7 +768,7 @@ def do_gdrive_download(df, headers):
app
.
logger
.
info
(
total_size
)
download_url
=
df
.
metadata
.
get
(
'downloadUrl'
)
app
.
logger
.
info
(
time
.
time
()
-
startTime
)
s
=
partial
(
total_size
,
1024
*
10
0
)
# I'm downloading BIG files, so 100M chunk size is fine for me
s
=
partial
(
total_size
,
1024
*
10
24
)
# I'm downloading BIG files, so 100M chunk size is fine for me
def
stream
():
for
bytes
in
s
:
headers
=
{
"Range"
:
'bytes=
%
s-
%
s'
%
(
bytes
[
0
],
bytes
[
1
])}
...
...
@@ -777,11 +778,7 @@ def do_gdrive_download(df, headers):
else
:
app
.
logger
.
info
(
'An error occurred:
%
s'
%
resp
)
return
app
.
logger
.
info
(
str
(
bytes
[
1
])
+
"..."
)
app
.
logger
.
info
(
time
.
time
()
-
startTime
)
return
Response
(
stream
(),
headers
=
headers
)
return
Response
(
stream_with_context
(
stream
()),
headers
=
headers
)
@
app
.
route
(
"/opds/download/<book_id>/<format>/"
)
@
requires_basic_auth_if_no_ano
...
...
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