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
9bc085a2
Commit
9bc085a2
authored
May 02, 2020
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes for comic reader
parent
0a92d79e
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
31 additions
and
39 deletions
+31
-39
about.py
cps/about.py
+2
-1
converter.py
cps/converter.py
+9
-4
editbooks.py
cps/editbooks.py
+4
-1
helper.py
cps/helper.py
+1
-2
kobo.py
cps/kobo.py
+3
-0
config_edit.html
cps/templates/config_edit.html
+0
-2
worker.py
cps/worker.py
+12
-29
No files found.
cps/about.py
View file @
9bc085a2
...
...
@@ -89,6 +89,7 @@ def stats():
authors
=
db
.
session
.
query
(
db
.
Authors
)
.
count
()
categorys
=
db
.
session
.
query
(
db
.
Tags
)
.
count
()
series
=
db
.
session
.
query
(
db
.
Series
)
.
count
()
_VERSIONS
[
'ebook converter'
]
=
_
(
converter
.
get_version
())
_VERSIONS
[
'ebook converter'
]
=
_
(
converter
.
get_calibre_version
())
_VERSIONS
[
'unrar'
]
=
_
(
converter
.
get_version
())
return
render_title_template
(
'stats.html'
,
bookcounter
=
counter
,
authorcounter
=
authors
,
versions
=
_VERSIONS
,
categorycounter
=
categorys
,
seriecounter
=
series
,
title
=
_
(
u"Statistics"
),
page
=
"stat"
)
cps/converter.py
View file @
9bc085a2
...
...
@@ -48,10 +48,15 @@ def _get_command_version(path, pattern, argument=None):
return
_NOT_INSTALLED
def
get_version
():
def
get_
calibre_
version
():
version
=
None
if
config
.
config_ebookconverter
==
1
:
version
=
_get_command_version
(
config
.
config_converterpath
,
r'Amazon kindlegen\('
)
elif
config
.
config_ebookconverter
==
2
:
if
config
.
config_ebookconverter
==
2
:
version
=
_get_command_version
(
config
.
config_converterpath
,
r'ebook-convert.*\(calibre'
,
'--version'
)
return
version
or
_NOT_CONFIGURED
def
get_unrar_version
():
version
=
None
if
config
.
config_ebookconverter
==
2
:
version
=
_get_command_version
(
config
.
config_converterpath
,
r'ebook-convert.*\(calibre'
,
'--version'
)
return
version
or
_NOT_CONFIGURED
cps/editbooks.py
View file @
9bc085a2
...
...
@@ -719,7 +719,6 @@ def upload():
os
.
path
.
join
(
filepath
,
"cover.jpg"
))
else
:
has_cover
=
1
move
(
meta
.
cover
,
os
.
path
.
join
(
filepath
,
"cover.jpg"
))
# handle authors
is_author
=
db
.
session
.
query
(
db
.
Authors
)
.
filter
(
db
.
Authors
.
name
==
authr
)
.
first
()
...
...
@@ -796,6 +795,10 @@ def upload():
if
config
.
config_use_google_drive
:
gdriveutils
.
updateGdriveCalibreFromLocal
()
error
=
helper
.
update_dir_stucture
(
book
.
id
,
config
.
config_calibre_dir
)
# move cover to final directory, including book id
if
has_cover
:
move
(
meta
.
cover
,
os
.
path
.
join
(
filepath
+
' ({})'
.
format
(
book_id
),
"cover.jpg"
))
db
.
session
.
commit
()
if
config
.
config_use_google_drive
:
gdriveutils
.
updateGdriveCalibreFromLocal
()
...
...
cps/helper.py
View file @
9bc085a2
...
...
@@ -173,14 +173,13 @@ def check_send_to_kindle(entry):
bookformats
.
append
({
'format'
:
'Pdf'
,
'convert'
:
0
,
'text'
:
_
(
'Send
%(format)
s to Kindle'
,
format
=
'Pdf'
)})
if
config
.
config_ebookconverter
>=
1
:
if
config
.
config_ebookconverter
==
2
:
if
'EPUB'
in
formats
and
not
'MOBI'
in
formats
:
bookformats
.
append
({
'format'
:
'Mobi'
,
'convert'
:
1
,
'text'
:
_
(
'Convert
%(orig)
s to
%(format)
s and send to Kindle'
,
orig
=
'Epub'
,
format
=
'Mobi'
)})
if
config
.
config_ebookconverter
==
2
:
if
'AZW3'
in
formats
and
not
'MOBI'
in
formats
:
bookformats
.
append
({
'format'
:
'Mobi'
,
'convert'
:
2
,
...
...
cps/kobo.py
View file @
9bc085a2
...
...
@@ -949,12 +949,15 @@ def HandleInitRequest():
book_uuid
=
"{ImageId}"
,
width
=
"{width}"
,
height
=
"{height}"
,
Quality
=
'{Quality}'
,
isGreyscale
=
'isGreyscale'
,
_external
=
True
))
kobo_resources
[
"image_url_template"
]
=
unquote
(
url_for
(
"kobo.HandleCoverImageRequest"
,
auth_token
=
kobo_auth
.
get_auth_token
(),
book_uuid
=
"{ImageId}"
,
width
=
"{width}"
,
height
=
"{height}"
,
isGreyscale
=
'false'
,
_external
=
True
))
...
...
cps/templates/config_edit.html
View file @
9bc085a2
...
...
@@ -329,8 +329,6 @@
<div
class=
"form-group"
>
<div><input
type=
"radio"
name=
"config_ebookconverter"
id=
"converter0"
value=
"0"
{%
if
config
.
config_ebookconverter =
=
0
%}
checked
{%
endif
%}
>
<label
for=
"converter0"
>
{{_('No Converter')}}
</label></div>
<div><input
type=
"radio"
name=
"config_ebookconverter"
id=
"converter1"
value=
"1"
{%
if
config
.
config_ebookconverter =
=
1
%}
checked
{%
endif
%}
>
<label
for=
"converter1"
>
{{_('Use Kindlegen')}}
</label></div>
<div><input
type=
"radio"
name=
"config_ebookconverter"
id=
"converter2"
value=
"2"
{%
if
config
.
config_ebookconverter =
=
2
%}
checked
{%
endif
%}
>
<label
for=
"converter2"
>
{{_('Use calibre\'s ebook converter')}}
</label></div>
</div>
...
...
cps/worker.py
View file @
9bc085a2
...
...
@@ -297,11 +297,6 @@ class WorkerThread(threading.Thread):
return
try
:
# check which converter to use kindlegen is "1"
if
format_old_ext
==
'.epub'
and
format_new_ext
==
'.mobi'
:
if
config
.
config_ebookconverter
==
1
:
command
=
[
config
.
config_converterpath
,
file_path
+
u'.epub'
]
quotes
=
[
1
]
if
config
.
config_ebookconverter
==
2
:
# Linux py2.7 encode as list without quotes no empty element for parameters
# linux py3.x no encode and as list without quotes no empty element for parameters
...
...
@@ -324,28 +319,17 @@ class WorkerThread(threading.Thread):
self
.
_handleError
(
_
(
u"Ebook-converter failed:
%(error)
s"
,
error
=
e
))
return
if
config
.
config_ebookconverter
==
1
:
nextline
=
p
.
communicate
()[
0
]
# Format of error message (kindlegen translates its output texts):
# Error(prcgen):E23006: Language not recognized in metadata.The dc:Language field is mandatory.Aborting.
conv_error
=
re
.
search
(
r".*\(.*\):(E\d+):\s(.*)"
,
nextline
,
re
.
MULTILINE
)
# If error occoures, store error message for logfile
if
conv_error
:
error_message
=
_
(
u"Kindlegen failed with Error
%(error)
s. Message:
%(message)
s"
,
error
=
conv_error
.
group
(
1
),
message
=
conv_error
.
group
(
2
)
.
strip
())
log
.
debug
(
"convert_kindlegen:
%
s"
,
nextline
)
else
:
while
p
.
poll
()
is
None
:
nextline
=
p
.
stdout
.
readline
()
if
os
.
name
==
'nt'
and
sys
.
version_info
<
(
3
,
0
):
nextline
=
nextline
.
decode
(
'windows-1252'
)
elif
os
.
name
==
'posix'
and
sys
.
version_info
<
(
3
,
0
):
nextline
=
nextline
.
decode
(
'utf-8'
)
log
.
debug
(
nextline
.
strip
(
'
\r\n
'
))
# parse progress string from calibre-converter
progress
=
re
.
search
(
r"(\d+)
%
\s.*"
,
nextline
)
if
progress
:
self
.
UIqueue
[
index
][
'progress'
]
=
progress
.
group
(
1
)
+
'
%
'
while
p
.
poll
()
is
None
:
nextline
=
p
.
stdout
.
readline
()
if
os
.
name
==
'nt'
and
sys
.
version_info
<
(
3
,
0
):
nextline
=
nextline
.
decode
(
'windows-1252'
)
elif
os
.
name
==
'posix'
and
sys
.
version_info
<
(
3
,
0
):
nextline
=
nextline
.
decode
(
'utf-8'
)
log
.
debug
(
nextline
.
strip
(
'
\r\n
'
))
# parse progress string from calibre-converter
progress
=
re
.
search
(
r"(\d+)
%
\s.*"
,
nextline
)
if
progress
:
self
.
UIqueue
[
index
][
'progress'
]
=
progress
.
group
(
1
)
+
'
%
'
# process returncode
check
=
p
.
returncode
...
...
@@ -361,8 +345,7 @@ class WorkerThread(threading.Thread):
# 0 = Info(prcgen):I1036: Mobi file built successfully
# 1 = Info(prcgen):I1037: Mobi file built with WARNINGS!
# 2 = Info(prcgen):I1038: MOBI file could not be generated because of errors!
if
(
check
<
2
and
config
.
config_ebookconverter
==
1
)
or
\
(
check
==
0
and
config
.
config_ebookconverter
==
2
):
if
check
==
0
and
config
.
config_ebookconverter
==
2
:
cur_book
=
db
.
session
.
query
(
db
.
Books
)
.
filter
(
db
.
Books
.
id
==
bookid
)
.
first
()
if
os
.
path
.
isfile
(
file_path
+
format_new_ext
):
new_format
=
db
.
Data
(
name
=
cur_book
.
data
[
0
]
.
name
,
...
...
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