mirror of
https://github.com/janeczku/calibre-web
synced 2024-11-24 18:47:23 +00:00
xmp data processing added to the uploader
This commit is contained in:
parent
23fe79c618
commit
22466d6b98
@ -119,10 +119,36 @@ def pdf_meta(tmp_file_path, original_file_name, original_file_extension):
|
|||||||
if use_pdf_meta:
|
if use_pdf_meta:
|
||||||
with open(tmp_file_path, 'rb') as f:
|
with open(tmp_file_path, 'rb') as f:
|
||||||
doc_info = PdfFileReader(f).getDocumentInfo()
|
doc_info = PdfFileReader(f).getDocumentInfo()
|
||||||
if doc_info:
|
xmp_info = PdfFileReader(f).getXmpMetadata()
|
||||||
author = doc_info.author if doc_info.author else u'Unknown'
|
if xmp_info:
|
||||||
title = doc_info.title if doc_info.title else original_file_name
|
xmp_author = xmp_info.dc_creator
|
||||||
subject = doc_info.subject
|
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 = ''
|
||||||
|
if xmp_info.dc_subject:
|
||||||
|
xmp_tags = ', '.join(xmp_info.dc_subject)
|
||||||
|
else:
|
||||||
|
xmp_tags = ''
|
||||||
|
if xmp_info.dc_language:
|
||||||
|
xmp_language = ', '.join(xmp_info.dc_language)
|
||||||
|
else:
|
||||||
|
xmp_language=''
|
||||||
|
if xmp_info.dc_publisher:
|
||||||
|
xmp_publisher = ', '.join(xmp_info.dc_publisher)
|
||||||
|
else:
|
||||||
|
xmp_publisher=''
|
||||||
|
if xmp_info or doc_info:
|
||||||
|
author = xmp_author or split_authors([doc_info.author]) or u'Unknown'
|
||||||
|
title = xmp_title or doc_info.title or original_file_name
|
||||||
|
subject = xmp_description or doc_info.subject
|
||||||
|
publisher = xmp_publisher
|
||||||
|
tags = xmp_tags or doc_info['/Keywords']
|
||||||
|
language = xmp_language
|
||||||
else:
|
else:
|
||||||
author = u'Unknown'
|
author = u'Unknown'
|
||||||
title = original_file_name
|
title = original_file_name
|
||||||
@ -132,13 +158,13 @@ def pdf_meta(tmp_file_path, original_file_name, original_file_extension):
|
|||||||
file_path=tmp_file_path,
|
file_path=tmp_file_path,
|
||||||
extension=original_file_extension,
|
extension=original_file_extension,
|
||||||
title=title,
|
title=title,
|
||||||
author=' & '.join(split_authors([author])),
|
author=' & '.join(author),
|
||||||
cover=pdf_preview(tmp_file_path, original_file_name),
|
cover=pdf_preview(tmp_file_path, original_file_name),
|
||||||
description=subject,
|
description=subject,
|
||||||
tags=doc_info['/Keywords'],
|
tags=tags,
|
||||||
series="",
|
series="",
|
||||||
series_id="",
|
series_id="",
|
||||||
languages="")
|
languages=language)
|
||||||
|
|
||||||
|
|
||||||
def pdf_preview(tmp_file_path, tmp_dir):
|
def pdf_preview(tmp_file_path, tmp_dir):
|
||||||
|
Loading…
Reference in New Issue
Block a user