Skip to content

Commit

Permalink
Apply mark_new_chapters to new story chapters in Anthologies. #977
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmXinu committed Jul 12, 2023
1 parent eaeeda6 commit 7502c0f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
11 changes: 11 additions & 0 deletions calibre-plugin/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down
7 changes: 7 additions & 0 deletions calibre-plugin/plugin-defaults.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions fanficfare/configurable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion fanficfare/story.py
Original file line number Diff line number Diff line change
Expand Up @@ -1409,7 +1409,7 @@ def getChapters(self,fortoc=False):
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
Expand Down

0 comments on commit 7502c0f

Please sign in to comment.