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
Show 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 _
...
@@ -32,6 +32,7 @@ from flask_babel import gettext as _
import
requests
import
requests
import
zipfile
import
zipfile
from
werkzeug.security
import
generate_password_hash
,
check_password_hash
from
werkzeug.security
import
generate_password_hash
,
check_password_hash
from
werkzeug.datastructures
import
Headers
from
babel
import
Locale
as
LC
from
babel
import
Locale
as
LC
from
babel
import
negotiate_locale
from
babel
import
negotiate_locale
from
babel
import
__version__
as
babelVersion
from
babel
import
__version__
as
babelVersion
...
@@ -52,12 +53,9 @@ import db
...
@@ -52,12 +53,9 @@ import db
from
shutil
import
move
,
copyfile
from
shutil
import
move
,
copyfile
from
tornado.ioloop
import
IOLoop
from
tornado.ioloop
import
IOLoop
import
shutil
import
shutil
import
StringIO
import
gdriveutils
import
gdriveutils
import
tempfile
import
tempfile
import
io
import
hashlib
import
hashlib
import
threading
from
tornado
import
version
as
tornadoVersion
from
tornado
import
version
as
tornadoVersion
...
@@ -81,7 +79,6 @@ try:
...
@@ -81,7 +79,6 @@ try:
use_generic_pdf_cover
=
False
use_generic_pdf_cover
=
False
except
ImportError
:
except
ImportError
:
use_generic_pdf_cover
=
True
use_generic_pdf_cover
=
True
from
cgi
import
escape
# Global variables
# Global variables
gdrive_watch_callback_token
=
'target=calibreweb-watch_files'
gdrive_watch_callback_token
=
'target=calibreweb-watch_files'
...
@@ -825,17 +822,17 @@ def get_opds_download_link(book_id, format):
...
@@ -825,17 +822,17 @@ def get_opds_download_link(book_id, format):
if
len
(
book
.
authors
)
>
0
:
if
len
(
book
.
authors
)
>
0
:
file_name
=
book
.
authors
[
0
]
.
name
+
'_'
+
file_name
file_name
=
book
.
authors
[
0
]
.
name
+
'_'
+
file_name
file_name
=
helper
.
get_valid_filename
(
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
)
headers
[
"Content-Disposition"
]
=
"attachment; filename*=UTF-8''
%
s.
%
s"
%
(
quote
(
file_name
.
encode
(
'utf8'
)),
format
)
app
.
logger
.
info
(
time
.
time
()
-
startTime
)
app
.
logger
.
info
(
time
.
time
()
-
startTime
)
startTime
=
time
.
time
()
startTime
=
time
.
time
()
if
config
.
config_use_google_drive
:
if
config
.
config_use_google_drive
:
app
.
logger
.
info
(
time
.
time
()
-
startTime
)
df
=
gdriveutils
.
getFileFromEbooksFolder
(
Gdrive
.
Instance
()
.
drive
,
book
.
path
,
data
.
name
+
"."
+
format
)
df
=
gdriveutils
.
getFileFromEbooksFolder
(
Gdrive
.
Instance
()
.
drive
,
book
.
path
,
data
.
name
+
"."
+
format
)
return
do_gdrive_download
(
df
,
headers
)
return
do_gdrive_download
(
df
,
headers
)
else
:
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
=
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
)
response
.
headers
=
headers
return
response
return
response
...
@@ -1388,7 +1385,7 @@ def shutdown():
...
@@ -1388,7 +1385,7 @@ def shutdown():
def
update
():
def
update
():
helper
.
updater_thread
=
helper
.
Updater
()
helper
.
updater_thread
=
helper
.
Updater
()
flash
(
_
(
u"Update done"
),
category
=
"info"
)
flash
(
_
(
u"Update done"
),
category
=
"info"
)
return
""
return
abort
(
404
)
@
app
.
route
(
"/search"
,
methods
=
[
"GET"
])
@
app
.
route
(
"/search"
,
methods
=
[
"GET"
])
...
@@ -1639,7 +1636,7 @@ def get_download_link(book_id, format):
...
@@ -1639,7 +1636,7 @@ def get_download_link(book_id, format):
if
len
(
book
.
authors
)
>
0
:
if
len
(
book
.
authors
)
>
0
:
file_name
=
book
.
authors
[
0
]
.
name
+
'_'
+
file_name
file_name
=
book
.
authors
[
0
]
.
name
+
'_'
+
file_name
file_name
=
helper
.
get_valid_filename
(
file_name
)
file_name
=
helper
.
get_valid_filename
(
file_name
)
headers
=
{}
headers
=
Headers
()
try
:
try
:
headers
[
"Content-Type"
]
=
mimetypes
.
types_map
[
'.'
+
format
]
headers
[
"Content-Type"
]
=
mimetypes
.
types_map
[
'.'
+
format
]
except
:
except
:
...
@@ -1650,7 +1647,7 @@ def get_download_link(book_id, format):
...
@@ -1650,7 +1647,7 @@ def get_download_link(book_id, format):
return
do_gdrive_download
(
df
,
headers
)
return
do_gdrive_download
(
df
,
headers
)
else
:
else
:
response
=
make_response
(
send_from_directory
(
os
.
path
.
join
(
config
.
config_calibre_dir
,
book
.
path
),
data
.
name
+
"."
+
format
))
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
)
response
.
headers
=
headers
return
response
return
response
else
:
else
:
abort
(
404
)
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