Improve output template internal formatting

* Allow slicing lists/strings using `field.start🔚step`
* A field can also be used as offset like `field1+num+field2`
* A default value can be given using `field|default`
* Capture all format strings and set it to `None` if invalid. This prevents invalid fields from causing errors
This commit is contained in:
pukkandan
2021-05-03 22:36:03 +05:30
parent 12e73423f1
commit e625be0d10
4 changed files with 71 additions and 32 deletions

View File

@@ -24,7 +24,7 @@ class ExecAfterDownloadPP(PostProcessor):
def parse_cmd(self, cmd, info):
# If no %(key)s is found, replace {} for backard compatibility
if not re.search(FORMAT_RE.format(r'[-\w>.+]+'), cmd):
if not re.search(FORMAT_RE.format(r'[^)]*'), cmd):
if '{}' not in cmd:
cmd += ' {}'
return cmd.replace('{}', compat_shlex_quote(info['filepath']))