[extractor/common] Fix inline HTML5 media tags processing and add test (closes #27345)
authorSergey M․ <dstftw@gmail.com>
Tue, 8 Dec 2020 17:05:21 +0000 (00:05 +0700)
committerSergey M․ <dstftw@gmail.com>
Tue, 8 Dec 2020 17:05:21 +0000 (00:05 +0700)
test/test_InfoExtractor.py
youtube_dl/extractor/common.py

index 71f6608feae4a5bcad37e96d74e795e7535a5dc7..644b3759c249359620021792631d0b3006f45ff1 100644 (file)
@@ -108,6 +108,18 @@ class TestInfoExtractor(unittest.TestCase):
         self.assertEqual(self.ie._download_json(uri, None, fatal=False), None)
 
     def test_parse_html5_media_entries(self):
+        # inline video tag
+        expect_dict(
+            self,
+            self.ie._parse_html5_media_entries(
+                'https://127.0.0.1/video.html',
+                r'<html><video src="/vid.mp4" /></html>', None)[0],
+            {
+                'formats': [{
+                    'url': 'https://127.0.0.1/vid.mp4',
+                }],
+            })
+
         # from https://www.r18.com/
         # with kpbs in label
         expect_dict(
index dd07a1cae6be42b2d2cc06a27a4162e4fb86d4a8..74e40fabb7183c974ce2a1e17fa603926d85f36d 100644 (file)
@@ -2515,9 +2515,9 @@ class InfoExtractor(object):
         # https://www.ampproject.org/docs/reference/components/amp-video)
         # For dl8-* tags see https://delight-vr.com/documentation/dl8-video/
         _MEDIA_TAG_NAME_RE = r'(?:(?:amp|dl8(?:-live)?)-)?(video|audio)'
-        media_tags = [(media_tag, media_type, '')
-                      for media_tag, media_type
-                      in re.findall(r'(?s)(<%s[^>]*/>)' % _MEDIA_TAG_NAME_RE, webpage)]
+        media_tags = [(media_tag, media_tag_name, media_type, '')
+                      for media_tag, media_tag_name, media_type
+                      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