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
772f978b
Commit
772f978b
authored
Mar 24, 2019
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved code quality
parent
0f1db18e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
32 deletions
+18
-32
web.py
cps/web.py
+18
-32
No files found.
cps/web.py
View file @
772f978b
...
@@ -1306,41 +1306,27 @@ def read_book(book_id, book_format):
...
@@ -1306,41 +1306,27 @@ def read_book(book_id, book_format):
return
render_title_template
(
'readpdf.html'
,
pdffile
=
book_id
,
title
=
_
(
u"Read a Book"
))
return
render_title_template
(
'readpdf.html'
,
pdffile
=
book_id
,
title
=
_
(
u"Read a Book"
))
elif
book_format
.
lower
()
==
"txt"
:
elif
book_format
.
lower
()
==
"txt"
:
return
render_title_template
(
'readtxt.html'
,
txtfile
=
book_id
,
title
=
_
(
u"Read a Book"
))
return
render_title_template
(
'readtxt.html'
,
txtfile
=
book_id
,
title
=
_
(
u"Read a Book"
))
elif
book_format
.
lower
()
==
"mp3"
:
entries
=
db
.
session
.
query
(
db
.
Books
)
.
filter
(
db
.
Books
.
id
==
book_id
)
.
filter
(
common_filters
())
.
first
()
return
render_title_template
(
'listenmp3.html'
,
mp3file
=
book_id
,
audioformat
=
book_format
.
lower
(),
title
=
_
(
u"Read a Book"
),
entry
=
entries
,
bookmark
=
bookmark
)
elif
book_format
.
lower
()
==
"m4b"
:
entries
=
db
.
session
.
query
(
db
.
Books
)
.
filter
(
db
.
Books
.
id
==
book_id
)
.
filter
(
common_filters
())
.
first
()
return
render_title_template
(
'listenmp3.html'
,
mp3file
=
book_id
,
audioformat
=
book_format
.
lower
(),
title
=
_
(
u"Read a Book"
),
entry
=
entries
,
bookmark
=
bookmark
)
elif
book_format
.
lower
()
==
"m4a"
:
entries
=
db
.
session
.
query
(
db
.
Books
)
.
filter
(
db
.
Books
.
id
==
book_id
)
.
filter
(
common_filters
())
.
first
()
return
render_title_template
(
'listenmp3.html'
,
mp3file
=
book_id
,
audioformat
=
book_format
.
lower
(),
title
=
_
(
u"Read a Book"
),
entry
=
entries
,
bookmark
=
bookmark
)
else
:
else
:
book_dir
=
os
.
path
.
join
(
config
.
get_main_dir
,
"cps"
,
"static"
,
str
(
book_id
))
for
fileExt
in
[
"mp3"
,
"m4b"
,
"m4a"
]:
if
not
os
.
path
.
exists
(
book_dir
):
if
book_format
.
lower
()
==
fileExt
:
os
.
mkdir
(
book_dir
)
entries
=
db
.
session
.
query
(
db
.
Books
)
.
filter
(
db
.
Books
.
id
==
book_id
)
.
filter
(
common_filters
())
.
first
()
for
fileext
in
[
"cbr"
,
"cbt"
,
"cbz"
]:
return
render_title_template
(
'listenmp3.html'
,
mp3file
=
book_id
,
audioformat
=
book_format
.
lower
(),
if
book_format
.
lower
()
==
fileext
:
title
=
_
(
u"Read a Book"
),
entry
=
entries
,
bookmark
=
bookmark
)
all_name
=
str
(
book_id
)
# + "/" + book.data[0].name + "." + fileext
for
fileExt
in
[
"cbr"
,
"cbt"
,
"cbz"
]:
# tmp_file = os.path.join(book_dir, book.data[0].name) + "." + fileext
if
book_format
.
lower
()
==
fileExt
:
# if not os.path.exists(all_name):
all_name
=
str
(
book_id
)
# cbr_file = os.path.join(config.config_calibre_dir, book.path, book.data[0].name) + "." + fileext
# copyfile(cbr_file, tmp_file)
return
render_title_template
(
'readcbr.html'
,
comicfile
=
all_name
,
title
=
_
(
u"Read a Book"
),
return
render_title_template
(
'readcbr.html'
,
comicfile
=
all_name
,
title
=
_
(
u"Read a Book"
),
extension
=
file
e
xt
)
extension
=
file
E
xt
)
'''
if feature_support['rar']:
#
if feature_support['rar']:
extensionList = ["cbr","cbt","cbz"]
#
extensionList = ["cbr","cbt","cbz"]
else:
#
else:
extensionList = ["cbt","cbz"]
#
extensionList = ["cbt","cbz"]
for fileext in extensionList:
#
for fileext in extensionList:
if book_format.lower() == fileext:
#
if book_format.lower() == fileext:
return render_title_template('readcbr.html', comicfile=book_id,
# return render_title_template('readcbr.html', comicfile=book_id,
extension=fileext, title=_(u"Read a Book"), book=book)
#
extension=fileext, title=_(u"Read a Book"), book=book)
flash
(
_
(
u"Error opening eBook. File does not exist or file is not accessible."
),
category
=
"error"
)
flash
(
_
(
u"Error opening eBook. File does not exist or file is not accessible."
),
category
=
"error"
)
return redirect(url_for("web.index"))
'''
return
redirect
(
url_for
(
"web.index"
))
@
web
.
route
(
"/book/<int:book_id>"
)
@
web
.
route
(
"/book/<int:book_id>"
)
...
...
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