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
7098d088
Commit
7098d088
authored
Dec 15, 2019
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added option to convert AZW3 to mobi for sending to kindle
parent
eabc6e23
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
7 deletions
+11
-7
editbooks.py
cps/editbooks.py
+2
-2
helper.py
cps/helper.py
+9
-5
No files found.
cps/editbooks.py
View file @
7098d088
...
@@ -729,7 +729,7 @@ def convert_bookformat(book_id):
...
@@ -729,7 +729,7 @@ def convert_bookformat(book_id):
if
(
book_format_from
is
None
)
or
(
book_format_to
is
None
):
if
(
book_format_from
is
None
)
or
(
book_format_to
is
None
):
flash
(
_
(
u"Source or destination format for conversion missing"
),
category
=
"error"
)
flash
(
_
(
u"Source or destination format for conversion missing"
),
category
=
"error"
)
return
redirect
(
request
.
environ
[
"HTTP_REFERER"
]
)
return
redirect
(
url_for
(
'editbook.edit_book'
,
book_id
=
book_id
)
)
log
.
info
(
'converting: book id:
%
s from:
%
s to:
%
s'
,
book_id
,
book_format_from
,
book_format_to
)
log
.
info
(
'converting: book id:
%
s from:
%
s to:
%
s'
,
book_id
,
book_format_from
,
book_format_to
)
rtn
=
helper
.
convert_book_format
(
book_id
,
config
.
config_calibre_dir
,
book_format_from
.
upper
(),
rtn
=
helper
.
convert_book_format
(
book_id
,
config
.
config_calibre_dir
,
book_format_from
.
upper
(),
...
@@ -741,4 +741,4 @@ def convert_bookformat(book_id):
...
@@ -741,4 +741,4 @@ def convert_bookformat(book_id):
category
=
"success"
)
category
=
"success"
)
else
:
else
:
flash
(
_
(
u"There was an error converting this book:
%(res)
s"
,
res
=
rtn
),
category
=
"error"
)
flash
(
_
(
u"There was an error converting this book:
%(res)
s"
,
res
=
rtn
),
category
=
"error"
)
return
redirect
(
request
.
environ
[
"HTTP_REFERER"
]
)
return
redirect
(
url_for
(
'editbook.edit_book'
,
book_id
=
book_id
)
)
cps/helper.py
View file @
7098d088
...
@@ -167,10 +167,10 @@ def check_send_to_kindle(entry):
...
@@ -167,10 +167,10 @@ def check_send_to_kindle(entry):
if
'EPUB'
in
formats
and
not
'MOBI'
in
formats
:
if
'EPUB'
in
formats
and
not
'MOBI'
in
formats
:
bookformats
.
append
({
'format'
:
'Mobi'
,
'convert'
:
1
,
bookformats
.
append
({
'format'
:
'Mobi'
,
'convert'
:
1
,
'text'
:
_
(
'Convert
%(orig)
s to
%(format)
s and send to Kindle'
,
orig
=
'Epub'
,
format
=
'Mobi'
)})
'text'
:
_
(
'Convert
%(orig)
s to
%(format)
s and send to Kindle'
,
orig
=
'Epub'
,
format
=
'Mobi'
)})
'''
if config.config_ebookconverter == 2:
if
config
.
config_ebookconverter
==
2
:
if '
EPUB' in formats and not 'AZW3
' in formats:
if
'
AZW3'
in
formats
and
not
'MOBI
'
in
formats
:
bookformats.append({'format': '
Azw3','convert':1
,
bookformats
.
append
({
'format'
:
'
Mobi'
,
'convert'
:
2
,
'text':_('Convert
%(orig)
s to
%(format)
s and send to Kindle',orig='
Epub',format='Azw3')})'''
'text'
:
_
(
'Convert
%(orig)
s to
%(format)
s and send to Kindle'
,
orig
=
'
Azw3'
,
format
=
'Mobi'
)})
return
bookformats
return
bookformats
else
:
else
:
log
.
error
(
u'Cannot find book entry
%
d'
,
entry
.
id
)
log
.
error
(
u'Cannot find book entry
%
d'
,
entry
.
id
)
...
@@ -197,9 +197,13 @@ def send_mail(book_id, book_format, convert, kindle_mail, calibrepath, user_id):
...
@@ -197,9 +197,13 @@ def send_mail(book_id, book_format, convert, kindle_mail, calibrepath, user_id):
"""Send email with attachments"""
"""Send email with attachments"""
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
()
if
convert
:
if
convert
==
1
:
# returns None if success, otherwise errormessage
# returns None if success, otherwise errormessage
return
convert_book_format
(
book_id
,
calibrepath
,
u'epub'
,
book_format
.
lower
(),
user_id
,
kindle_mail
)
return
convert_book_format
(
book_id
,
calibrepath
,
u'epub'
,
book_format
.
lower
(),
user_id
,
kindle_mail
)
if
convert
==
2
:
# returns None if success, otherwise errormessage
return
convert_book_format
(
book_id
,
calibrepath
,
u'azw3'
,
book_format
.
lower
(),
user_id
,
kindle_mail
)
for
entry
in
iter
(
book
.
data
):
for
entry
in
iter
(
book
.
data
):
if
entry
.
format
.
upper
()
==
book_format
.
upper
():
if
entry
.
format
.
upper
()
==
book_format
.
upper
():
...
...
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