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