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
0a02caad
Commit
0a02caad
authored
May 09, 2020
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improvements
parent
ff75bdba
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
36 additions
and
49 deletions
+36
-49
about.py
cps/about.py
+1
-0
admin.py
cps/admin.py
+2
-12
constants.py
cps/constants.py
+5
-4
converter.py
cps/converter.py
+6
-2
helper.py
cps/helper.py
+2
-8
config_edit.html
cps/templates/config_edit.html
+6
-18
detail.html
cps/templates/detail.html
+2
-0
uploader.py
cps/uploader.py
+5
-3
web.py
cps/web.py
+7
-2
No files found.
cps/about.py
View file @
0a02caad
...
@@ -91,5 +91,6 @@ def stats():
...
@@ -91,5 +91,6 @@ def stats():
series
=
db
.
session
.
query
(
db
.
Series
)
.
count
()
series
=
db
.
session
.
query
(
db
.
Series
)
.
count
()
_VERSIONS
[
'ebook converter'
]
=
_
(
converter
.
get_calibre_version
())
_VERSIONS
[
'ebook converter'
]
=
_
(
converter
.
get_calibre_version
())
_VERSIONS
[
'unrar'
]
=
_
(
converter
.
get_unrar_version
())
_VERSIONS
[
'unrar'
]
=
_
(
converter
.
get_unrar_version
())
_VERSIONS
[
'kepubify'
]
=
_
(
converter
.
get_kepubify_version
())
return
render_title_template
(
'stats.html'
,
bookcounter
=
counter
,
authorcounter
=
authors
,
versions
=
_VERSIONS
,
return
render_title_template
(
'stats.html'
,
bookcounter
=
counter
,
authorcounter
=
authors
,
versions
=
_VERSIONS
,
categorycounter
=
categorys
,
seriecounter
=
series
,
title
=
_
(
u"Statistics"
),
page
=
"stat"
)
categorycounter
=
categorys
,
seriecounter
=
series
,
title
=
_
(
u"Statistics"
),
page
=
"stat"
)
cps/admin.py
View file @
0a02caad
...
@@ -168,7 +168,6 @@ def update_view_configuration():
...
@@ -168,7 +168,6 @@ def update_view_configuration():
_config_string
(
"config_calibre_web_title"
)
_config_string
(
"config_calibre_web_title"
)
_config_string
(
"config_columns_to_ignore"
)
_config_string
(
"config_columns_to_ignore"
)
# _config_string("config_mature_content_tags")
reboot_required
|=
_config_string
(
"config_title_regex"
)
reboot_required
|=
_config_string
(
"config_title_regex"
)
_config_int
(
"config_read_column"
)
_config_int
(
"config_read_column"
)
...
@@ -179,7 +178,8 @@ def update_view_configuration():
...
@@ -179,7 +178,8 @@ def update_view_configuration():
_config_int
(
"config_restricted_column"
)
_config_int
(
"config_restricted_column"
)
if
config
.
config_google_drive_watch_changes_response
:
if
config
.
config_google_drive_watch_changes_response
:
config
.
config_google_drive_watch_changes_response
=
json
.
dumps
(
config
.
config_google_drive_watch_changes_response
)
config
.
config_google_drive_watch_changes_response
=
\
json
.
dumps
(
config
.
config_google_drive_watch_changes_response
)
config
.
config_default_role
=
constants
.
selected_roles
(
to_save
)
config
.
config_default_role
=
constants
.
selected_roles
(
to_save
)
config
.
config_default_role
&=
~
constants
.
ROLE_ANONYMOUS
config
.
config_default_role
&=
~
constants
.
ROLE_ANONYMOUS
...
@@ -538,11 +538,6 @@ def _configuration_update_helper():
...
@@ -538,11 +538,6 @@ def _configuration_update_helper():
_config_string
(
"config_converterpath"
)
_config_string
(
"config_converterpath"
)
_config_string
(
"config_kepubifypath"
)
_config_string
(
"config_kepubifypath"
)
_config_checkbox_int
(
"config_automatic_kepub"
)
_config_string
(
"config_kepubify_path"
)
_config_string
(
"config_kepub_cache_dir"
)
reboot_required
|=
_config_int
(
"config_login_type"
)
reboot_required
|=
_config_int
(
"config_login_type"
)
#LDAP configurator,
#LDAP configurator,
...
@@ -579,11 +574,6 @@ def _configuration_update_helper():
...
@@ -579,11 +574,6 @@ def _configuration_update_helper():
if
not
config
.
config_ldap_serv_username
:
if
not
config
.
config_ldap_serv_username
:
return
_configuration_result
(
'Please Enter a LDAP Service Account'
,
gdriveError
)
return
_configuration_result
(
'Please Enter a LDAP Service Account'
,
gdriveError
)
#_config_checkbox("config_ldap_use_ssl")
#_config_checkbox("config_ldap_use_tls")
# reboot_required |= _config_checkbox("config_ldap_openldap")
# _config_checkbox("config_ldap_require_cert")
if
config
.
config_ldap_group_object_filter
:
if
config
.
config_ldap_group_object_filter
:
if
config
.
config_ldap_group_object_filter
.
count
(
"
%
s"
)
!=
1
:
if
config
.
config_ldap_group_object_filter
.
count
(
"
%
s"
)
!=
1
:
return
_configuration_result
(
_
(
'LDAP Group Object Filter Needs to Have One "
%
s" Format Identifier'
),
return
_configuration_result
(
_
(
'LDAP Group Object Filter Needs to Have One "
%
s" Format Identifier'
),
...
...
cps/constants.py
View file @
0a02caad
...
@@ -81,9 +81,10 @@ SIDEBAR_PUBLISHER = 1 << 12
...
@@ -81,9 +81,10 @@ SIDEBAR_PUBLISHER = 1 << 12
SIDEBAR_RATING
=
1
<<
13
SIDEBAR_RATING
=
1
<<
13
SIDEBAR_FORMAT
=
1
<<
14
SIDEBAR_FORMAT
=
1
<<
14
SIDEBAR_ARCHIVED
=
1
<<
15
SIDEBAR_ARCHIVED
=
1
<<
15
SIDEBAR_LIST
=
1
<<
16
ADMIN_USER_ROLES
=
sum
(
r
for
r
in
ALL_ROLES
.
values
())
&
~
ROLE_ANONYMOUS
ADMIN_USER_ROLES
=
sum
(
r
for
r
in
ALL_ROLES
.
values
())
&
~
ROLE_ANONYMOUS
ADMIN_USER_SIDEBAR
=
(
SIDEBAR_
ARCHIVED
<<
1
)
-
1
ADMIN_USER_SIDEBAR
=
(
SIDEBAR_
LIST
<<
1
)
-
1
UPDATE_STABLE
=
0
<<
0
UPDATE_STABLE
=
0
<<
0
AUTO_UPDATE_STABLE
=
1
<<
0
AUTO_UPDATE_STABLE
=
1
<<
0
...
@@ -111,9 +112,9 @@ del env_CALIBRE_PORT
...
@@ -111,9 +112,9 @@ del env_CALIBRE_PORT
EXTENSIONS_AUDIO
=
{
'mp3'
,
'm4a'
,
'm4b'
}
EXTENSIONS_AUDIO
=
{
'mp3'
,
'm4a'
,
'm4b'
}
EXTENSIONS_CONVERT
=
{
'pdf'
,
'epub'
,
'mobi'
,
'azw3'
,
'docx'
,
'rtf'
,
'fb2'
,
'lit'
,
'lrf'
,
'txt'
,
'htmlz'
,
'rtf'
,
'odt'
}
EXTENSIONS_CONVERT
=
[
'pdf'
,
'epub'
,
'mobi'
,
'azw3'
,
'docx'
,
'rtf'
,
'fb2'
,
'lit'
,
'lrf'
,
'txt'
,
'htmlz'
,
'rtf'
,
'odt'
]
EXTENSIONS_UPLOAD
=
{
'txt'
,
'pdf'
,
'epub'
,
'
mobi'
,
'azw'
,
'azw3'
,
'cbr'
,
'cbz'
,
'cbt'
,
'djvu'
,
'prc'
,
'doc'
,
'docx
'
,
EXTENSIONS_UPLOAD
=
{
'txt'
,
'pdf'
,
'epub'
,
'
kepub'
,
'mobi'
,
'azw'
,
'azw3'
,
'cbr'
,
'cbz'
,
'cbt'
,
'djvu'
,
'prc'
,
'doc
'
,
'fb2'
,
'html'
,
'rtf'
,
'lit'
,
'odt'
,
'mp3'
,
'm4a'
,
'm4b'
}
'
docx'
,
'
fb2'
,
'html'
,
'rtf'
,
'lit'
,
'odt'
,
'mp3'
,
'm4a'
,
'm4b'
}
def
has_flag
(
value
,
bit_flag
):
def
has_flag
(
value
,
bit_flag
):
...
...
cps/converter.py
View file @
0a02caad
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
from
__future__
import
division
,
print_function
,
unicode_literals
from
__future__
import
division
,
print_function
,
unicode_literals
import
os
import
os
import
re
import
re
import
sys
from
flask_babel
import
gettext
as
_
from
flask_babel
import
gettext
as
_
from
.
import
config
,
logger
from
.
import
config
,
logger
...
@@ -49,11 +50,14 @@ def _get_command_version(path, pattern, argument=None):
...
@@ -49,11 +50,14 @@ def _get_command_version(path, pattern, argument=None):
def
get_calibre_version
():
def
get_calibre_version
():
# version = None
# if config.config_ebookconverter == 2:
return
_get_command_version
(
config
.
config_converterpath
,
r'ebook-convert.*\(calibre'
,
'--version'
)
\
return
_get_command_version
(
config
.
config_converterpath
,
r'ebook-convert.*\(calibre'
,
'--version'
)
\
or
_NOT_CONFIGURED
or
_NOT_CONFIGURED
def
get_unrar_version
():
def
get_unrar_version
():
return
_get_command_version
(
config
.
config_rarfile_location
,
r'UNRAR.*\d'
)
or
_NOT_CONFIGURED
return
_get_command_version
(
config
.
config_rarfile_location
,
r'UNRAR.*\d'
)
or
_NOT_CONFIGURED
def
get_kepubify_version
():
return
_get_command_version
(
config
.
config_kepubifypath
,
r'kepubify\s'
,
'--version'
)
or
_NOT_CONFIGURED
cps/helper.py
View file @
0a02caad
...
@@ -609,14 +609,8 @@ def do_download_file(book, book_format, client, data, headers):
...
@@ -609,14 +609,8 @@ def do_download_file(book, book_format, client, data, headers):
# ToDo: improve error handling
# ToDo: improve error handling
log
.
error
(
'File not found:
%
s'
,
os
.
path
.
join
(
filename
,
data
.
name
+
"."
+
book_format
))
log
.
error
(
'File not found:
%
s'
,
os
.
path
.
join
(
filename
,
data
.
name
+
"."
+
book_format
))
if
client
==
"kobo"
and
book_format
==
"epub"
:
if
client
==
"kobo"
and
book_format
==
"kepub"
:
filename
=
config
.
config_kepub_cache_dir
headers
[
"Content-Disposition"
]
=
headers
[
"Content-Disposition"
]
.
replace
(
".kepub"
,
".kepub.epub"
)
os
.
system
(
'{0} "{1}" -o {2}'
.
format
(
config
.
config_kepubify_path
,
os
.
path
.
join
(
filename
,
data
.
name
+
"."
+
book_format
),
filename
))
book_format
=
"kepub.epub"
headers
[
"Content-Disposition"
]
=
headers
[
"Content-Disposition"
]
.
replace
(
".epub"
,
".kepub.epub"
)
response
=
make_response
(
send_from_directory
(
filename
,
data
.
name
+
"."
+
book_format
))
response
=
make_response
(
send_from_directory
(
filename
,
data
.
name
+
"."
+
book_format
))
...
...
cps/templates/config_edit.html
View file @
0a02caad
...
@@ -345,17 +345,17 @@
...
@@ -345,17 +345,17 @@
</div>
</div>
<div
id=
"collapseeight"
class=
"panel-collapse collapse"
>
<div
id=
"collapseeight"
class=
"panel-collapse collapse"
>
<div
class=
"panel-body"
>
<div
class=
"panel-body"
>
<div
class=
"form-group"
>
<label
for=
"config_converterpath"
>
{{_('Path to Calibre E-Book Converter')}}
</label>
<label
for=
"config_calibre"
>
{{_('Calibre E-Book Converter Settings')}}
</label>
<input
type=
"text"
class=
"form-control"
id=
"config_calibre"
name=
"config_calibre"
value=
"{% if config.config_calibre != None %}{{ config.config_calibre }}{% endif %}"
autocomplete=
"off"
>
</div>
<label
for=
"config_converterpath"
>
{{_('Path to Calibre E-Book Converter')}}
</label>
<div
class=
"form-group input-group"
>
<div
class=
"form-group input-group"
>
<input
type=
"text"
class=
"form-control"
id=
"config_converterpath"
name=
"config_converterpath"
value=
"{% if config.config_converterpath != None %}{{ config.config_converterpath }}{% endif %}"
autocomplete=
"off"
>
<input
type=
"text"
class=
"form-control"
id=
"config_converterpath"
name=
"config_converterpath"
value=
"{% if config.config_converterpath != None %}{{ config.config_converterpath }}{% endif %}"
autocomplete=
"off"
>
<span
class=
"input-group-btn"
>
<span
class=
"input-group-btn"
>
<button
type=
"button"
id=
"converter_path"
class=
"btn btn-default"
><span
class=
"glyphicon glyphicon-folder-open"
></span></button>
<button
type=
"button"
id=
"converter_path"
class=
"btn btn-default"
><span
class=
"glyphicon glyphicon-folder-open"
></span></button>
</span>
</span>
</div>
</div>
<div
class=
"form-group"
>
<label
for=
"config_calibre"
>
{{_('Calibre E-Book Converter Settings')}}
</label>
<input
type=
"text"
class=
"form-control"
id=
"config_calibre"
name=
"config_calibre"
value=
"{% if config.config_calibre != None %}{{ config.config_calibre }}{% endif %}"
autocomplete=
"off"
>
</div>
<label
for=
"config_kepubifypath"
>
{{_('Path to Kepubify E-Book Converter')}}
</label>
<label
for=
"config_kepubifypath"
>
{{_('Path to Kepubify E-Book Converter')}}
</label>
<div
class=
"form-group input-group"
>
<div
class=
"form-group input-group"
>
<input
type=
"text"
class=
"form-control"
id=
"config_kepubifypath"
name=
"config_kepubifypath"
value=
"{% if config.config_kepubifypath != None %}{{ config.config_kepubifypath }}{% endif %}"
autocomplete=
"off"
>
<input
type=
"text"
class=
"form-control"
id=
"config_kepubifypath"
name=
"config_kepubifypath"
value=
"{% if config.config_kepubifypath != None %}{{ config.config_kepubifypath }}{% endif %}"
autocomplete=
"off"
>
...
@@ -363,18 +363,6 @@
...
@@ -363,18 +363,6 @@
<button
type=
"button"
id=
"kepubify_path"
class=
"btn btn-default"
><span
class=
"glyphicon glyphicon-folder-open"
></span></button>
<button
type=
"button"
id=
"kepubify_path"
class=
"btn btn-default"
><span
class=
"glyphicon glyphicon-folder-open"
></span></button>
</span>
</span>
</div>
</div>
<div
class=
"form-group"
>
<input
type=
"checkbox"
id=
"config_automatic_kepub"
name=
"config_automatic_kepub"
{%
if
config
.
config_automatic_kepub
%}
checked
{%
endif
%}
>
<label
for=
"config_uploading"
>
{{_('Enable automatic kobo epub conversion')}}
</label>
</div>
<div
class=
"form-group"
>
<label
for=
"config_kepubify_path"
>
{{_('Path to kepubify')}}
</label>
<input
type=
"text"
class=
"form-control"
id=
"config_kepubify_path"
name=
"config_kepubify_path"
value=
"{% if config.config_kepubify_path != None %}{{ config.config_kepubify_path }}{% endif %}"
autocomplete=
"off"
>
</div>
<div
class=
"form-group"
>
<label
for=
"config_kepub_cache_dir"
>
{{_('Path to kepubify')}}
</label>
<input
type=
"text"
class=
"form-control"
id=
"config_kepub_cache_dir"
name=
"config_kepub_cache_dir"
value=
"{% if config.config_kepub_cache_dir != None %}{{ config.config_kepub_cache_dir }}{% endif %}"
autocomplete=
"off"
>
</div>
{% if feature_support['rar'] %}
{% if feature_support['rar'] %}
<label
for=
"config_rarfile_location"
>
{{_('Location of Unrar binary')}}
</label>
<label
for=
"config_rarfile_location"
>
{{_('Location of Unrar binary')}}
</label>
<div
class=
"form-group input-group"
>
<div
class=
"form-group input-group"
>
...
...
cps/templates/detail.html
View file @
0a02caad
...
@@ -202,6 +202,7 @@
...
@@ -202,6 +202,7 @@
</label>
</label>
</form>
</form>
</p>
</p>
{% if g.user.check_visibility(32768) %}
<p>
<p>
<form
id=
"archived_form"
action=
"{{ url_for('web.toggle_archived', book_id=entry.id)}}"
method=
"POST"
>
<form
id=
"archived_form"
action=
"{{ url_for('web.toggle_archived', book_id=entry.id)}}"
method=
"POST"
>
<label
class=
"block-label"
>
<label
class=
"block-label"
>
...
@@ -210,6 +211,7 @@
...
@@ -210,6 +211,7 @@
</label>
</label>
</form>
</form>
</p>
</p>
{% endif %}
</div>
</div>
{% endif %}
{% endif %}
...
...
cps/uploader.py
View file @
0a02caad
...
@@ -79,11 +79,13 @@ def process(tmp_file_path, original_file_name, original_file_extension, rarExcec
...
@@ -79,11 +79,13 @@ def process(tmp_file_path, original_file_name, original_file_extension, rarExcec
try
:
try
:
if
".PDF"
==
original_file_extension
.
upper
():
if
".PDF"
==
original_file_extension
.
upper
():
meta
=
pdf_meta
(
tmp_file_path
,
original_file_name
,
original_file_extension
)
meta
=
pdf_meta
(
tmp_file_path
,
original_file_name
,
original_file_extension
)
if
".EPUB"
==
original_file_extension
.
upper
()
and
use_epub_meta
is
True
:
el
if
".EPUB"
==
original_file_extension
.
upper
()
and
use_epub_meta
is
True
:
meta
=
epub
.
get_epub_info
(
tmp_file_path
,
original_file_name
,
original_file_extension
)
meta
=
epub
.
get_epub_info
(
tmp_file_path
,
original_file_name
,
original_file_extension
)
if
".FB2"
==
original_file_extension
.
upper
()
and
use_fb2_meta
is
True
:
elif
".KEPUB"
==
original_file_extension
.
upper
()
and
use_epub_meta
is
True
:
meta
=
epub
.
get_epub_info
(
tmp_file_path
,
original_file_name
,
original_file_extension
)
elif
".FB2"
==
original_file_extension
.
upper
()
and
use_fb2_meta
is
True
:
meta
=
fb2
.
get_fb2_info
(
tmp_file_path
,
original_file_extension
)
meta
=
fb2
.
get_fb2_info
(
tmp_file_path
,
original_file_extension
)
if
original_file_extension
.
upper
()
in
[
'.CBZ'
,
'.CBT'
,
'.CBR'
]:
el
if
original_file_extension
.
upper
()
in
[
'.CBZ'
,
'.CBT'
,
'.CBR'
]:
meta
=
comic
.
get_comic_info
(
tmp_file_path
,
meta
=
comic
.
get_comic_info
(
tmp_file_path
,
original_file_name
,
original_file_name
,
original_file_extension
,
original_file_extension
,
...
...
cps/web.py
View file @
0a02caad
...
@@ -814,6 +814,12 @@ def render_language_books(page, name, order):
...
@@ -814,6 +814,12 @@ def render_language_books(page, name, order):
title
=
_
(
u"Language:
%(name)
s"
,
name
=
lang_name
),
page
=
"language"
)
title
=
_
(
u"Language:
%(name)
s"
,
name
=
lang_name
),
page
=
"language"
)
@
web
.
route
(
"/table"
)
@
login_required_if_no_ano
def
books_table
():
return
render_title_template
(
'index.html'
,
random
=
random
,
entries
=
entries
,
pagination
=
pagination
,
id
=
name
,
title
=
_
(
u"Language:
%(name)
s"
,
name
=
lang_name
),
page
=
"language"
)
@
web
.
route
(
"/author"
)
@
web
.
route
(
"/author"
)
@
login_required_if_no_ano
@
login_required_if_no_ano
def
author_list
():
def
author_list
():
...
@@ -1233,8 +1239,7 @@ def serve_book(book_id, book_format, anyname):
...
@@ -1233,8 +1239,7 @@ def serve_book(book_id, book_format, anyname):
@
login_required_if_no_ano
@
login_required_if_no_ano
@
download_required
@
download_required
def
download_link
(
book_id
,
book_format
,
anyname
):
def
download_link
(
book_id
,
book_format
,
anyname
):
if
(
config
.
config_automatic_kepub
and
if
"Kobo"
in
request
.
headers
.
get
(
'User-Agent'
):
"Kobo"
in
request
.
headers
.
get
(
'User-Agent'
)):
client
=
"kobo"
client
=
"kobo"
return
get_download_link
(
book_id
,
book_format
,
client
)
return
get_download_link
(
book_id
,
book_format
,
client
)
...
...
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