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
395c6679
Commit
395c6679
authored
Mar 29, 2017
by
OzzieIsaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #163
parent
ebb3acec
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
12 deletions
+9
-12
web.py
cps/web.py
+9
-12
No files found.
cps/web.py
View file @
395c6679
...
...
@@ -32,6 +32,7 @@ from flask_babel import gettext as _
import requests
import zipfile
from werkzeug.security import generate_password_hash, check_password_hash
from werkzeug.datastructures import Headers
from babel import Locale as LC
from babel import negotiate_locale
from babel import __version__ as babelVersion
...
...
@@ -52,12 +53,9 @@ import db
from shutil import move, copyfile
from tornado.ioloop import IOLoop
import shutil
import
StringIO
import gdriveutils
import tempfile
import
io
import hashlib
import
threading
from tornado import version as tornadoVersion
...
...
@@ -81,7 +79,6 @@ try:
use_generic_pdf_cover = False
except ImportError:
use_generic_pdf_cover = True
from
cgi
import
escape
# Global variables
gdrive_watch_callback_token='target=calibreweb-watch_files'
...
...
@@ -825,18 +822,18 @@ def get_opds_download_link(book_id, format):
if len(book.authors) > 0:
file_name = book.authors[0].name + '_' + file_name
file_name = helper.get_valid_filename(file_name)
headers
=
{}
headers
= Headers ()
headers["Content-Disposition"] = "attachment; filename*=UTF-8''%s.%s" % (quote(file_name.encode('utf8')), format)
app.logger.info (time.time()-startTime)
startTime=time.time()
if config.config_use_google_drive:
app.logger.info(time.time() - startTime)
df=gdriveutils.getFileFromEbooksFolder(Gdrive.Instance().drive, book.path, data.name + "." + format)
return do_gdrive_download(df, headers)
else:
# file_name = helper.get_valid_filename(file_name)
response = make_response(send_from_directory(os.path.join(config.config_calibre_dir, book.path), data.name + "." + format))
response
.
headers
[
"Content-Disposition"
]
=
"attachment; filename*=UTF-8''
%
s.
%
s"
%
(
quote
(
file_name
.
encode
(
'utf8'
)),
format
)
return
response
response.headers=headers
return response
@app.route("/ajax/book/<string:uuid>")
...
...
@@ -1388,7 +1385,7 @@ def shutdown():
def update():
helper.updater_thread = helper.Updater()
flash(_(u"Update done"), category="info")
return
""
return
abort(404)
@app.route("/search", methods=["GET"])
...
...
@@ -1639,7 +1636,7 @@ def get_download_link(book_id, format):
if len(book.authors) > 0:
file_name = book.authors[0].name + '_' + file_name
file_name = helper.get_valid_filename(file_name)
headers
=
{}
headers
= Headers ()
try:
headers["Content-Type"] = mimetypes.types_map['.' + format]
except:
...
...
@@ -1650,8 +1647,8 @@ def get_download_link(book_id, format):
return do_gdrive_download(df, headers)
else:
response = make_response(send_from_directory(os.path.join(config.config_calibre_dir, book.path), data.name + "." + format))
response
.
headers
[
"Content-Disposition"
]
=
"attachment; filename*=UTF-8''
%
s.
%
s"
%
(
quote
(
file_name
.
encode
(
'utf-8'
)),
format
)
return
response
response.headers=headers
return response
else:
abort(404)
...
...
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