Add epub.get_dates and add "(Year)" to the headerfile template.
This commit is contained in:
parent
4f44cd642f
commit
256aeee5d5
1 changed files with 14 additions and 0 deletions
14
epubfile.py
14
epubfile.py
|
@ -898,6 +898,11 @@ class Epub:
|
||||||
creators = [str(c.contents[0]) for c in creators if len(c.contents) == 1]
|
creators = [str(c.contents[0]) for c in creators if len(c.contents) == 1]
|
||||||
return creators
|
return creators
|
||||||
|
|
||||||
|
def get_dates(self):
|
||||||
|
dates = self.opf.metadata.find_all({'dc:date'})
|
||||||
|
dates = [str(t.contents[0]) for t in dates if len(t.contents) == 1]
|
||||||
|
return dates
|
||||||
|
|
||||||
def get_languages(self):
|
def get_languages(self):
|
||||||
languages = self.opf.metadata.find_all({'dc:language'})
|
languages = self.opf.metadata.find_all({'dc:language'})
|
||||||
languages = [str(l.contents[0]) for l in languages if len(l.contents) == 1]
|
languages = [str(l.contents[0]) for l in languages if len(l.contents) == 1]
|
||||||
|
@ -1603,8 +1608,17 @@ def merge(
|
||||||
title = input_book.get_titles()[0]
|
title = input_book.get_titles()[0]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
title = input_filepath.replace_extension('').basename
|
title = input_filepath.replace_extension('').basename
|
||||||
|
|
||||||
|
try:
|
||||||
|
year = input_book.get_dates()[0]
|
||||||
|
except IndexError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
title = f'{title} ({year})'
|
||||||
|
|
||||||
if number_headerfile:
|
if number_headerfile:
|
||||||
title = f'{index:>0{index_length}}. {title}'
|
title = f'{index:>0{index_length}}. {title}'
|
||||||
|
|
||||||
content += f'<h1>{html.escape(title)}</h1>'
|
content += f'<h1>{html.escape(title)}</h1>'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue