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
82e15d2e
Commit
82e15d2e
authored
Mar 21, 2021
by
Ozzie Isaacs
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into development
# Conflicts: # test/Calibre-Web TestSummary_Linux.html
parents
8cc84948
9c842f18
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
54 deletions
+9
-54
uploader.py
cps/uploader.py
+9
-54
No files found.
cps/uploader.py
View file @
82e15d2e
...
@@ -22,7 +22,7 @@ import hashlib
...
@@ -22,7 +22,7 @@ import hashlib
from
tempfile
import
gettempdir
from
tempfile
import
gettempdir
from
flask_babel
import
gettext
as
_
from
flask_babel
import
gettext
as
_
from
.
import
logger
,
comic
,
isoLanguages
,
get_locale
from
.
import
logger
,
comic
,
isoLanguages
from
.constants
import
BookMeta
from
.constants
import
BookMeta
from
.helper
import
split_authors
from
.helper
import
split_authors
...
@@ -53,7 +53,7 @@ except ImportError as ex:
...
@@ -53,7 +53,7 @@ except ImportError as ex:
from
PyPDF2
import
__version__
as
PyPdfVersion
from
PyPDF2
import
__version__
as
PyPdfVersion
use_pdf_meta
=
True
use_pdf_meta
=
True
except
ImportError
as
e
:
except
ImportError
as
e
:
log
.
debug
(
'Cannot import PyPDF3/PyPDF2, extracting pdf metadata will not work:
%
s /
%
s'
,
e
)
log
.
debug
(
'Cannot import PyPDF3/PyPDF2, extracting pdf metadata will not work:
%
s /
%
s'
,
e
x
,
e
)
use_pdf_meta
=
False
use_pdf_meta
=
False
try
:
try
:
...
@@ -86,7 +86,7 @@ def process(tmp_file_path, original_file_name, original_file_extension, rarExecu
...
@@ -86,7 +86,7 @@ def process(tmp_file_path, original_file_name, original_file_extension, rarExecu
original_file_name
,
original_file_name
,
original_file_extension
,
original_file_extension
,
rarExecutable
)
rarExecutable
)
except
Exception
as
ex
:
except
Exception
as
ex
:
log
.
warning
(
'cannot parse metadata, using default:
%
s'
,
ex
)
log
.
warning
(
'cannot parse metadata, using default:
%
s'
,
ex
)
if
meta
and
meta
.
title
.
strip
()
and
meta
.
author
.
strip
():
if
meta
and
meta
.
title
.
strip
()
and
meta
.
author
.
strip
():
...
@@ -113,12 +113,12 @@ def default_meta(tmp_file_path, original_file_name, original_file_extension):
...
@@ -113,12 +113,12 @@ def default_meta(tmp_file_path, original_file_name, original_file_extension):
def
parse_xmp
(
pdf_file
):
def
parse_xmp
(
pdf_file
):
"""
"""
Parse XMP Metadata and prepare for BookMeta object
Parse XMP Metadata and prepare for BookMeta object
"""
"""
try
:
try
:
xmp_info
=
pdf_file
.
getXmpMetadata
()
xmp_info
=
pdf_file
.
getXmpMetadata
()
except
Exception
as
e
:
except
Exception
as
e
:
log
.
debug
(
'Can not read XMP metadata'
,
e
)
log
.
debug
(
'Can not read XMP metadata
%
e
'
,
e
)
return
None
return
None
if
xmp_info
:
if
xmp_info
:
...
@@ -126,8 +126,8 @@ def parse_xmp(pdf_file):
...
@@ -126,8 +126,8 @@ def parse_xmp(pdf_file):
xmp_author
=
xmp_info
.
dc_creator
# list
xmp_author
=
xmp_info
.
dc_creator
# list
except
AttributeError
:
except
AttributeError
:
xmp_author
=
[
''
]
xmp_author
=
[
''
]
if
xmp_info
.
dc_title
:
if
xmp_info
.
dc_title
:
xmp_title
=
xmp_info
.
dc_title
[
'x-default'
]
xmp_title
=
xmp_info
.
dc_title
[
'x-default'
]
else
:
else
:
xmp_title
=
''
xmp_title
=
''
...
@@ -142,61 +142,16 @@ def parse_xmp(pdf_file):
...
@@ -142,61 +142,16 @@ def parse_xmp(pdf_file):
for
i
in
xmp_info
.
dc_language
:
for
i
in
xmp_info
.
dc_language
:
#calibre-web currently only takes one language.
#calibre-web currently only takes one language.
languages
.
append
(
isoLanguages
.
get_lang3
(
i
))
languages
.
append
(
isoLanguages
.
get_lang3
(
i
))
except
:
except
AttributeError
:
languages
.
append
(
''
)
languages
.
append
(
''
)
xmp_tags
=
', '
.
join
(
xmp_info
.
dc_subject
)
xmp_publisher
=
', '
.
join
(
xmp_info
.
dc_publisher
)
return
{
'author'
:
xmp_author
,
'title'
:
xmp_title
,
'subject'
:
xmp_description
,
'tags'
:
xmp_tags
,
'languages'
:
languages
,
'publisher'
:
xmp_publisher
}
def
parse_xmp
(
pdf_file
):
"""
Parse XMP Metadata and prepare for BookMeta object
"""
try
:
xmp_info
=
pdf_file
.
getXmpMetadata
()
except
Exception
as
e
:
log
.
debug
(
'Can not read XMP metadata'
,
e
)
return
None
if
xmp_info
:
try
:
xmp_author
=
xmp_info
.
dc_creator
# list
except
:
xmp_author
=
[
''
]
if
xmp_info
.
dc_title
:
xmp_title
=
xmp_info
.
dc_title
[
'x-default'
]
else
:
xmp_title
=
''
if
xmp_info
.
dc_description
:
xmp_description
=
xmp_info
.
dc_description
[
'x-default'
]
else
:
xmp_description
=
''
languages
=
[]
try
:
for
i
in
xmp_info
.
dc_language
:
languages
.
append
(
isoLanguages
.
get_lang3
(
i
))
except
AttributeError
:
languages
=
[
""
]
xmp_tags
=
', '
.
join
(
xmp_info
.
dc_subject
)
xmp_tags
=
', '
.
join
(
xmp_info
.
dc_subject
)
xmp_publisher
=
', '
.
join
(
xmp_info
.
dc_publisher
)
xmp_publisher
=
', '
.
join
(
xmp_info
.
dc_publisher
)
return
{
'author'
:
xmp_author
,
return
{
'author'
:
xmp_author
,
'title'
:
xmp_title
,
'title'
:
xmp_title
,
'subject'
:
xmp_description
,
'subject'
:
xmp_description
,
'tags'
:
xmp_tags
,
'tags'
:
xmp_tags
,
'languages'
:
languages
,
'languages'
:
languages
,
'publisher'
:
xmp_publisher
'publisher'
:
xmp_publisher
}
}
...
...
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