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
699bd036
Commit
699bd036
authored
Apr 04, 2017
by
OzzieIsaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code cosmetics
parent
dc45b53b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
15 deletions
+9
-15
gdriveutils.py
cps/gdriveutils.py
+2
-2
helper.py
cps/helper.py
+3
-3
main.js
cps/static/js/main.js
+1
-1
web.py
cps/web.py
+3
-9
No files found.
cps/gdriveutils.py
View file @
699bd036
...
@@ -201,7 +201,7 @@ def backupCalibreDbAndOptionalDownload(drive, f=None):
...
@@ -201,7 +201,7 @@ def backupCalibreDbAndOptionalDownload(drive, f=None):
metaDataFile
=
"'
%
s' in parents and title = 'metadata.db' and trashed = false"
%
getEbooksFolderId
()
metaDataFile
=
"'
%
s' in parents and title = 'metadata.db' and trashed = false"
%
getEbooksFolderId
()
fileList
=
drive
.
ListFile
({
'q'
:
metaDataFile
})
.
GetList
()
fileList
=
drive
.
ListFile
({
'q'
:
metaDataFile
})
.
GetList
()
databaseFile
=
fileList
[
0
]
databaseFile
=
fileList
[
0
]
if
f
:
if
f
:
...
@@ -353,7 +353,7 @@ def getChangeById (drive, change_id):
...
@@ -353,7 +353,7 @@ def getChangeById (drive, change_id):
if
not
drive
:
if
not
drive
:
drive
=
getDrive
()
drive
=
getDrive
()
if
drive
.
auth
.
access_token_expired
:
if
drive
.
auth
.
access_token_expired
:
drive
.
auth
.
Refresh
()
drive
.
auth
.
Refresh
()
# Print a single Change resource information.
# Print a single Change resource information.
#
#
# Args:
# Args:
...
...
cps/helper.py
View file @
699bd036
...
@@ -81,7 +81,7 @@ def make_mobi(book_id, calibrepath):
...
@@ -81,7 +81,7 @@ def make_mobi(book_id, calibrepath):
file_path
=
os
.
path
.
join
(
calibrepath
,
book
.
path
,
data
.
name
)
file_path
=
os
.
path
.
join
(
calibrepath
,
book
.
path
,
data
.
name
)
if
os
.
path
.
exists
(
file_path
+
u".epub"
):
if
os
.
path
.
exists
(
file_path
+
u".epub"
):
p
=
subprocess
.
Popen
((
kindlegen
+
"
\"
"
+
file_path
+
u".epub
\"
"
)
.
encode
(
sys
.
getfilesystemencoding
()),
p
=
subprocess
.
Popen
((
kindlegen
+
"
\"
"
+
file_path
+
u".epub
\"
"
)
.
encode
(
sys
.
getfilesystemencoding
()),
s
hell
=
True
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
stdin
=
subprocess
.
PIPE
)
s
tdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
# Poll process for new output until finished
# Poll process for new output until finished
while
True
:
while
True
:
nextline
=
p
.
stdout
.
readline
()
nextline
=
p
.
stdout
.
readline
()
...
@@ -252,7 +252,7 @@ def get_valid_filename(value, replace_whitespace=True):
...
@@ -252,7 +252,7 @@ def get_valid_filename(value, replace_whitespace=True):
value
=
value
.
replace
(
u'ß'
,
u'ss'
)
value
=
value
.
replace
(
u'ß'
,
u'ss'
)
value
=
unicodedata
.
normalize
(
'NFKD'
,
value
)
value
=
unicodedata
.
normalize
(
'NFKD'
,
value
)
re_slugify
=
re
.
compile
(
'[
\
W
\
s-]'
,
re
.
UNICODE
)
re_slugify
=
re
.
compile
(
'[
\
W
\
s-]'
,
re
.
UNICODE
)
if
type
(
value
)
is
str
:
#Python3 str, Python2 unicode
if
isinstance
(
value
,
str
)
:
#Python3 str, Python2 unicode
value
=
re_slugify
.
sub
(
''
,
value
)
.
strip
()
value
=
re_slugify
.
sub
(
''
,
value
)
.
strip
()
else
:
else
:
value
=
unicode
(
re_slugify
.
sub
(
''
,
value
)
.
strip
())
value
=
unicode
(
re_slugify
.
sub
(
''
,
value
)
.
strip
())
...
@@ -300,7 +300,7 @@ def update_dir_stucture(book_id, calibrepath):
...
@@ -300,7 +300,7 @@ def update_dir_stucture(book_id, calibrepath):
def
update_dir_structure_gdrive
(
book_id
):
def
update_dir_structure_gdrive
(
book_id
):
db
.
session
.
connection
()
.
connection
.
connection
.
create_function
(
"title_sort"
,
1
,
db
.
title_sort
)
db
.
session
.
connection
()
.
connection
.
connection
.
create_function
(
"title_sort"
,
1
,
db
.
title_sort
)
book
=
db
.
session
.
query
(
db
.
Books
)
.
filter
(
db
.
Books
.
id
==
book_id
)
.
first
()
book
=
db
.
session
.
query
(
db
.
Books
)
.
filter
(
db
.
Books
.
id
==
book_id
)
.
first
()
authordir
=
book
.
path
.
split
(
'/'
)[
0
]
authordir
=
book
.
path
.
split
(
'/'
)[
0
]
new_authordir
=
get_valid_filename
(
book
.
authors
[
0
]
.
name
)
new_authordir
=
get_valid_filename
(
book
.
authors
[
0
]
.
name
)
titledir
=
book
.
path
.
split
(
'/'
)[
1
]
titledir
=
book
.
path
.
split
(
'/'
)[
1
]
...
...
cps/static/js/main.js
View file @
699bd036
...
@@ -13,7 +13,7 @@ $(function() {
...
@@ -13,7 +13,7 @@ $(function() {
$
.
ajax
({
$
.
ajax
({
dataType
:
"json"
,
dataType
:
"json"
,
url
:
window
.
location
.
pathname
+
"/../../get_updater_status"
,
url
:
window
.
location
.
pathname
+
"/../../get_updater_status"
,
success
:
function
(
data
)
{
success
(
data
)
{
// console.log(data.status);
// console.log(data.status);
$
(
"#UpdateprogressDialog #Updatecontent"
).
html
(
updateText
[
data
.
status
]);
$
(
"#UpdateprogressDialog #Updatecontent"
).
html
(
updateText
[
data
.
status
]);
if
(
data
.
status
>
6
){
if
(
data
.
status
>
6
){
...
...
cps/web.py
View file @
699bd036
...
@@ -272,14 +272,9 @@ def load_user_from_header(header_val):
...
@@ -272,14 +272,9 @@ def load_user_from_header(header_val):
return
user
return
user
return
return
def
check_auth
(
username
,
password
):
def
check_auth
(
username
,
password
):
user
=
ub
.
session
.
query
(
ub
.
User
)
.
filter
(
ub
.
User
.
nickname
==
username
)
.
first
()
user
=
ub
.
session
.
query
(
ub
.
User
)
.
filter
(
ub
.
User
.
nickname
==
username
)
.
first
()
if
user
and
check_password_hash
(
user
.
password
,
password
):
return
bool
(
user
and
check_password_hash
(
user
.
password
,
password
))
return
True
else
:
return
False
def
authenticate
():
def
authenticate
():
return
Response
(
return
Response
(
...
@@ -1239,11 +1234,10 @@ def stats():
...
@@ -1239,11 +1234,10 @@ def stats():
kindlegen
=
os
.
path
.
join
(
vendorpath
,
u"kindlegen"
)
kindlegen
=
os
.
path
.
join
(
vendorpath
,
u"kindlegen"
)
versions
[
'KindlegenVersion'
]
=
_
(
'not installed'
)
versions
[
'KindlegenVersion'
]
=
_
(
'not installed'
)
if
os
.
path
.
exists
(
kindlegen
):
if
os
.
path
.
exists
(
kindlegen
):
p
=
subprocess
.
Popen
(
kindlegen
,
shell
=
False
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
p
=
subprocess
.
Popen
(
kindlegen
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
stdin
=
subprocess
.
PIPE
)
p
.
wait
()
p
.
wait
()
for
lines
in
p
.
stdout
.
readlines
():
for
lines
in
p
.
stdout
.
readlines
():
if
type
(
lines
)
is
bytes
:
if
isinstance
(
lines
,
bytes
)
:
lines
=
lines
.
decode
(
'utf-8'
)
lines
=
lines
.
decode
(
'utf-8'
)
if
re
.
search
(
'Amazon kindlegen
\
('
,
lines
):
if
re
.
search
(
'Amazon kindlegen
\
('
,
lines
):
versions
[
'KindlegenVersion'
]
=
lines
versions
[
'KindlegenVersion'
]
=
lines
...
...
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