diff options
author | Sergey M․ <dstftw@gmail.com> | 2020-12-07 00:55:49 +0700 |
---|---|---|
committer | Sergey M․ <dstftw@gmail.com> | 2020-12-07 00:56:29 +0700 |
commit | 06bf2ac20f2fb64df9f6e4cd1dba267b25effd22 (patch) | |
tree | 51682526a4755071141ebcef7a6d112861b21243 /youtube_dl | |
parent | 6ad0d8781e2b156a4599abcebaa0b91b7e3131f4 (diff) |
[extractor/common] Eliminate media tag name regex duplication
Diffstat (limited to 'youtube_dl')
-rw-r--r-- | youtube_dl/extractor/common.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/youtube_dl/extractor/common.py b/youtube_dl/extractor/common.py index 864596e66..877873ebd 100644 --- a/youtube_dl/extractor/common.py +++ b/youtube_dl/extractor/common.py @@ -2513,15 +2513,16 @@ class InfoExtractor(object): # amp-video and amp-audio are very similar to their HTML5 counterparts # so we wll include them right here (see # https://www.ampproject.org/docs/reference/components/amp-video) + _MEDIA_TAG_NAME_RE = r'(?:amp-)?(video|audio)' media_tags = [(media_tag, media_type, '') for media_tag, media_type - in re.findall(r'(?s)(<(?:amp-)?(video|audio)[^>]*/>)', webpage)] + in re.findall(r'(?s)(<%s[^>]*/>)' % _MEDIA_TAG_NAME_RE, webpage)] media_tags.extend(re.findall( # We only allow video|audio followed by a whitespace or '>'. # Allowing more characters may end up in significant slow down (see # https://github.com/ytdl-org/youtube-dl/issues/11979, example URL: # http://www.porntrex.com/maps/videositemap.xml). - r'(?s)(<(?P<tag>(?:amp-)?(video|audio))(?:\s+[^>]*)?>)(.*?)</(?P=tag)>', webpage)) + r'(?s)(<(?P<tag>%s)(?:\s+[^>]*)?>)(.*?)</(?P=tag)>' % _MEDIA_TAG_NAME_RE, webpage)) for media_tag, _, media_type, media_content in media_tags: media_info = { 'formats': [], |