[yahoo] Add support for custom brigthcove embeds (closes #14210)
authorSergey M․ <dstftw@gmail.com>
Sat, 30 Sep 2017 15:47:03 +0000 (22:47 +0700)
committerSergey M․ <dstftw@gmail.com>
Sat, 30 Sep 2017 15:47:03 +0000 (22:47 +0700)
youtube_dl/extractor/yahoo.py

index 38f82bf447128d42643afa865c41efc7db9014cd..e92337969b453cc6f6beb13ffa3883be3da86b0c 100644 (file)
@@ -28,7 +28,7 @@ from .nbc import NBCSportsVPlayerIE
 
 class YahooIE(InfoExtractor):
     IE_DESC = 'Yahoo screen and movies'
-    _VALID_URL = r'(?P<url>(?P<host>https?://(?:[a-zA-Z]{2}\.)?[\da-zA-Z_-]+\.yahoo\.com)/(?:[^/]+/)*(?P<display_id>.+)?-(?P<id>[0-9]+)(?:-[a-z]+)?(?:\.html)?)'
+    _VALID_URL = r'(?P<host>https?://(?:[a-zA-Z]{2}\.)?[\da-zA-Z_-]+\.yahoo\.com)/(?:[^/]+/)*(?:(?P<display_id>.+)?-)?(?P<id>[0-9]+)(?:-[a-z]+)?(?:\.html)?'
     _TESTS = [
         {
             'url': 'http://screen.yahoo.com/julian-smith-travis-legg-watch-214727115.html',
@@ -227,13 +227,28 @@ class YahooIE(InfoExtractor):
                 'skip_download': True,
             },
         },
+        {
+            # custom brightcove
+            'url': 'https://au.tv.yahoo.com/plus7/sunrise/-/watch/37083565/clown-entertainers-say-it-is-hurting-their-business/',
+            'info_dict': {
+                'id': '5575377707001',
+                'ext': 'mp4',
+                'title': "Clown entertainers say 'It' is hurting their business",
+                'description': 'Stephen King s horror film has much to answer for. Jelby and Mr Loopy the Clowns join us.',
+                'timestamp': 1505341164,
+                'upload_date': '20170913',
+                'uploader_id': '2376984109001',
+            },
+            'params': {
+                'skip_download': True,
+            },
+        }
     ]
 
     def _real_extract(self, url):
         mobj = re.match(self._VALID_URL, url)
-        display_id = mobj.group('display_id') or self._match_id(url)
         page_id = mobj.group('id')
-        url = mobj.group('url')
+        display_id = mobj.group('display_id') or page_id
         host = mobj.group('host')
         webpage, urlh = self._download_webpage_handle(url, display_id)
         if 'err=404' in urlh.geturl():
@@ -262,6 +277,14 @@ class YahooIE(InfoExtractor):
         if bc_url:
             return self.url_result(bc_url, BrightcoveNewIE.ie_key())
 
+        brightcove_id = self._search_regex(
+            r'<iframe[^>]+data-video-id=["\'](\d+)', webpage, 'brightcove id',
+            default=None)
+        if brightcove_id:
+            return self.url_result(
+                'http://players.brightcove.net/2376984109001/default_default/index.html?videoId=%s' % brightcove_id,
+                BrightcoveNewIE.ie_key())
+
         # Query result is often embedded in webpage as JSON. Sometimes explicit requests
         # to video API results in a failure with geo restriction reason therefore using
         # embedded query result when present sounds reasonable.