]> git.bitcoin.ninja Git - youtube-dl/commitdiff
[cnn] Add support for articles with videos (fixes #4541)
authorAdrian Kretz <adriankretz@gmail.com>
Mon, 22 Dec 2014 17:40:36 +0000 (18:40 +0100)
committerAdrian Kretz <adriankretz@gmail.com>
Mon, 22 Dec 2014 17:40:36 +0000 (18:40 +0100)
youtube_dl/extractor/__init__.py
youtube_dl/extractor/cnn.py

index 92aca503c169c3625a64dab6db8bbeed5fb3ff16..ba12e326350b113a3dd4cead1e5027e9d9ae681a 100644 (file)
@@ -64,6 +64,7 @@ from .cnet import CNETIE
 from .cnn import (
     CNNIE,
     CNNBlogsIE,
+    CNNArticleIE,
 )
 from .collegehumor import CollegeHumorIE
 from .comedycentral import ComedyCentralIE, ComedyCentralShowsIE
index 81142ee419d45b9df9f75bdc152ab87e1317650f..cddcacdf1173c4b5fbfa1dc0ae69ef03cfe5e265 100644 (file)
@@ -127,3 +127,28 @@ class CNNBlogsIE(InfoExtractor):
             'url': cnn_url,
             'ie_key': CNNIE.ie_key(),
         }
+
+
+class CNNArticleIE(InfoExtractor):
+    _VALID_URL = r'https?://((edition|www)\.)?cnn\.com/(?!video/)'
+    _TEST = {
+        'url': 'http://www.cnn.com/2014/12/21/politics/obama-north-koreas-hack-not-war-but-cyber-vandalism/',
+        'md5': '275b326f85d80dff7592a9820f5dc887',
+        'info_dict': {
+            'id': 'bestoftv/2014/12/21/sotu-crowley-president-obama-north-korea-not-going-to-be-intimidated.cnn',
+            'ext': 'mp4',
+            'title': 'Obama: We\'re not going to be intimidated',
+            'description': 'md5:e735586f3dc936075fa654a4d91b21f9',
+            'upload_date': '20141220',
+        },
+        'add_ie': ['CNN'],
+    }
+
+    def _real_extract(self, url):
+        webpage = self._download_webpage(url, url_basename(url))
+        cnn_url = self._html_search_regex(r"video:\s*'([^']+)'", webpage, 'cnn url')
+        return {
+            '_type': 'url',
+            'url': r'http://cnn.com/video/?/video/' + cnn_url,
+            'ie_key': CNNIE.ie_key(),
+        }