[extractor/common] Escape `%` in `representation_id` of m3u8

Closes #4877
This commit is contained in:
pukkandan 2022-09-09 09:58:41 +05:30
parent 0831d95c46
commit 0cb0fdbbfe
No known key found for this signature in database
GPG Key ID: 7EEE9E1E817D0A39
1 changed files with 2 additions and 2 deletions

View File

@ -2914,6 +2914,8 @@ class InfoExtractor:
def prepare_template(template_name, identifiers):
tmpl = representation_ms_info[template_name]
if representation_id is not None:
tmpl = tmpl.replace('$RepresentationID$', representation_id)
# First of, % characters outside $...$ templates
# must be escaped by doubling for proper processing
# by % operator string formatting used further (see
@ -2928,8 +2930,6 @@ class InfoExtractor:
t += c
# Next, $...$ templates are translated to their
# %(...) counterparts to be used with % operator
if representation_id is not None:
t = t.replace('$RepresentationID$', representation_id)
t = re.sub(r'\$(%s)\$' % '|'.join(identifiers), r'%(\1)d', t)
t = re.sub(r'\$(%s)%%([^$]+)\$' % '|'.join(identifiers), r'%(\1)\2', t)
t.replace('$$', '$')