Add latestonly option to mark_new_chapters feature to remove pre-existing (new) chpater marks on update and only mark chapters that are new in this update. Closes #330

This commit is contained in:
Jim Miller 2018-08-22 15:45:46 -05:00
parent 4d3579dc66
commit 7a8c16847c
5 changed files with 21 additions and 10 deletions

View file

@ -396,7 +396,12 @@ chapter_title_strip_pattern:^[0-9]+[\.: -]+(?=[^0-9]|$)
## If true, when updating an epub that already has old chapters, new
## chapters will be marked in the TOC and chapter header by using
## chapter_title_new_pattern and chapter_title_addnew_pattern to set the chapter.
## chapter_title_new_pattern and chapter_title_addnew_pattern to set
## the chapter title.
## If set to latestonly, only new chapters downloaded this time will
## be marked (new) and existing chapters will have any (new) marks
## removed.
## mark_new_chapters can be true, false or latestonly
mark_new_chapters:false
## chapter title patterns use python template substitution. The

View file

@ -209,12 +209,13 @@ class BaseSiteAdapter(Configurable):
self.oldchapters[index],
partial(cachedfetch,self._fetchUrlRaw,self.oldimgs))
# if already marked new -- ie, origtitle and title don't match
# logger.debug("self.oldchaptersdata[url]:%s"%(self.oldchaptersdata[url]))
newchap = (self.oldchaptersdata is not None and
url in self.oldchaptersdata and (
self.oldchaptersdata[url]['chapterorigtitle'] !=
self.oldchaptersdata[url]['chaptertitle']) )
if self.getConfig('mark_new_chapters') == 'true':
# if already marked new -- ie, origtitle and title don't match
# logger.debug("self.oldchaptersdata[url]:%s"%(self.oldchaptersdata[url]))
newchap = (self.oldchaptersdata is not None and
url in self.oldchaptersdata and (
self.oldchaptersdata[url]['chapterorigtitle'] !=
self.oldchaptersdata[url]['chaptertitle']) )
try:
if not data:

View file

@ -204,7 +204,7 @@ def get_valid_set_options():
'replace_hr':(None,None,boollist),
'sort_ships':(None,None,boollist),
'strip_chapter_numbers':(None,None,boollist),
'mark_new_chapters':(None,None,boollist),
'mark_new_chapters':(None,None,boollist+['latestonly']),
'titlepage_use_table':(None,None,boollist),
'use_ssl_unverified_context':(None,None,boollist),

View file

@ -399,7 +399,12 @@ chapter_title_strip_pattern:^[0-9]+[\.: -]+(?=[^0-9]|$)
## If true, when updating an epub that already has old chapters, new
## chapters will be marked in the TOC and chapter header by using
## chapter_title_new_pattern and chapter_title_addnew_pattern to set the chapter.
## chapter_title_new_pattern and chapter_title_addnew_pattern to set
## the chapter title.
## If set to latestonly, only new chapters downloaded this time will
## be marked (new) and existing chapters will have any (new) marks
## removed.
## mark_new_chapters can be true, false or latestonly
mark_new_chapters:false
## chapter title patterns use python template substitution. The

View file

@ -1046,7 +1046,7 @@ class Story(Configurable):
addnums = ( self.getConfig('add_chapter_numbers') == "true"
or (self.getConfig('add_chapter_numbers') == "toconly" and fortoc) )
marknew = self.getConfig('mark_new_chapters')=='true'
marknew = self.getConfig('mark_new_chapters') # true or latestonly
defpattern = self.getConfig('chapter_title_def_pattern','${title}') # default val in case of missing defaults.ini
if addnums and marknew: