Apply mark_new_chapters to new story chapters in Anthologies. #977

This commit is contained in:
Jim Miller 2023-07-12 12:48:13 -05:00
parent eaeeda6911
commit 7502c0f2fb
4 changed files with 22 additions and 1 deletions

View file

@ -251,6 +251,17 @@ def do_download_for_worker(book,options,merge,notification=lambda x,y:x):
if not story.getMetadata("series") and 'calibre_series' in book:
adapter.setSeries(book['calibre_series'][0],book['calibre_series'][1])
# logger.debug(merge)
# logger.debug(book.get('epub_for_update','(NONE)'))
# logger.debug(options.get('mergebook','(NOMERGEBOOK)'))
# is a merge, is a pre-existing anthology, and is not a pre-existing book in anthology.
if merge and 'mergebook' in options and 'epub_for_update' not in book:
# internal for plugin anthologies to mark chapters
# (new) in new stories
story.setMetadata("newforanthology","true")
logger.debug("metadata newforanthology:%s"%story.getMetadata("newforanthology"))
# set PI version instead of default.
if 'version' in options:
story.setMetadata('version',options['version'])

View file

@ -471,6 +471,13 @@ chapter_title_strip_pattern:^[0-9]+[\.: -]+(?=[^0-9]|$)
## If set to latestonly, only new chapters downloaded this time will
## be marked (new) and existing chapters will have any (new) marks
## removed.
##
## (Plugin Only) - New stories added to an existing anthology will
## have *all* chapters marked (new). If set to latestonly, existing
## (new) marks will only be removed when that particular story within
## the anthology is updated--either because it has new chapter(s) or
## you are using Update Always.
##
## mark_new_chapters can be true, false or latestonly
mark_new_chapters:false

View file

@ -342,6 +342,9 @@ def get_valid_scalar_entries():
'langcode',
'output_css',
'cover_image',
'newforanthology' # internal for plugin anthologies
# to mark chapters (new) in new
# stories
])
def get_valid_entries():

View file

@ -1409,7 +1409,7 @@ class Story(Requestable):
toctempl = string.Template(tocpattern)
for index, chap in enumerate(self.chapters):
if chap['new']:
if chap['new'] or self.getMetadata('newforanthology'):
usetempl = newtempl
else:
usetempl = templ