[outtmpl] Allow \n
in replacements and default.
Fixes: https://github.com/yt-dlp/yt-dlp/issues/6808#issuecomment-1510055357 Fixes: https://github.com/yt-dlp/yt-dlp/issues/6808#issuecomment-1510363645
This commit is contained in:
parent
80b732b7a9
commit
78fde6e339
3 changed files with 3 additions and 2 deletions
|
@ -822,6 +822,7 @@ class TestYoutubeDL(unittest.TestCase):
|
||||||
test('%(title&foo|baz)s.bar', 'baz.bar')
|
test('%(title&foo|baz)s.bar', 'baz.bar')
|
||||||
test('%(x,id&foo|baz)s.bar', 'foo.bar')
|
test('%(x,id&foo|baz)s.bar', 'foo.bar')
|
||||||
test('%(x,title&foo|baz)s.bar', 'baz.bar')
|
test('%(x,title&foo|baz)s.bar', 'baz.bar')
|
||||||
|
test('%(title&\n|)s', '\n')
|
||||||
|
|
||||||
# Laziness
|
# Laziness
|
||||||
def gen():
|
def gen():
|
||||||
|
|
|
@ -1156,7 +1156,7 @@ class YoutubeDL:
|
||||||
}
|
}
|
||||||
MATH_FIELD_RE = rf'(?:{FIELD_RE}|-?{NUMBER_RE})'
|
MATH_FIELD_RE = rf'(?:{FIELD_RE}|-?{NUMBER_RE})'
|
||||||
MATH_OPERATORS_RE = r'(?:%s)' % '|'.join(map(re.escape, MATH_FUNCTIONS.keys()))
|
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<negate>-)?
|
||||||
(?P<fields>{FIELD_RE})
|
(?P<fields>{FIELD_RE})
|
||||||
(?P<maths>(?:{MATH_OPERATORS_RE}{MATH_FIELD_RE})*)
|
(?P<maths>(?:{MATH_OPERATORS_RE}{MATH_FIELD_RE})*)
|
||||||
|
|
|
@ -243,7 +243,7 @@ def create_parser():
|
||||||
if multiple_keys:
|
if multiple_keys:
|
||||||
allowed_keys = fr'({allowed_keys})(,({allowed_keys}))*'
|
allowed_keys = fr'({allowed_keys})(,({allowed_keys}))*'
|
||||||
mobj = re.match(
|
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)
|
value[0] if multiple_args else value)
|
||||||
if mobj is not None:
|
if mobj is not None:
|
||||||
keys, val = mobj.group('keys').split(','), mobj.group('val')
|
keys, val = mobj.group('keys').split(','), mobj.group('val')
|
||||||
|
|
Loading…
Reference in a new issue