[eagleplatform] Improve embed detection and extract in separate routine (Closes ...
authorSergey M․ <dstftw@gmail.com>
Wed, 29 Jun 2016 16:01:34 +0000 (23:01 +0700)
committerSergey M․ <dstftw@gmail.com>
Wed, 29 Jun 2016 16:01:34 +0000 (23:01 +0700)
youtube_dl/extractor/eagleplatform.py
youtube_dl/extractor/generic.py

index 113a4966fb3c444f5759e617e36b293ee88e6872..12d28d3b9f1e76f84f0f9fa322befd0bfa056f09 100644 (file)
@@ -50,6 +50,14 @@ class EaglePlatformIE(InfoExtractor):
         'skip': 'Georestricted',
     }]
 
+    @staticmethod
+    def _extract_url(webpage):
+        mobj = re.search(
+            r'<iframe[^>]+src=(["\'])(?P<url>(?:https?:)?//.+?\.media\.eagleplatform\.com/index/player\?.+?)\1',
+            webpage)
+        if mobj is not None:
+            return mobj.group('url')
+
     @staticmethod
     def _handle_error(response):
         status = int_or_none(response.get('status', 200))
index 2188f8bb2aaeb6bb900850cbfa219439c9da69ec..712dd8a94ce6aad443101d2b7e88facbb2452eb4 100644 (file)
@@ -65,6 +65,7 @@ from .threeqsdn import ThreeQSDNIE
 from .theplatform import ThePlatformIE
 from .vessel import VesselIE
 from .kaltura import KalturaIE
+from .eagleplatform import EaglePlatformIE
 
 
 class GenericIE(InfoExtractor):
@@ -1932,10 +1933,9 @@ class GenericIE(InfoExtractor):
             return self.url_result(smuggle_url(kaltura_url, {'source_url': url}), KalturaIE.ie_key())
 
         # Look for Eagle.Platform embeds
-        mobj = re.search(
-            r'<iframe[^>]+src="(?P<url>https?://.+?\.media\.eagleplatform\.com/index/player\?.+?)"', webpage)
-        if mobj is not None:
-            return self.url_result(mobj.group('url'), 'EaglePlatform')
+        eagleplatform_url = EaglePlatformIE._extract_url(webpage)
+        if eagleplatform_url:
+            return self.url_result(eagleplatform_url, EaglePlatformIE.ie_key())
 
         # Look for ClipYou (uses Eagle.Platform) embeds
         mobj = re.search(