[pbs] Simplify and speed up player URL search
authorSergey M․ <dstftw@gmail.com>
Fri, 6 Nov 2015 17:45:26 +0000 (23:45 +0600)
committerSergey M․ <dstftw@gmail.com>
Fri, 6 Nov 2015 17:45:26 +0000 (23:45 +0600)
youtube_dl/extractor/pbs.py

index 3448736a258458ff1a2b4a2ee126ce703894e6dc..7b868d0570092c21e86876b8125cb08a36441b04 100644 (file)
@@ -191,9 +191,13 @@ class PBSIE(InfoExtractor):
             if media_id:
                 return media_id, presumptive_id, upload_date
 
-            url = self._search_regex(
-                r'(?s)<iframe[^>]+?(?:[a-z-]+?=["\'].*?["\'][^>]+?)*?\bsrc=["\']([^\'"]+partnerplayer[^\'"]+)["\']',
-                webpage, 'player URL')
+            for iframe in re.findall(r'(?s)<iframe(.+?)></iframe>', webpage):
+                url = self._search_regex(
+                    r'src=(["\'])(?P<url>.+?partnerplayer.+?)\1', iframe,
+                    'player URL', default=None, group='url')
+                if url:
+                    break
+
             mobj = re.match(self._VALID_URL, url)
 
         player_id = mobj.group('player_id')