Skip to content

Commit

Permalink
[outtmpl] Allow \n in replacements and default.
Browse files Browse the repository at this point in the history
  • Loading branch information
pukkandan committed Apr 24, 2023
1 parent 80b732b commit 78fde6e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions test/test_YoutubeDL.py
Expand Up @@ -822,6 +822,7 @@ def expect_same_infodict(out):
test('%(title&foo|baz)s.bar', 'baz.bar')
test('%(x,id&foo|baz)s.bar', 'foo.bar')
test('%(x,title&foo|baz)s.bar', 'baz.bar')
test('%(title&\n|)s', '\n')

# Laziness
def gen():
Expand Down
2 changes: 1 addition & 1 deletion yt_dlp/YoutubeDL.py
Expand Up @@ -1156,7 +1156,7 @@ def prepare_outtmpl(self, outtmpl, info_dict, sanitize=False):
}
MATH_FIELD_RE = rf'(?:{FIELD_RE}|-?{NUMBER_RE})'
MATH_OPERATORS_RE = r'(?:%s)' % '|'.join(map(re.escape, MATH_FUNCTIONS.keys()))
INTERNAL_FORMAT_RE = re.compile(rf'''(?x)
INTERNAL_FORMAT_RE = re.compile(rf'''(?xs)
(?P<negate>-)?
(?P<fields>{FIELD_RE})
(?P<maths>(?:{MATH_OPERATORS_RE}{MATH_FIELD_RE})*)
Expand Down
2 changes: 1 addition & 1 deletion yt_dlp/options.py
Expand Up @@ -243,7 +243,7 @@ def _dict_from_options_callback(
if multiple_keys:
allowed_keys = fr'({allowed_keys})(,({allowed_keys}))*'
mobj = re.match(
fr'(?i)(?P<keys>{allowed_keys}){delimiter}(?P<val>.*)$',
fr'(?is)(?P<keys>{allowed_keys}){delimiter}(?P<val>.*)$',
value[0] if multiple_args else value)
if mobj is not None:
keys, val = mobj.group('keys').split(','), mobj.group('val')
Expand Down

0 comments on commit 78fde6e

Please sign in to comment.