Skip to content

Commit

Permalink
Add force_update_epub_always option to update when EPUB has more chap…
Browse files Browse the repository at this point in the history
…ters than source. See #950 #949 #942.
  • Loading branch information
JimmXinu committed May 5, 2023
1 parent 8b20756 commit f3d2513
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion calibre-plugin/fff_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1548,7 +1548,7 @@ def prep_download_loop(self,book,
if chaptercount == urlchaptercount:
if collision == UPDATE:
raise NotGoingToDownload(_("Already contains %d chapters.")%chaptercount,'edit-undo.png',showerror=False)
elif chaptercount > urlchaptercount:
elif chaptercount > urlchaptercount and not (collision == UPDATEALWAYS and adapter.getConfig('force_update_epub_always')):
raise NotGoingToDownload(_("Existing epub contains %d chapters, web site only has %d. Use Overwrite to force update.") % (chaptercount,urlchaptercount),'dialog_error.png')
elif chaptercount == 0:
raise NotGoingToDownload(_("FanFicFare doesn't recognize chapters in existing epub, epub is probably from a different source. Use Overwrite to force update."),'dialog_error.png')
Expand Down
11 changes: 11 additions & 0 deletions calibre-plugin/plugin-defaults.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1286,6 +1286,17 @@ nook_img_fix:true
## useful for CLI and web service--the calibre plugin doesn't need it.
#calibre_series_meta:false

## By default, FanFicFare will not update an existing EPUB that has
## more chapters than the story does on the source site. When
## force_update_epub_always:true FFF will ignore that check when using
## 'Update EPUB Always' (plugin) or -U/--update-epub-always (CLI) and
## will discard chapters in the EPUB that are not listed on the source
## site anymore.
## This can be useful for authors that remove and/or replace chapters.
## Recommended to be set for individual stories or sites rather than
## under [defaults] or [epub].
#force_update_epub_always:false

[html]

## include images from img tags in the body and summary of
Expand Down
2 changes: 1 addition & 1 deletion fanficfare/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ def do_download(arg,

if chaptercount == urlchaptercount and not options.metaonly and not options.updatealways:
print('%s already contains %d chapters.' % (output_filename, chaptercount))
elif chaptercount > urlchaptercount:
elif chaptercount > urlchaptercount and not (options.updatealways and adapter.getConfig('force_update_epub_always')):
warn('%s contains %d chapters, more than source: %d.' % (output_filename, chaptercount, urlchaptercount))
elif chaptercount == 0:
warn("%s doesn't contain any recognizable chapters, probably from a different source. Not updating." % output_filename)
Expand Down
2 changes: 2 additions & 0 deletions fanficfare/configurable.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ def get_valid_set_options():
'logpage_at_end':(None,['epub'],boollist),

'calibre_series_meta':(None,['epub'],boollist),
'force_update_epub_always':(None,['epub'],boollist),

'windows_eol':(None,['txt'],boollist),

Expand Down Expand Up @@ -412,6 +413,7 @@ def get_valid_keywords():
'include_logpage',
'logpage_at_end',
'calibre_series_meta',
'force_update_epub_always',
'include_subject_tags',
'include_titlepage',
'include_tocpage',
Expand Down
11 changes: 11 additions & 0 deletions fanficfare/defaults.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1285,6 +1285,17 @@ nook_img_fix:true
## useful for CLI and web service--the calibre plugin doesn't need it.
#calibre_series_meta:false

## By default, FanFicFare will not update an existing EPUB that has
## more chapters than the story does on the source site. When
## force_update_epub_always:true FFF will ignore that check when using
## 'Update EPUB Always' (plugin) or -U/--update-epub-always (CLI) and
## will discard chapters in the EPUB that are not listed on the source
## site anymore.
## This can be useful for authors that remove and/or replace chapters.
## Recommended to be set for individual stories or sites rather than
## under [defaults] or [epub].
#force_update_epub_always:false

[html]

## include images from img tags in the body and summary of
Expand Down

0 comments on commit f3d2513

Please sign in to comment.