Skip to content

Commit

Permalink
First rough version of reporting continue_on_chapter_error chapters.
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmXinu committed Jan 16, 2021
1 parent 0cb2053 commit 6e68624
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 5 deletions.
9 changes: 8 additions & 1 deletion calibre-plugin/fff_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1856,6 +1856,7 @@ def download_list_completed(self, job, options={},merge=False):
book_list = job.result
good_list = [ x for x in book_list if x['good'] ]
bad_list = [ x for x in book_list if not x['good'] ]
chapter_error_list = [ x for x in book_list if 'chapter_error_count' in x ]
try:
good_list = sorted(good_list,key=lambda x : x['reportorder'])
bad_list = sorted(bad_list,key=lambda x : x['reportorder'])
Expand All @@ -1865,9 +1866,15 @@ def download_list_completed(self, job, options={},merge=False):
#print("book_list:%s"%book_list)
payload = (good_list, bad_list, options)

if chapter_error_list:
info_dialog(self.gui, _('FanFicFare: ')+_('Some Failed Chapters'),
_('Some of the stories downloaded have failed chapters. Click View Log in the next dialog to see which.'),
show=True,
show_copy_button=False)

if merge:
if len(good_list) < 1:
info_dialog(self.gui, _('No Good Stories for Anthology'),
info_dialog(self.gui, _('FanFicFare: ')+_('No Good Stories for Anthology'),
_('No good stories/updates where downloaded, Anthology creation/update aborted.'),
show=True,
show_copy_button=False)
Expand Down
20 changes: 17 additions & 3 deletions calibre-plugin/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,16 @@ def do_download_for_worker(book,options,merge,notification=lambda x,y:x):
inject_cal_cols(book,story,configuration)
writer.writeStory(outfilename=outfile, forceOverwrite=True)

book['comment'] = _('Download %s completed, %s chapters.')%(options['fileform'],story.getMetadata("numChapters"))
if adapter.story.chapter_error_count > 0:
book['comment'] = _('Download %(fileform)s completed, %(failed)s failed chapters, %(total)s total chapters.')%\
{'fileform':options['fileform'],
'failed':adapter.story.chapter_error_count,
'total':story.getMetadata("numChapters")}
book['chapter_error_count'] = adapter.story.chapter_error_count
else:
book['comment'] = _('Download %(fileform)s completed, %(total)s chapters.')%\
{'fileform':options['fileform'],
'total':story.getMetadata("numChapters")}
book['all_metadata'] = story.getAllMetadata(removeallentities=True)
if options['savemetacol'] != '':
book['savemetacol'] = story.dump_html_metadata()
Expand Down Expand Up @@ -297,8 +306,13 @@ def do_download_for_worker(book,options,merge,notification=lambda x,y:x):
inject_cal_cols(book,story,configuration)
writer.writeStory(outfilename=outfile, forceOverwrite=True)

book['comment'] = _('Update %(fileform)s completed, added %(added)s chapters for %(total)s total.')%\
{'fileform':options['fileform'],'added':(urlchaptercount-chaptercount),'total':urlchaptercount}
if adapter.story.chapter_error_count > 0:
book['comment'] = _('Update %(fileform)s completed, added %(added)s chapters, %(failed)s failed chapters, for %(total)s total.')%\
{'fileform':options['fileform'],'added':(urlchaptercount-chaptercount),'total':urlchaptercount}
book['chapter_error_count'] = adapter.story.chapter_error_count
else:
book['comment'] = _('Update %(fileform)s completed, added %(added)s chapters for %(total)s total.')%\
{'fileform':options['fileform'],'added':(urlchaptercount-chaptercount),'total':urlchaptercount}
book['all_metadata'] = story.getAllMetadata(removeallentities=True)
if options['savemetacol'] != '':
book['savemetacol'] = story.dump_html_metadata()
Expand Down
1 change: 1 addition & 0 deletions fanficfare/adapters/base_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ def getStory(self):
</div>"""%(url,traceback.format_exc().replace("&","&amp;").replace(">","&gt;").replace("<","&lt;")))
title = title+self.getConfig("chapter_title_error_mark","(CHAPTER ERROR)")
url="chapter url removed due to failure"
self.story.chapter_error_count += 1
else:
raise

Expand Down
4 changes: 3 additions & 1 deletion fanficfare/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,9 @@ def do_download(arg,
import json
print(json.dumps(metadata, sort_keys=True,
indent=2, separators=(',', ':')))

if adapter.story.chapter_error_count > 0:
print("%s chapters errored downloading %s"%(adapter.story.chapter_error_count,
url))
del adapter

except exceptions.InvalidStoryURL as isu:
Expand Down
2 changes: 2 additions & 0 deletions fanficfare/story.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,8 @@ def __init__(self, configuration):

self.replacements_prepped = False

self.chapter_error_count = 0

def prepare_replacements(self):
if not self.replacements_prepped and not self.is_lightweight():
# logger.debug("prepare_replacements")
Expand Down

0 comments on commit 6e68624

Please sign in to comment.