mirror of
https://github.com/janeczku/calibre-web
synced 2024-11-24 18:47:23 +00:00
Added tags metadata handler for epubs
This commit is contained in:
parent
cd2e27d7ad
commit
4bba3558b7
@ -43,13 +43,16 @@ def get_epub_info(tmp_file_path, original_file_name, original_file_extension):
|
||||
|
||||
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)
|
||||
if len(tmp) > 0:
|
||||
epub_metadata[s] = p.xpath('dc:%s/text()' % s, namespaces=ns)[0]
|
||||
else:
|
||||
epub_metadata[s] = "Unknown"
|
||||
|
||||
if epub_metadata['subject'] == "Unknown":
|
||||
epub_metadata['subject'] = ''
|
||||
|
||||
if epub_metadata['description'] == "Unknown":
|
||||
description = tree.xpath("//*[local-name() = 'description']/text()")
|
||||
if len(description) > 0:
|
||||
@ -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'),
|
||||
cover=coverfile,
|
||||
description=epub_metadata['description'],
|
||||
tags="",
|
||||
tags=epub_metadata['subject'].encode('utf-8').decode('utf-8'),
|
||||
series="",
|
||||
series_id="",
|
||||
languages=epub_metadata['language'])
|
||||
|
@ -2928,7 +2928,7 @@ def upload():
|
||||
|
||||
title = meta.title
|
||||
author = meta.author
|
||||
|
||||
tags = meta.tags
|
||||
title_dir = helper.get_valid_filename(title, False)
|
||||
author_dir = helper.get_valid_filename(author, False)
|
||||
data_name = title_dir
|
||||
@ -2995,6 +2995,11 @@ def upload():
|
||||
if upload_comment != "":
|
||||
db.session.add(db.Comments(upload_comment, db_book.id))
|
||||
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
|
||||
db_book.languages[0].language_name = _(meta.languages)
|
||||
author_names = []
|
||||
|
Loading…
Reference in New Issue
Block a user