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
74e93e1c
Commit
74e93e1c
authored
Jul 09, 2017
by
OzzieIsaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code cosmetics
parent
1fdb7dc4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
48 deletions
+41
-48
helper.py
cps/helper.py
+10
-8
ub.py
cps/ub.py
+7
-11
web.py
cps/web.py
+3
-8
messages.pot
messages.pot
+21
-21
No files found.
cps/helper.py
View file @
74e93e1c
...
...
@@ -88,10 +88,10 @@ def make_mobi(book_id, calibrepath):
if
os
.
path
.
exists
(
file_path
+
u".epub"
):
try
:
p
=
subprocess
.
Popen
((
kindlegen
+
"
\"
"
+
file_path
+
u".epub
\"
"
)
.
encode
(
sys
.
getfilesystemencoding
()),
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
shell
=
True
)
except
:
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
except
Exception
:
error_message
=
_
(
u"kindlegen failed, no excecution permissions"
)
app
.
logger
.
error
(
"make_mobi: "
+
error_message
)
app
.
logger
.
error
(
"make_mobi: "
+
error_message
)
return
error_message
,
RET_FAIL
# Poll process for new output until finished
...
...
@@ -226,9 +226,11 @@ def send_mail(book_id, kindle_mail, calibrepath):
msg
.
attach
(
get_attachment
(
formats
[
'mobi'
]))
elif
'epub'
in
formats
:
data
,
resultCode
=
make_mobi
(
book
.
id
,
calibrepath
)
app
.
logger
.
error
=
(
data
)
if
resultCode
==
RET_SUCCESS
:
msg
.
attach
(
get_attachment
(
data
))
else
:
return
data
#_("Could not convert epub to mobi")
elif
'pdf'
in
formats
:
msg
.
attach
(
get_attachment
(
formats
[
'pdf'
]))
...
...
@@ -305,7 +307,7 @@ def delete_book_gdrive(book):
def
update_dir_stucture
(
book_id
,
calibrepath
):
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
()
path
=
os
.
path
.
join
(
calibrepath
,
book
.
path
)
#.replace('/',os.path.sep)).replace('\\',os.path.sep)
path
=
os
.
path
.
join
(
calibrepath
,
book
.
path
)
authordir
=
book
.
path
.
split
(
'/'
)[
0
]
new_authordir
=
get_valid_filename
(
book
.
authors
[
0
]
.
name
)
...
...
@@ -333,7 +335,7 @@ def update_dir_structure_gdrive(book_id):
new_authordir
=
get_valid_filename
(
book
.
authors
[
0
]
.
name
)
titledir
=
book
.
path
.
split
(
'/'
)[
1
]
new_titledir
=
get_valid_filename
(
book
.
title
)
+
" ("
+
str
(
book_id
)
+
")"
if
titledir
!=
new_titledir
:
print
(
titledir
)
gFile
=
gd
.
getFileFromEbooksFolder
(
web
.
Gdrive
.
Instance
()
.
drive
,
os
.
path
.
dirname
(
book
.
path
),
titledir
)
...
...
@@ -400,8 +402,8 @@ class Updater(threading.Thread):
for
file
in
delete_files
:
parts
=
file
.
split
(
os
.
sep
)
sub
=
''
for
i
in
range
(
len
(
parts
))
:
sub
=
os
.
path
.
join
(
sub
,
part
s
[
i
]
)
for
part
in
parts
:
sub
=
os
.
path
.
join
(
sub
,
part
)
if
sub
==
''
:
sub
=
os
.
sep
count
=
0
...
...
@@ -432,7 +434,7 @@ class Updater(threading.Thread):
logging
.
getLogger
(
'cps.web'
)
.
debug
(
'Update on OS-System : '
+
sys
.
platform
)
new_permissions
=
os
.
stat
(
root_dst_dir
)
# print new_permissions
for
src_dir
,
dirs
,
files
in
os
.
walk
(
root_src_dir
):
for
src_dir
,
__
,
files
in
os
.
walk
(
root_src_dir
):
dst_dir
=
src_dir
.
replace
(
root_src_dir
,
root_dst_dir
,
1
)
if
not
os
.
path
.
exists
(
dst_dir
):
os
.
makedirs
(
dst_dir
)
...
...
cps/ub.py
View file @
74e93e1c
...
...
@@ -349,13 +349,6 @@ class Config:
else
:
return
False
def
role_delete_books
(
self
):
if
self
.
config_default_role
is
not
None
:
return
True
if
self
.
config_default_role
&
ROLE_DELETE_BOOKS
==
ROLE_DELETE_BOOKS
else
False
else
:
return
False
def
role_passwd
(
self
):
if
self
.
config_default_role
is
not
None
:
return
True
if
self
.
config_default_role
&
ROLE_PASSWD
==
ROLE_PASSWD
else
False
...
...
@@ -460,13 +453,16 @@ def migrate_Database():
create
=
True
try
:
if
create
:
conn
.
execute
(
"SELET language_books FROM user"
)
conn
=
engine
.
connect
()
conn
.
execute
(
"SELECT language_books FROM user"
)
session
.
commit
()
except
exc
.
OperationalError
:
conn
=
engine
.
connect
()
conn
.
execute
(
"UPDATE user SET 'sidebar_view' = (random_books*"
+
str
(
SIDEBAR_RANDOM
)
+
"+ language_books *"
+
str
(
SIDEBAR_LANGUAGE
)
+
"+ series_books *"
+
str
(
SIDEBAR_SERIES
)
+
"+ category_books *"
+
str
(
SIDEBAR_CATEGORY
)
+
"+ hot_books *"
+
str
(
SIDEBAR_HOT
)
+
"+"
+
str
(
SIDEBAR_AUTHOR
)
+
"+"
+
str
(
DETAIL_RANDOM
)
+
")"
)
conn
.
execute
(
"UPDATE user SET 'sidebar_view' = (random_books* :side_random + language_books * :side_lang "
"+ series_books * :side_series + category_books * :side_category + hot_books * "
":side_hot + :side_autor + :detail_random)"
,{
'side_random'
:
SIDEBAR_RANDOM
,
'side_lang'
:
SIDEBAR_LANGUAGE
,
'side_series'
:
SIDEBAR_SERIES
,
'side_category'
:
SIDEBAR_CATEGORY
,
'side_hot'
:
SIDEBAR_HOT
,
'side_autor'
:
SIDEBAR_AUTHOR
,
'detail_random'
:
DETAIL_RANDOM
})
session
.
commit
()
if
session
.
query
(
User
)
.
filter
(
User
.
role
.
op
(
'&'
)(
ROLE_ANONYMOUS
)
==
ROLE_ANONYMOUS
)
.
first
()
is
None
:
create_anonymous_user
()
...
...
cps/web.py
View file @
74e93e1c
...
...
@@ -77,11 +77,6 @@ import time
current_milli_time
=
lambda
:
int
(
round
(
time
.
time
()
*
1000
))
try
:
from
wand.image
import
Image
use_generic_pdf_cover
=
False
except
ImportError
:
use_generic_pdf_cover
=
True
# Global variables
gdrive_watch_callback_token
=
'target=calibreweb-watch_files'
...
...
@@ -739,7 +734,7 @@ def feed_author(book_id):
off
=
request
.
args
.
get
(
"offset"
)
if
not
off
:
off
=
0
entries
,
random
,
pagination
=
fill_indexpage
((
int
(
off
)
/
(
int
(
config
.
config_books_per_page
))
+
1
),
entries
,
__
,
pagination
=
fill_indexpage
((
int
(
off
)
/
(
int
(
config
.
config_books_per_page
))
+
1
),
db
.
Books
,
db
.
Books
.
authors
.
any
(
db
.
Authors
.
id
==
book_id
),
db
.
Books
.
timestamp
.
desc
())
xml
=
render_title_template
(
'feed.xml'
,
entries
=
entries
,
pagination
=
pagination
)
response
=
make_response
(
xml
)
...
...
@@ -1285,8 +1280,8 @@ def stats():
lines
=
lines
.
decode
(
'utf-8'
)
if
re
.
search
(
'Amazon kindlegen
\
('
,
lines
):
versions
[
'KindlegenVersion'
]
=
lines
except
:
versions
[
'KindlegenVersion'
]
=
_
(
'Excecution permissions missing'
)
except
Exception
:
versions
[
'KindlegenVersion'
]
=
_
(
u
'Excecution permissions missing'
)
versions
[
'PythonVersion'
]
=
sys
.
version
versions
[
'babel'
]
=
babelVersion
versions
[
'sqlalchemy'
]
=
sqlalchemyVersion
...
...
messages.pot
View file @
74e93e1c
...
...
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2017-07-0
8 19:4
6+0200\n"
"POT-Creation-Date: 2017-07-0
9 19:1
6+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
...
...
@@ -31,33 +31,33 @@ msgstr ""
msgid "epub format not found for book id: %(book)d"
msgstr ""
#: cps/helper.py:9
3
#: cps/helper.py:9
0 cps/helper.py:94
msgid "kindlegen failed, no excecution permissions"
msgstr ""
#: cps/helper.py:1
09
#: cps/helper.py:1
10
#, python-format
msgid "Kindlegen failed with Error %(error)s. Message: %(message)s"
msgstr ""
#: cps/helper.py:18
6
#: cps/helper.py:18
7
#, python-format
msgid "Failed to send mail: %s"
msgstr ""
#: cps/helper.py:19
3
#: cps/helper.py:19
4
msgid "Calibre-web test email"
msgstr ""
#: cps/helper.py:19
4 cps/helper.py:206
#: cps/helper.py:19
5 cps/helper.py:207
msgid "This email has been sent via calibre web."
msgstr ""
#: cps/helper.py:20
3 cps/templates/detail.html:47
#: cps/helper.py:20
4 cps/templates/detail.html:43
msgid "Send to Kindle"
msgstr ""
#: cps/helper.py:22
3 cps/helper.py:236
#: cps/helper.py:22
4 cps/helper.py:239
msgid "Could not find any formats suitable for sending by email"
msgstr ""
...
...
@@ -445,8 +445,8 @@ msgstr ""
msgid "Admin"
msgstr ""
#: cps/templates/admin.html:13 cps/templates/detail.html:2
2
#: cps/templates/detail.html:3
4
#: cps/templates/admin.html:13 cps/templates/detail.html:2
1
#: cps/templates/detail.html:3
0
msgid "Download"
msgstr ""
...
...
@@ -699,7 +699,7 @@ msgstr ""
msgid "No Result! Please try anonther keyword."
msgstr ""
#: cps/templates/book_edit.html:182 cps/templates/detail.html:12
7
#: cps/templates/book_edit.html:182 cps/templates/detail.html:12
6
#: cps/templates/search_form.html:14
msgid "Publisher"
msgstr ""
...
...
@@ -809,39 +809,39 @@ msgstr ""
msgid "Login"
msgstr ""
#: cps/templates/detail.html:
52
#: cps/templates/detail.html:
48
msgid "Read in browser"
msgstr ""
#: cps/templates/detail.html:
91
#: cps/templates/detail.html:
88
msgid "Book"
msgstr ""
#: cps/templates/detail.html:
91
#: cps/templates/detail.html:
88
msgid "of"
msgstr ""
#: cps/templates/detail.html:9
7
#: cps/templates/detail.html:9
4
msgid "language"
msgstr ""
#: cps/templates/detail.html:13
2
#: cps/templates/detail.html:13
1
msgid "Publishing date"
msgstr ""
#: cps/templates/detail.html:16
7
#: cps/templates/detail.html:16
8
msgid "Read"
msgstr ""
#: cps/templates/detail.html:17
6
#: cps/templates/detail.html:17
7
msgid "Description:"
msgstr ""
#: cps/templates/detail.html:18
7
#: cps/templates/detail.html:18
9
msgid "Add to shelf"
msgstr ""
#: cps/templates/detail.html:2
27
#: cps/templates/detail.html:2
30
msgid "Edit metadata"
msgstr ""
...
...
@@ -1007,7 +1007,7 @@ msgstr ""
msgid "Calibre Web ebook catalog"
msgstr ""
#: cps/templates/read.html:1
36
#: cps/templates/read.html:1
25
msgid "Reflow text when sidebars are open."
msgstr ""
...
...
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