mirror of
https://github.com/JimmXinu/FanFicFare.git
synced 2025-12-06 08:52:55 +01:00
Add continue_on_chapter_error_try_limit setting
This commit is contained in:
parent
02e3bddd5c
commit
096face5d2
5 changed files with 52 additions and 8 deletions
|
|
@ -673,6 +673,15 @@ browser_cache_age_limit:4.0
|
||||||
## an error message in the ebook for that chapter.
|
## an error message in the ebook for that chapter.
|
||||||
continue_on_chapter_error:false
|
continue_on_chapter_error:false
|
||||||
|
|
||||||
|
## When continue_on_chapter_error:true, after
|
||||||
|
## continue_on_chapter_error_try_limit chapters have failed, continue
|
||||||
|
## processing, but stop trying to download chapters. Mark all such
|
||||||
|
## chapters with chapter_title_error_mark, but chapter text will
|
||||||
|
## explain that no download attempt was made because
|
||||||
|
## continue_on_chapter_error_try_limit was exceeded. Set to -1 for
|
||||||
|
## infinite chapter errors.
|
||||||
|
continue_on_chapter_error_try_limit:5
|
||||||
|
|
||||||
## Append this to chapter titles that errored. Only used with
|
## Append this to chapter titles that errored. Only used with
|
||||||
## continue_on_chapter_error:true
|
## continue_on_chapter_error:true
|
||||||
## Set empty to not mark failed chapters.
|
## Set empty to not mark failed chapters.
|
||||||
|
|
|
||||||
|
|
@ -366,7 +366,7 @@ Some more longer description. "I suck at summaries!" "Better than it sounds!"
|
||||||
<br />
|
<br />
|
||||||
</div>
|
</div>
|
||||||
'''
|
'''
|
||||||
elif self.story.getMetadata('storyId') == '667' and "chapter=2" in url:
|
elif self.story.getMetadata('storyId') == '667' and ("chapter=2" in url or "chapter=3" in url or "chapter=4" in url):
|
||||||
raise exceptions.FailedToDownload("Error downloading Chapter: %s!" % url)
|
raise exceptions.FailedToDownload("Error downloading Chapter: %s!" % url)
|
||||||
elif self.getSiteDomain() not in url:
|
elif self.getSiteDomain() not in url:
|
||||||
## for chapter_urls setting.
|
## for chapter_urls setting.
|
||||||
|
|
|
||||||
|
|
@ -230,6 +230,21 @@ class BaseSiteAdapter(Requestable):
|
||||||
percent = 0.0
|
percent = 0.0
|
||||||
per_step = 1.0/self.story.getChapterCount()
|
per_step = 1.0/self.story.getChapterCount()
|
||||||
# logger.debug("self.story.getChapterCount():%s per_step:%s"%(self.story.getChapterCount(),per_step))
|
# logger.debug("self.story.getChapterCount():%s per_step:%s"%(self.story.getChapterCount(),per_step))
|
||||||
|
continue_on_chapter_error_try_limit = 5
|
||||||
|
try:
|
||||||
|
continue_on_chapter_error_try_limit = int(self.getConfig('continue_on_chapter_error_try_limit',
|
||||||
|
continue_on_chapter_error_try_limit))
|
||||||
|
except:
|
||||||
|
logger.warning('Parsing continue_on_chapter_error_try_limit:%s failed, using %s'%(
|
||||||
|
self.getConfig('continue_on_chapter_error_try_limit'),
|
||||||
|
continue_on_chapter_error_try_limit))
|
||||||
|
|
||||||
|
def do_error_chapter(txt,title):
|
||||||
|
data = self.make_soup(txt)
|
||||||
|
title = title+self.getConfig("chapter_title_error_mark","(CHAPTER ERROR)")
|
||||||
|
url="chapter url removed due to failure"
|
||||||
|
return data, title, url
|
||||||
|
|
||||||
for index, chap in enumerate(self.chapterUrls):
|
for index, chap in enumerate(self.chapterUrls):
|
||||||
title = chap['title']
|
title = chap['title']
|
||||||
url = chap['url']
|
url = chap['url']
|
||||||
|
|
@ -263,6 +278,18 @@ class BaseSiteAdapter(Requestable):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not data:
|
if not data:
|
||||||
|
if( self.getConfig('continue_on_chapter_error') and
|
||||||
|
continue_on_chapter_error_try_limit > 0 and # for -1 == infinite
|
||||||
|
self.story.chapter_error_count >= continue_on_chapter_error_try_limit ):
|
||||||
|
data, title, url = do_error_chapter("""<div>
|
||||||
|
<p><b>Error</b></p>
|
||||||
|
<p>FanFicFare didn't try to download this chapter, due to earlier chapter errors.</p><p>
|
||||||
|
Because <b>continue_on_chapter_error:true</b> is set, processing continued, but because
|
||||||
|
<b>continue_on_chapter_error_try_limit</b>(%s) has been exceeded, this chapter did not
|
||||||
|
try to download.</p>
|
||||||
|
<p>Chapter URL:<br><a href="%s">%s</a></p>
|
||||||
|
</div>"""%(continue_on_chapter_error_try_limit,url,url),title)
|
||||||
|
else:
|
||||||
data = self.getChapterTextNum(url,index)
|
data = self.getChapterTextNum(url,index)
|
||||||
# if had to fetch and has existing chapters
|
# if had to fetch and has existing chapters
|
||||||
newchap = bool(self.oldchapters or self.oldchaptersmap)
|
newchap = bool(self.oldchapters or self.oldchaptersmap)
|
||||||
|
|
@ -275,17 +302,15 @@ class BaseSiteAdapter(Requestable):
|
||||||
newchap = False
|
newchap = False
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if self.getConfig('continue_on_chapter_error',False):
|
if self.getConfig('continue_on_chapter_error',False):
|
||||||
data = self.make_soup("""<div>
|
data, title, url = do_error_chapter("""<div>
|
||||||
<p><b>Error</b></p>
|
<p><b>Error</b></p>
|
||||||
<p>FanFicFare failed to download this chapter. Because
|
<p>FanFicFare failed to download this chapter. Because
|
||||||
<b>continue_on_chapter_error</b> is set to <b>true</b>, the download continued.</p>
|
<b>continue_on_chapter_error</b> is set to <b>true</b>, the download continued.</p>
|
||||||
<p>Chapter URL:<br><a href="%s">%s</a></p>
|
<p>Chapter URL:<br><a href="%s">%s</a></p>
|
||||||
<p>Error:<br><pre>%s</pre></p>
|
<p>Error:<br><pre>%s</pre></p>
|
||||||
</div>"""%(url,url,traceback.format_exc().replace("&","&").replace(">",">").replace("<","<")))
|
</div>"""%(url,url,traceback.format_exc().replace("&","&").replace(">",">").replace("<","<")),title)
|
||||||
title = title+self.getConfig("chapter_title_error_mark","(CHAPTER ERROR)")
|
|
||||||
logger.info("continue_on_chapter_error: (%s) %s"%(url,e))
|
logger.info("continue_on_chapter_error: (%s) %s"%(url,e))
|
||||||
logger.debug(traceback.format_exc())
|
logger.debug(traceback.format_exc())
|
||||||
url="chapter url removed due to failure"
|
|
||||||
self.story.chapter_error_count += 1
|
self.story.chapter_error_count += 1
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
|
||||||
|
|
@ -568,6 +568,7 @@ def get_valid_keywords():
|
||||||
'capitalize_forumtags',
|
'capitalize_forumtags',
|
||||||
'continue_on_chapter_error',
|
'continue_on_chapter_error',
|
||||||
'chapter_title_error_mark',
|
'chapter_title_error_mark',
|
||||||
|
'continue_on_chapter_error_try_limit',
|
||||||
'minimum_threadmarks',
|
'minimum_threadmarks',
|
||||||
'first_post_title',
|
'first_post_title',
|
||||||
'always_include_first_post',
|
'always_include_first_post',
|
||||||
|
|
|
||||||
|
|
@ -631,6 +631,15 @@ browser_cache_age_limit:4.0
|
||||||
## an error message in the ebook for that chapter.
|
## an error message in the ebook for that chapter.
|
||||||
continue_on_chapter_error:false
|
continue_on_chapter_error:false
|
||||||
|
|
||||||
|
## When continue_on_chapter_error:true, after
|
||||||
|
## continue_on_chapter_error_try_limit chapters have failed, continue
|
||||||
|
## processing, but stop trying to download chapters. Mark all such
|
||||||
|
## chapters with chapter_title_error_mark, but chapter text will
|
||||||
|
## explain that no download attempt was made because
|
||||||
|
## continue_on_chapter_error_try_limit was exceeded. Set to -1 for
|
||||||
|
## infinite chapter errors.
|
||||||
|
continue_on_chapter_error_try_limit:5
|
||||||
|
|
||||||
## Append this to chapter titles that errored. Only used with
|
## Append this to chapter titles that errored. Only used with
|
||||||
## continue_on_chapter_error:true
|
## continue_on_chapter_error:true
|
||||||
## Set empty to not mark failed chapters.
|
## Set empty to not mark failed chapters.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue