aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/YoutubeDL.py
diff options
context:
space:
mode:
authorJesús <heckyel@hyperbola.info>2022-02-12 21:05:27 -0500
committerJesús <heckyel@hyperbola.info>2022-02-12 21:05:27 -0500
commitaf4847e22e81d05177f92c712983ab3f2f20184b (patch)
tree6b749333494ffe379df3e1a060660e4b1afcdf85 /yt_dlp/YoutubeDL.py
parentc4b763b19f54ed5dfc2fd408adb9ed74126f6740 (diff)
parent29448350808619262d6a9ddd393a2c28df1720fe (diff)
downloadhypervideo-pre-af4847e22e81d05177f92c712983ab3f2f20184b.tar.lz
hypervideo-pre-af4847e22e81d05177f92c712983ab3f2f20184b.tar.xz
hypervideo-pre-af4847e22e81d05177f92c712983ab3f2f20184b.zip
updated from upstream | 12/02/2022 at 21:05
Diffstat (limited to 'yt_dlp/YoutubeDL.py')
-rw-r--r--yt_dlp/YoutubeDL.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py
index ac45a5160..4438e40e9 100644
--- a/yt_dlp/YoutubeDL.py
+++ b/yt_dlp/YoutubeDL.py
@@ -1841,15 +1841,21 @@ class YoutubeDL(object):
'^=': lambda attr, value: attr.startswith(value),
'$=': lambda attr, value: attr.endswith(value),
'*=': lambda attr, value: value in attr,
+ '~=': lambda attr, value: value.search(attr) is not None
}
str_operator_rex = re.compile(r'''(?x)\s*
(?P<key>[a-zA-Z0-9._-]+)\s*
- (?P<negation>!\s*)?(?P<op>%s)(?P<none_inclusive>\s*\?)?\s*
- (?P<value>[a-zA-Z0-9._-]+)\s*
+ (?P<negation>!\s*)?(?P<op>%s)\s*(?P<none_inclusive>\?\s*)?
+ (?P<quote>["'])?
+ (?P<value>(?(quote)(?:(?!(?P=quote))[^\\]|\\.)+|[\w.-]+))
+ (?(quote)(?P=quote))\s*
''' % '|'.join(map(re.escape, STR_OPERATORS.keys())))
m = str_operator_rex.fullmatch(filter_spec)
if m:
- comparison_value = m.group('value')
+ if m.group('op') == '~=':
+ comparison_value = re.compile(m.group('value'))
+ else:
+ comparison_value = re.sub(r'''\\([\\"'])''', r'\1', m.group('value'))
str_op = STR_OPERATORS[m.group('op')]
if m.group('negation'):
op = lambda attr, value: not str_op(attr, value)
@@ -3859,7 +3865,7 @@ class YoutubeDL(object):
else:
self.to_screen(f'[info] Downloading {thumb_display_id} ...')
try:
- uf = self.urlopen(t['url'])
+ uf = self.urlopen(sanitized_Request(t['url'], headers=t.get('http_headers', {})))
self.to_screen(f'[info] Writing {thumb_display_id} to: {thumb_filename}')
with open(encodeFilename(thumb_filename), 'wb') as thumbf:
shutil.copyfileobj(uf, thumbf)