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
4dcac075
Commit
4dcac075
authored
Jan 05, 2019
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Partly fixed #661: Right order of Authors is still not shown
parent
f821580b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
16 deletions
+25
-16
helper.py
cps/helper.py
+13
-7
web.py
cps/web.py
+12
-9
No files found.
cps/helper.py
View file @
4dcac075
...
...
@@ -262,12 +262,15 @@ def delete_book_file(book, calibrepath, book_format=None):
return
False
def
update_dir_structure_file
(
book_id
,
calibrepath
):
def
update_dir_structure_file
(
book_id
,
calibrepath
,
first_author
):
localbook
=
db
.
session
.
query
(
db
.
Books
)
.
filter
(
db
.
Books
.
id
==
book_id
)
.
first
()
path
=
os
.
path
.
join
(
calibrepath
,
localbook
.
path
)
authordir
=
localbook
.
path
.
split
(
'/'
)[
0
]
new_authordir
=
get_valid_filename
(
localbook
.
authors
[
0
]
.
name
)
if
first_author
:
new_authordir
=
get_valid_filename
(
first_author
)
else
:
new_authordir
=
get_valid_filename
(
localbook
.
authors
[
0
]
.
name
)
titledir
=
localbook
.
path
.
split
(
'/'
)[
1
]
new_titledir
=
get_valid_filename
(
localbook
.
title
)
+
" ("
+
str
(
book_id
)
+
")"
...
...
@@ -300,12 +303,15 @@ def update_dir_structure_file(book_id, calibrepath):
return
False
def
update_dir_structure_gdrive
(
book_id
):
def
update_dir_structure_gdrive
(
book_id
,
first_author
):
error
=
False
book
=
db
.
session
.
query
(
db
.
Books
)
.
filter
(
db
.
Books
.
id
==
book_id
)
.
first
()
authordir
=
book
.
path
.
split
(
'/'
)[
0
]
new_authordir
=
get_valid_filename
(
book
.
authors
[
0
]
.
name
)
if
first_author
:
new_authordir
=
get_valid_filename
(
first_author
)
else
:
new_authordir
=
get_valid_filename
(
book
.
authors
[
0
]
.
name
)
titledir
=
book
.
path
.
split
(
'/'
)[
1
]
new_titledir
=
get_valid_filename
(
book
.
title
)
+
" ("
+
str
(
book_id
)
+
")"
...
...
@@ -356,11 +362,11 @@ def generate_random_password():
################################## External interface
def
update_dir_stucture
(
book_id
,
calibrepath
):
def
update_dir_stucture
(
book_id
,
calibrepath
,
first_author
=
None
):
if
ub
.
config
.
config_use_google_drive
:
return
update_dir_structure_gdrive
(
book_id
)
return
update_dir_structure_gdrive
(
book_id
,
first_author
)
else
:
return
update_dir_structure_file
(
book_id
,
calibrepath
)
return
update_dir_structure_file
(
book_id
,
calibrepath
,
first_author
)
def
delete_book
(
book
,
calibrepath
,
book_format
):
...
...
cps/web.py
View file @
4dcac075
...
...
@@ -532,6 +532,7 @@ def modify_database_object(input_elements, db_book_object, db_object, db_session
type_elements
=
c_elements
.
name
for
inp_element
in
input_elements
:
if
inp_element
.
lower
()
==
type_elements
.
lower
():
# if inp_element == type_elements:
found
=
True
break
# if the element was not found in the new list, add it to remove list
...
...
@@ -3656,22 +3657,24 @@ def edit_book(book_id):
# we have all author names now
if
input_authors
==
[
''
]:
input_authors
=
[
_
(
u'unknown'
)]
# prevent empty Author
if
book
.
authors
:
author0_before_edit
=
book
.
authors
[
0
]
.
name
else
:
author0_before_edit
=
db
.
Authors
(
_
(
u'unknown'
),
''
,
0
)
modify_database_object
(
input_authors
,
book
.
authors
,
db
.
Authors
,
db
.
session
,
'author'
)
if
book
.
authors
:
if
author0_before_edit
!=
book
.
authors
[
0
]
.
name
:
edited_books_id
=
book
.
id
book
.
author_sort
=
helper
.
get_sorted_author
(
input_authors
[
0
])
sort_authors_list
=
list
()
for
inp
in
input_authors
:
sort_authors_list
.
append
(
helper
.
get_sorted_author
(
inp
))
sort_authors
=
' & '
.
join
(
sort_authors_list
)
if
book
.
author_sort
!=
sort_authors
:
edited_books_id
=
book
.
id
book
.
author_sort
=
sort_authors
if
config
.
config_use_google_drive
:
gdriveutils
.
updateGdriveCalibreFromLocal
()
error
=
False
if
edited_books_id
:
error
=
helper
.
update_dir_stucture
(
edited_books_id
,
config
.
config_calibre_dir
)
error
=
helper
.
update_dir_stucture
(
edited_books_id
,
config
.
config_calibre_dir
,
input_authors
[
0
]
)
if
not
error
:
if
to_save
[
"cover_url"
]:
...
...
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