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
dde3b9b0
Commit
dde3b9b0
authored
Jul 31, 2017
by
Carlos Clavero
Committed by
GitHub
Jul 31, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4 from Kyosfonica/epub_tags_metadata
Added tags metadata handler for epubs
parents
80873e77
4bba3558
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
3 deletions
+11
-3
epub.py
cps/epub.py
+5
-2
web.py
cps/web.py
+6
-1
No files found.
cps/epub.py
View file @
dde3b9b0
...
@@ -43,13 +43,16 @@ def get_epub_info(tmp_file_path, original_file_name, original_file_extension):
...
@@ -43,13 +43,16 @@ def get_epub_info(tmp_file_path, original_file_name, original_file_extension):
epub_metadata
=
{}
epub_metadata
=
{}
for
s
in
[
'title'
,
'description'
,
'creator'
,
'language'
]:
for
s
in
[
'title'
,
'description'
,
'creator'
,
'language'
,
'subject'
]:
tmp
=
p
.
xpath
(
'dc:
%
s/text()'
%
s
,
namespaces
=
ns
)
tmp
=
p
.
xpath
(
'dc:
%
s/text()'
%
s
,
namespaces
=
ns
)
if
len
(
tmp
)
>
0
:
if
len
(
tmp
)
>
0
:
epub_metadata
[
s
]
=
p
.
xpath
(
'dc:
%
s/text()'
%
s
,
namespaces
=
ns
)[
0
]
epub_metadata
[
s
]
=
p
.
xpath
(
'dc:
%
s/text()'
%
s
,
namespaces
=
ns
)[
0
]
else
:
else
:
epub_metadata
[
s
]
=
"Unknown"
epub_metadata
[
s
]
=
"Unknown"
if
epub_metadata
[
'subject'
]
==
"Unknown"
:
epub_metadata
[
'subject'
]
=
''
if
epub_metadata
[
'description'
]
==
"Unknown"
:
if
epub_metadata
[
'description'
]
==
"Unknown"
:
description
=
tree
.
xpath
(
"//*[local-name() = 'description']/text()"
)
description
=
tree
.
xpath
(
"//*[local-name() = 'description']/text()"
)
if
len
(
description
)
>
0
:
if
len
(
description
)
>
0
:
...
@@ -101,7 +104,7 @@ def get_epub_info(tmp_file_path, original_file_name, original_file_extension):
...
@@ -101,7 +104,7 @@ def get_epub_info(tmp_file_path, original_file_name, original_file_extension):
author
=
epub_metadata
[
'creator'
]
.
encode
(
'utf-8'
)
.
decode
(
'utf-8'
),
author
=
epub_metadata
[
'creator'
]
.
encode
(
'utf-8'
)
.
decode
(
'utf-8'
),
cover
=
coverfile
,
cover
=
coverfile
,
description
=
epub_metadata
[
'description'
],
description
=
epub_metadata
[
'description'
],
tags
=
""
,
tags
=
epub_metadata
[
'subject'
]
.
encode
(
'utf-8'
)
.
decode
(
'utf-8'
)
,
series
=
""
,
series
=
""
,
series_id
=
""
,
series_id
=
""
,
languages
=
epub_metadata
[
'language'
])
languages
=
epub_metadata
[
'language'
])
cps/web.py
View file @
dde3b9b0
...
@@ -2928,7 +2928,7 @@ def upload():
...
@@ -2928,7 +2928,7 @@ def upload():
title
=
meta
.
title
title
=
meta
.
title
author
=
meta
.
author
author
=
meta
.
author
tags
=
meta
.
tags
title_dir
=
helper
.
get_valid_filename
(
title
,
False
)
title_dir
=
helper
.
get_valid_filename
(
title
,
False
)
author_dir
=
helper
.
get_valid_filename
(
author
,
False
)
author_dir
=
helper
.
get_valid_filename
(
author
,
False
)
data_name
=
title_dir
data_name
=
title_dir
...
@@ -2995,6 +2995,11 @@ def upload():
...
@@ -2995,6 +2995,11 @@ def upload():
if
upload_comment
!=
""
:
if
upload_comment
!=
""
:
db
.
session
.
add
(
db
.
Comments
(
upload_comment
,
db_book
.
id
))
db
.
session
.
add
(
db
.
Comments
(
upload_comment
,
db_book
.
id
))
db
.
session
.
commit
()
db
.
session
.
commit
()
input_tags
=
tags
.
split
(
','
)
input_tags
=
map
(
lambda
it
:
it
.
strip
(),
input_tags
)
modify_database_object
(
input_tags
,
db_book
.
tags
,
db
.
Tags
,
db
.
session
,
'tags'
)
if
db_language
is
not
None
:
# display Full name instead of iso639.part3
if
db_language
is
not
None
:
# display Full name instead of iso639.part3
db_book
.
languages
[
0
]
.
language_name
=
_
(
meta
.
languages
)
db_book
.
languages
[
0
]
.
language_name
=
_
(
meta
.
languages
)
author_names
=
[]
author_names
=
[]
...
...
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