[mtv] Fix Viacom A/B Testing Video Player extraction(closes #28703)
authorRemita Amine <remitamine@gmail.com>
Thu, 8 Apr 2021 17:53:36 +0000 (18:53 +0100)
committerRemita Amine <remitamine@gmail.com>
Thu, 8 Apr 2021 17:54:44 +0000 (18:54 +0100)
youtube_dl/extractor/mtv.py

index 600cf2d89bcf8288c62d774f62858b5b0d3ef391..5a5205c0e98741f87b39ccdac071f11f52d658f4 100644 (file)
@@ -255,7 +255,9 @@ class MTVServicesInfoExtractor(InfoExtractor):
 
     @staticmethod
     def _extract_child_with_type(parent, t):
-        return next(c for c in parent['children'] if c.get('type') == t)
+        for c in parent['children']:
+            if c.get('type') == t:
+                return c
 
     def _extract_mgid(self, webpage):
         try:
@@ -286,7 +288,8 @@ class MTVServicesInfoExtractor(InfoExtractor):
             data = self._parse_json(self._search_regex(
                 r'__DATA__\s*=\s*({.+?});', webpage, 'data'), None)
             main_container = self._extract_child_with_type(data, 'MainContainer')
-            video_player = self._extract_child_with_type(main_container, 'VideoPlayer')
+            ab_testing = self._extract_child_with_type(main_container, 'ABTesting')
+            video_player = self._extract_child_with_type(ab_testing or main_container, 'VideoPlayer')
             mgid = video_player['props']['media']['video']['config']['uri']
 
         return mgid