diff --git a/fanficfare/cli.py b/fanficfare/cli.py index 750546e1..58aec07c 100644 --- a/fanficfare/cli.py +++ b/fanficfare/cli.py @@ -411,6 +411,12 @@ def do_download(arg, if not options.update and chaptercount == urlchaptercount and adapter.getConfig('do_update_hook'): adapter.hookForUpdates(chaptercount) + if adapter.getConfig('pre_process_safepattern'): + metadata = adapter.story.get_filename_safe_metadata(pattern=adapter.getConfig('pre_process_safepattern')) + else: + metadata = adapter.story.getAllMetadata() + call(string.Template(adapter.getConfig('pre_process_cmd')).substitute(metadata), shell=True) + write_story(configuration, adapter, 'epub') else: @@ -427,6 +433,13 @@ def do_download(arg, else: pprint.pprint(metadata) + if not options.metaonly and adapter.getConfig('pre_process_cmd'): + if adapter.getConfig('pre_process_safepattern'): + metadata = adapter.story.get_filename_safe_metadata(pattern=adapter.getConfig('pre_process_safepattern')) + else: + metadata = adapter.story.getAllMetadata() + call(string.Template(adapter.getConfig('pre_process_cmd')).substitute(metadata), shell=True) + output_filename = write_story(configuration, adapter, options.format, options.metaonly) if not options.metaonly and adapter.getConfig('post_process_cmd'): diff --git a/fanficfare/defaults.ini b/fanficfare/defaults.ini index 0db3243e..e3c1adab 100644 --- a/fanficfare/defaults.ini +++ b/fanficfare/defaults.ini @@ -203,6 +203,18 @@ connect_timeout:60.0 ## each metadata item passed to post_process_cmd before it's called. #post_process_safepattern:(^\.|/\.|[^a-zA-Z0-9_\. \[\]\(\)&'-]+) +## For use only with CLI version--run a command 3*before* the output +## file is written. All of the titlepage_entries values are +## available, (but not output_filename). Can be used to generate +## cover images that are then included in the output ebook using +## default_cover_image. +#pre_process_cmd:tenprintcover.py --author "${author}" --title "${title}" --cover cover.png + +## Some operating systems and command shells have problems with some +## characters. When set, pre_process_safepattern will be applied to +## each metadata item passed to pre_process_cmd before it's called. +#pre_process_safepattern:(^\.|/\.|[^a-zA-Z0-9_\. \[\]\(\)&'-]+) + ## For use only with CLI version--display a simple progress bar while ## downloading--one dot(.) per network fetch. Same as using --progressbar #progressbar:false