mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
FB2 metadata: Add support for setting publisher and publish year
This commit is contained in:
parent
2af560fe8a
commit
6b9b298594
@ -356,6 +356,22 @@ def _set_authors(title_info, mi, ctx):
|
|||||||
ctx.create_tag(atag, 'last-name', at_start=False).text = ' '.join(author_parts)
|
ctx.create_tag(atag, 'last-name', at_start=False).text = ' '.join(author_parts)
|
||||||
|
|
||||||
|
|
||||||
|
def _set_publisher(publish_info, mi, ctx):
|
||||||
|
if mi.is_null('publisher'):
|
||||||
|
return
|
||||||
|
ctx.clear_meta_tags(publish_info, 'publisher')
|
||||||
|
tag = ctx.create_tag(publish_info, 'publisher')
|
||||||
|
tag.text = mi.publisher
|
||||||
|
|
||||||
|
|
||||||
|
def _set_pubdate(publish_info, mi, ctx):
|
||||||
|
if mi.is_null('pubdate'):
|
||||||
|
return
|
||||||
|
ctx.clear_meta_tags(publish_info, 'year')
|
||||||
|
tag = ctx.create_tag(publish_info, 'year')
|
||||||
|
tag.text = mi.pubdate.strftime('%Y')
|
||||||
|
|
||||||
|
|
||||||
def _set_tags(title_info, mi, ctx):
|
def _set_tags(title_info, mi, ctx):
|
||||||
if not mi.is_null('tags'):
|
if not mi.is_null('tags'):
|
||||||
ctx.clear_meta_tags(title_info, 'genre')
|
ctx.clear_meta_tags(title_info, 'genre')
|
||||||
@ -410,6 +426,7 @@ def set_metadata(stream, mi, apply_null=False, update_timestamp=False):
|
|||||||
ctx = Context(root)
|
ctx = Context(root)
|
||||||
desc = ctx.get_or_create(root, 'description')
|
desc = ctx.get_or_create(root, 'description')
|
||||||
ti = ctx.get_or_create(desc, 'title-info')
|
ti = ctx.get_or_create(desc, 'title-info')
|
||||||
|
pi = ctx.get_or_create(desc, 'publish-info')
|
||||||
|
|
||||||
indent = ti.text
|
indent = ti.text
|
||||||
|
|
||||||
@ -418,6 +435,8 @@ def set_metadata(stream, mi, apply_null=False, update_timestamp=False):
|
|||||||
_set_tags(ti, mi, ctx)
|
_set_tags(ti, mi, ctx)
|
||||||
_set_authors(ti, mi, ctx)
|
_set_authors(ti, mi, ctx)
|
||||||
_set_title(ti, mi, ctx)
|
_set_title(ti, mi, ctx)
|
||||||
|
_set_publisher(pi, mi, ctx)
|
||||||
|
_set_pubdate(pi, mi, ctx)
|
||||||
_set_cover(ti, mi, ctx)
|
_set_cover(ti, mi, ctx)
|
||||||
|
|
||||||
for child in ti:
|
for child in ti:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user