mirror of
https://github.com/JimmXinu/FanFicFare.git
synced 2026-05-08 21:11:59 +02:00
Replace post_process_apply_filename_safepattern with post_process_safepattern so it can have its own pattern.
This commit is contained in:
parent
587b24ef82
commit
34ec12ea1e
3 changed files with 11 additions and 11 deletions
|
|
@ -175,7 +175,7 @@ def main(argv=None,
|
|||
options.downloadlist))):
|
||||
parser.print_help();
|
||||
return
|
||||
|
||||
|
||||
if options.list:
|
||||
configuration = get_configuration(options.list,
|
||||
passed_defaultsini,
|
||||
|
|
@ -378,8 +378,8 @@ def do_download(arg,
|
|||
output_filename = write_story(configuration, adapter, options.format, options.metaonly)
|
||||
|
||||
if not options.metaonly and adapter.getConfig('post_process_cmd'):
|
||||
if adapter.getConfig('post_process_apply_filename_safepattern'):
|
||||
metadata = adapter.story.get_filename_safe_metadata()
|
||||
if adapter.getConfig('post_process_safepattern'):
|
||||
metadata = adapter.story.get_filename_safe_metadata(pattern=adapter.getConfig('post_process_safepattern'))
|
||||
else:
|
||||
metadata = adapter.story.getAllMetadata()
|
||||
metadata['output_filename'] = output_filename
|
||||
|
|
|
|||
|
|
@ -195,10 +195,9 @@ connect_timeout:60.0
|
|||
#post_process_cmd: addbook -f "${output_filename}" -t "${title}"
|
||||
|
||||
## Some operating systems and command shells have problems with some
|
||||
## characters. When true, the output_filename_safepattern will be
|
||||
## applied to each metadata item passed to post_process_cmd before
|
||||
## it's called.
|
||||
#post_process_apply_filename_safepattern:false
|
||||
## characters. When set, post_process_safepattern will be applied to
|
||||
## each metadata item passed to post_process_cmd before it's called.
|
||||
#post_process_safepattern:(^\.|/\.|[^a-zA-Z0-9_\. \[\]\(\)&'-]+)
|
||||
|
||||
## Use regular expressions to find and replace (or remove) metadata.
|
||||
## For example, you could change Sci-Fi=>SF, remove *-Centered tags,
|
||||
|
|
|
|||
|
|
@ -1031,12 +1031,13 @@ class Story(Configurable):
|
|||
|
||||
return retval
|
||||
|
||||
def get_filename_safe_metadata(self):
|
||||
def get_filename_safe_metadata(self,pattern=None):
|
||||
origvalues = self.getAllMetadata()
|
||||
values={}
|
||||
pattern = re_compile(self.getConfig("output_filename_safepattern",
|
||||
r"(^\.|/\.|[^a-zA-Z0-9_\. \[\]\(\)&'-]+)"),
|
||||
"output_filename_safepattern")
|
||||
if not pattern:
|
||||
pattern = re_compile(self.getConfig("output_filename_safepattern",
|
||||
r"(^\.|/\.|[^a-zA-Z0-9_\. \[\]\(\)&'-]+)"),
|
||||
"output_filename_safepattern")
|
||||
for k in origvalues.keys():
|
||||
if k == 'formatext': # don't do file extension--we set it anyway.
|
||||
values[k]=self.getMetadata(k)
|
||||
|
|
|
|||
Loading…
Reference in a new issue