]>
Commit | Line | Data |
---|---|---|
3798eadc PH |
1 | from __future__ import unicode_literals |
2 | ||
1a582dd4 | 3 | import re |
1a582dd4 JMF |
4 | |
5 | from .common import InfoExtractor | |
29825140 RA |
6 | from .turner import TurnerBaseIE |
7 | from ..utils import url_basename | |
1a582dd4 | 8 | |
273f603e | 9 | |
29825140 | 10 | class CNNIE(TurnerBaseIE): |
292a2301 | 11 | _VALID_URL = r'''(?x)https?://(?:(?P<sub_domain>edition|www|money)\.)?cnn\.com/(?:video/(?:data/.+?|\?)/)?videos?/ |
abca34cb | 12 | (?P<path>.+?/(?P<title>[^/]+?)(?:\.(?:[a-z\-]+)|(?=&)))''' |
1a582dd4 | 13 | |
273f603e | 14 | _TESTS = [{ |
3798eadc | 15 | 'url': 'http://edition.cnn.com/video/?/video/sports/2013/06/09/nadal-1-on-1.cnn', |
3798eadc PH |
16 | 'md5': '3e6121ea48df7e2259fe73a0628605c4', |
17 | 'info_dict': { | |
3c77a54d | 18 | 'id': 'sports/2013/06/09/nadal-1-on-1.cnn', |
acd40f64 | 19 | 'ext': 'mp4', |
3798eadc PH |
20 | 'title': 'Nadal wins 8th French Open title', |
21 | 'description': 'World Sport\'s Amanda Davies chats with 2013 French Open champion Rafael Nadal.', | |
22 | 'duration': 135, | |
23 | 'upload_date': '20130609', | |
1a582dd4 | 24 | }, |
29825140 | 25 | 'expected_warnings': ['Failed to download m3u8 information'], |
9e1a5b84 | 26 | }, { |
611c1dd9 S |
27 | 'url': 'http://edition.cnn.com/video/?/video/us/2013/08/21/sot-student-gives-epic-speech.georgia-institute-of-technology&utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+rss%2Fcnn_topstories+%28RSS%3A+Top+Stories%29', |
28 | 'md5': 'b5cc60c60a3477d185af8f19a2a26f4e', | |
29 | 'info_dict': { | |
3c77a54d | 30 | 'id': 'us/2013/08/21/sot-student-gives-epic-speech.georgia-institute-of-technology', |
acd40f64 | 31 | 'ext': 'mp4', |
611c1dd9 S |
32 | 'title': "Student's epic speech stuns new freshmen", |
33 | 'description': "A Georgia Tech student welcomes the incoming freshmen with an epic speech backed by music from \"2001: A Space Odyssey.\"", | |
34 | 'upload_date': '20130821', | |
29825140 RA |
35 | }, |
36 | 'expected_warnings': ['Failed to download m3u8 information'], | |
429ddfd3 S |
37 | }, { |
38 | 'url': 'http://www.cnn.com/video/data/2.0/video/living/2014/12/22/growing-america-nashville-salemtown-board-episode-1.hln.html', | |
39 | 'md5': 'f14d02ebd264df951feb2400e2c25a1b', | |
40 | 'info_dict': { | |
3c77a54d | 41 | 'id': 'living/2014/12/22/growing-america-nashville-salemtown-board-episode-1.hln', |
429ddfd3 S |
42 | 'ext': 'mp4', |
43 | 'title': 'Nashville Ep. 1: Hand crafted skateboards', | |
44 | 'description': 'md5:e7223a503315c9f150acac52e76de086', | |
45 | 'upload_date': '20141222', | |
29825140 RA |
46 | }, |
47 | 'expected_warnings': ['Failed to download m3u8 information'], | |
292a2301 RA |
48 | }, { |
49 | 'url': 'http://money.cnn.com/video/news/2016/08/19/netflix-stunning-stats.cnnmoney/index.html', | |
50 | 'md5': '52a515dc1b0f001cd82e4ceda32be9d1', | |
51 | 'info_dict': { | |
3c77a54d | 52 | 'id': '/video/news/2016/08/19/netflix-stunning-stats.cnnmoney', |
292a2301 RA |
53 | 'ext': 'mp4', |
54 | 'title': '5 stunning stats about Netflix', | |
55 | 'description': 'Did you know that Netflix has more than 80 million members? Here are five facts about the online video distributor that you probably didn\'t know.', | |
56 | 'upload_date': '20160819', | |
29825140 RA |
57 | }, |
58 | 'params': { | |
59 | # m3u8 download | |
60 | 'skip_download': True, | |
61 | }, | |
ecb750a4 PH |
62 | }, { |
63 | 'url': 'http://cnn.com/video/?/video/politics/2015/03/27/pkg-arizona-senator-church-attendance-mandatory.ktvk', | |
64 | 'only_matching': True, | |
29713e42 PH |
65 | }, { |
66 | 'url': 'http://cnn.com/video/?/video/us/2015/04/06/dnt-baker-refuses-anti-gay-order.wkmg', | |
67 | 'only_matching': True, | |
292a2301 RA |
68 | }, { |
69 | 'url': 'http://edition.cnn.com/videos/arts/2016/04/21/olympic-games-cultural-a-z-brazil.cnn', | |
70 | 'only_matching': True, | |
273f603e | 71 | }] |
1a582dd4 | 72 | |
292a2301 RA |
73 | _CONFIG = { |
74 | # http://edition.cnn.com/.element/apps/cvp/3.0/cfg/spider/cnn/expansion/config.xml | |
75 | 'edition': { | |
76 | 'data_src': 'http://edition.cnn.com/video/data/3.0/video/%s/index.xml', | |
77 | 'media_src': 'http://pmd.cdn.turner.com/cnn/big', | |
78 | }, | |
79 | # http://money.cnn.com/.element/apps/cvp2/cfg/config.xml | |
80 | 'money': { | |
81 | 'data_src': 'http://money.cnn.com/video/data/4.0/video/%s.xml', | |
82 | 'media_src': 'http://ht3.cdn.turner.com/money/big', | |
83 | }, | |
84 | } | |
85 | ||
da30a20a RA |
86 | def _extract_timestamp(self, video_data): |
87 | # TODO: fix timestamp extraction | |
88 | return None | |
89 | ||
1a582dd4 | 90 | def _real_extract(self, url): |
292a2301 RA |
91 | sub_domain, path, page_title = re.match(self._VALID_URL, url).groups() |
92 | if sub_domain not in ('money', 'edition'): | |
93 | sub_domain = 'edition' | |
94 | config = self._CONFIG[sub_domain] | |
29825140 RA |
95 | return self._extract_cvp_info( |
96 | config['data_src'] % path, page_title, { | |
97 | 'default': { | |
98 | 'media_src': config['media_src'], | |
29f7c58a | 99 | }, |
100 | 'f4m': { | |
101 | 'host': 'cnn-vh.akamaihd.net', | |
102 | }, | |
29825140 | 103 | }) |
0ae6b019 JMF |
104 | |
105 | ||
106 | class CNNBlogsIE(InfoExtractor): | |
107 | _VALID_URL = r'https?://[^\.]+\.blogs\.cnn\.com/.+' | |
108 | _TEST = { | |
109 | 'url': 'http://reliablesources.blogs.cnn.com/2014/02/09/criminalizing-journalism/', | |
110 | 'md5': '3e56f97b0b6ffb4b79f4ea0749551084', | |
111 | 'info_dict': { | |
3c77a54d | 112 | 'id': 'bestoftv/2014/02/09/criminalizing-journalism.cnn', |
0ae6b019 JMF |
113 | 'ext': 'mp4', |
114 | 'title': 'Criminalizing journalism?', | |
115 | 'description': 'Glenn Greenwald responds to comments made this week on Capitol Hill that journalists could be criminal accessories.', | |
116 | 'upload_date': '20140209', | |
117 | }, | |
1fe48afe | 118 | 'expected_warnings': ['Failed to download m3u8 information'], |
0ae6b019 JMF |
119 | 'add_ie': ['CNN'], |
120 | } | |
121 | ||
122 | def _real_extract(self, url): | |
123 | webpage = self._download_webpage(url, url_basename(url)) | |
124 | cnn_url = self._html_search_regex(r'data-url="(.+?)"', webpage, 'cnn url') | |
d226c560 | 125 | return self.url_result(cnn_url, CNNIE.ie_key()) |
9532d723 AK |
126 | |
127 | ||
128 | class CNNArticleIE(InfoExtractor): | |
292a2301 | 129 | _VALID_URL = r'https?://(?:(?:edition|www)\.)?cnn\.com/(?!videos?/)' |
9532d723 AK |
130 | _TEST = { |
131 | 'url': 'http://www.cnn.com/2014/12/21/politics/obama-north-koreas-hack-not-war-but-cyber-vandalism/', | |
5fe51125 | 132 | 'md5': '689034c2a3d9c6dc4aa72d65a81efd01', |
9532d723 | 133 | 'info_dict': { |
3c77a54d | 134 | 'id': 'bestoftv/2014/12/21/ip-north-korea-obama.cnn', |
9532d723 | 135 | 'ext': 'mp4', |
5fe51125 | 136 | 'title': 'Obama: Cyberattack not an act of war', |
1fe48afe | 137 | 'description': 'md5:0a802a40d2376f60e6b04c8d5bcebc4b', |
5fe51125 | 138 | 'upload_date': '20141221', |
9532d723 | 139 | }, |
1fe48afe | 140 | 'expected_warnings': ['Failed to download m3u8 information'], |
9532d723 AK |
141 | 'add_ie': ['CNN'], |
142 | } | |
143 | ||
144 | def _real_extract(self, url): | |
145 | webpage = self._download_webpage(url, url_basename(url)) | |
146 | cnn_url = self._html_search_regex(r"video:\s*'([^']+)'", webpage, 'cnn url') | |
d226c560 | 147 | return self.url_result('http://cnn.com/video/?/video/' + cnn_url, CNNIE.ie_key()) |