]>
Commit | Line | Data |
---|---|---|
cd7ee7aa JMF |
1 | from __future__ import unicode_literals |
2 | ||
0bc56fa6 | 3 | import re |
0bc56fa6 JMF |
4 | |
5 | from .common import InfoExtractor | |
574b2a73 | 6 | from .theplatform import ThePlatformIE |
1cc79574 | 7 | from ..utils import ( |
37e64add | 8 | find_xpath_attr, |
0fe2ff78 | 9 | lowercase_escape, |
b46b65ed | 10 | smuggle_url, |
0fe2ff78 | 11 | unescapeHTML, |
37e64add | 12 | ) |
0bc56fa6 JMF |
13 | |
14 | ||
020cf5eb | 15 | class NBCIE(InfoExtractor): |
cb88671e | 16 | _VALID_URL = r'https?://www\.nbc\.com/(?:[^/]+/)+(?P<id>n?\d+)' |
58c1f6f0 S |
17 | |
18 | _TESTS = [ | |
19 | { | |
5c8a3f86 | 20 | 'url': 'http://www.nbc.com/the-tonight-show/segments/112966', |
58c1f6f0 | 21 | 'info_dict': { |
e881c4bc YCH |
22 | 'id': '112966', |
23 | 'ext': 'mp4', | |
5c8a3f86 JMF |
24 | 'title': 'Jimmy Fallon Surprises Fans at Ben & Jerry\'s', |
25 | 'description': 'Jimmy gives out free scoops of his new "Tonight Dough" ice cream flavor by surprising customers at the Ben & Jerry\'s scoop shop.', | |
79ba9140 | 26 | 'timestamp': 1424246400, |
27 | 'upload_date': '20150218', | |
28 | 'uploader': 'NBCU-COM', | |
58c1f6f0 | 29 | }, |
e881c4bc YCH |
30 | 'params': { |
31 | # m3u8 download | |
32 | 'skip_download': True, | |
33 | }, | |
020cf5eb | 34 | }, |
58c1f6f0 S |
35 | { |
36 | 'url': 'http://www.nbc.com/the-tonight-show/episodes/176', | |
37 | 'info_dict': { | |
e881c4bc | 38 | 'id': '176', |
58c1f6f0 S |
39 | 'ext': 'flv', |
40 | 'title': 'Ricky Gervais, Steven Van Zandt, ILoveMakonnen', | |
41 | 'description': 'A brand new episode of The Tonight Show welcomes Ricky Gervais, Steven Van Zandt and ILoveMakonnen.', | |
42 | }, | |
e881c4bc | 43 | 'skip': '404 Not Found', |
58c1f6f0 | 44 | }, |
b9b3ab45 YCH |
45 | { |
46 | 'url': 'http://www.nbc.com/saturday-night-live/video/star-wars-teaser/2832821', | |
47 | 'info_dict': { | |
e881c4bc YCH |
48 | 'id': '2832821', |
49 | 'ext': 'mp4', | |
b9b3ab45 YCH |
50 | 'title': 'Star Wars Teaser', |
51 | 'description': 'md5:0b40f9cbde5b671a7ff62fceccc4f442', | |
79ba9140 | 52 | 'timestamp': 1417852800, |
53 | 'upload_date': '20141206', | |
54 | 'uploader': 'NBCU-COM', | |
b9b3ab45 | 55 | }, |
e881c4bc YCH |
56 | 'params': { |
57 | # m3u8 download | |
58 | 'skip_download': True, | |
59 | }, | |
b9b3ab45 | 60 | 'skip': 'Only works from US', |
0fe2ff78 YCH |
61 | }, |
62 | { | |
63 | # This video has expired but with an escaped embedURL | |
64 | 'url': 'http://www.nbc.com/parenthood/episode-guide/season-5/just-like-at-home/515', | |
3e18700d | 65 | 'only_matching': True, |
e6e90515 YCH |
66 | }, |
67 | { | |
68 | # HLS streams requires the 'hdnea3' cookie | |
69 | 'url': 'http://www.nbc.com/Kings/video/goliath/n1806', | |
70 | 'info_dict': { | |
71 | 'id': 'n1806', | |
72 | 'ext': 'mp4', | |
73 | 'title': 'Goliath', | |
74 | 'description': 'When an unknown soldier saves the life of the King\'s son in battle, he\'s thrust into the limelight and politics of the kingdom.', | |
75 | 'timestamp': 1237100400, | |
76 | 'upload_date': '20090315', | |
77 | 'uploader': 'NBCU-COM', | |
78 | }, | |
79 | 'params': { | |
80 | 'skip_download': True, | |
81 | }, | |
82 | 'skip': 'Only works from US', | |
b9b3ab45 | 83 | } |
58c1f6f0 | 84 | ] |
020cf5eb JMF |
85 | |
86 | def _real_extract(self, url): | |
10e3d734 | 87 | video_id = self._match_id(url) |
020cf5eb | 88 | webpage = self._download_webpage(url, video_id) |
0fe2ff78 | 89 | theplatform_url = unescapeHTML(lowercase_escape(self._html_search_regex( |
b9b3ab45 YCH |
90 | [ |
91 | r'(?:class="video-player video-player-full" data-mpx-url|class="player" src)="(.*?)"', | |
b09c1223 | 92 | r'<iframe[^>]+src="((?:https?:)?//player\.theplatform\.com/[^"]+)"', |
b9b3ab45 YCH |
93 | r'"embedURL"\s*:\s*"([^"]+)"' |
94 | ], | |
0fe2ff78 | 95 | webpage, 'theplatform url').replace('_no_endcard', '').replace('\\/', '/'))) |
020cf5eb JMF |
96 | if theplatform_url.startswith('//'): |
97 | theplatform_url = 'http:' + theplatform_url | |
e881c4bc YCH |
98 | return { |
99 | '_type': 'url_transparent', | |
79ba9140 | 100 | 'ie_key': 'ThePlatform', |
e881c4bc YCH |
101 | 'url': smuggle_url(theplatform_url, {'source_url': url}), |
102 | 'id': video_id, | |
103 | } | |
020cf5eb JMF |
104 | |
105 | ||
a2a4d5fa | 106 | class NBCSportsVPlayerIE(InfoExtractor): |
a2edf2e7 | 107 | _VALID_URL = r'https?://vplayer\.nbcsports\.com/(?:[^/]+/)+(?P<id>[0-9a-zA-Z_]+)' |
a28ccbab | 108 | |
5cbb2699 | 109 | _TESTS = [{ |
a28ccbab | 110 | 'url': 'https://vplayer.nbcsports.com/p/BxmELC/nbcsports_share/select/9CsDKds0kvHI', |
a28ccbab YCH |
111 | 'info_dict': { |
112 | 'id': '9CsDKds0kvHI', | |
113 | 'ext': 'flv', | |
114 | 'description': 'md5:df390f70a9ba7c95ff1daace988f0d8d', | |
115 | 'title': 'Tyler Kalinoski hits buzzer-beater to lift Davidson', | |
79ba9140 | 116 | 'timestamp': 1426270238, |
117 | 'upload_date': '20150313', | |
118 | 'uploader': 'NBCU-SPORTS', | |
a28ccbab | 119 | } |
5cbb2699 | 120 | }, { |
5cbb2699 YCH |
121 | 'url': 'http://vplayer.nbcsports.com/p/BxmELC/nbc_embedshare/select/_hqLjQ95yx8Z', |
122 | 'only_matching': True, | |
123 | }] | |
a28ccbab | 124 | |
a2a4d5fa YCH |
125 | @staticmethod |
126 | def _extract_url(webpage): | |
127 | iframe_m = re.search( | |
128 | r'<iframe[^>]+src="(?P<url>https?://vplayer\.nbcsports\.com/[^"]+)"', webpage) | |
129 | if iframe_m: | |
130 | return iframe_m.group('url') | |
131 | ||
a28ccbab YCH |
132 | def _real_extract(self, url): |
133 | video_id = self._match_id(url) | |
134 | webpage = self._download_webpage(url, video_id) | |
135 | theplatform_url = self._og_search_video_url(webpage) | |
136 | return self.url_result(theplatform_url, 'ThePlatform') | |
137 | ||
138 | ||
a2a4d5fa | 139 | class NBCSportsIE(InfoExtractor): |
dfb1b146 | 140 | # Does not include https because its certificate is invalid |
5886b38d | 141 | _VALID_URL = r'https?://www\.nbcsports\.com//?(?:[^/]+/)+(?P<id>[0-9a-z-]+)' |
a2a4d5fa YCH |
142 | |
143 | _TEST = { | |
144 | 'url': 'http://www.nbcsports.com//college-basketball/ncaab/tom-izzo-michigan-st-has-so-much-respect-duke', | |
a2a4d5fa YCH |
145 | 'info_dict': { |
146 | 'id': 'PHJSaFWbrTY9', | |
147 | 'ext': 'flv', | |
148 | 'title': 'Tom Izzo, Michigan St. has \'so much respect\' for Duke', | |
149 | 'description': 'md5:ecb459c9d59e0766ac9c7d5d0eda8113', | |
0738187f YCH |
150 | 'uploader': 'NBCU-SPORTS', |
151 | 'upload_date': '20150330', | |
152 | 'timestamp': 1427726529, | |
a2a4d5fa YCH |
153 | } |
154 | } | |
155 | ||
156 | def _real_extract(self, url): | |
157 | video_id = self._match_id(url) | |
158 | webpage = self._download_webpage(url, video_id) | |
159 | return self.url_result( | |
160 | NBCSportsVPlayerIE._extract_url(webpage), 'NBCSportsVPlayer') | |
161 | ||
162 | ||
9cf01f7f | 163 | class CSNNEIE(InfoExtractor): |
164 | _VALID_URL = r'https?://www\.csnne\.com/video/(?P<id>[0-9a-z-]+)' | |
165 | ||
166 | _TEST = { | |
167 | 'url': 'http://www.csnne.com/video/snc-evening-update-wright-named-red-sox-no-5-starter', | |
168 | 'info_dict': { | |
169 | 'id': 'yvBLLUgQ8WU0', | |
170 | 'ext': 'mp4', | |
171 | 'title': 'SNC evening update: Wright named Red Sox\' No. 5 starter.', | |
172 | 'description': 'md5:1753cfee40d9352b19b4c9b3e589b9e3', | |
79ba9140 | 173 | 'timestamp': 1459369979, |
174 | 'upload_date': '20160330', | |
175 | 'uploader': 'NBCU-SPORTS', | |
9cf01f7f | 176 | } |
177 | } | |
178 | ||
179 | def _real_extract(self, url): | |
180 | display_id = self._match_id(url) | |
181 | webpage = self._download_webpage(url, display_id) | |
182 | return { | |
183 | '_type': 'url_transparent', | |
184 | 'ie_key': 'ThePlatform', | |
185 | 'url': self._html_search_meta('twitter:player:stream', webpage), | |
186 | 'display_id': display_id, | |
187 | } | |
188 | ||
189 | ||
574b2a73 | 190 | class NBCNewsIE(ThePlatformIE): |
0437307a | 191 | _VALID_URL = r'''(?x)https?://(?:www\.)?(?:nbcnews|today|msnbc)\.com/ |
a4f3d779 | 192 | (?:video/.+?/(?P<id>\d+)| |
0437307a | 193 | ([^/]+/)*(?:.*-)?(?P<mpx_id>[^/?]+)) |
87fe568c | 194 | ''' |
0bc56fa6 | 195 | |
87fe568c JMF |
196 | _TESTS = [ |
197 | { | |
198 | 'url': 'http://www.nbcnews.com/video/nbc-news/52753292', | |
199 | 'md5': '47abaac93c6eaf9ad37ee6c4463a5179', | |
200 | 'info_dict': { | |
201 | 'id': '52753292', | |
202 | 'ext': 'flv', | |
203 | 'title': 'Crew emerges after four-month Mars food study', | |
204 | 'description': 'md5:24e632ffac72b35f8b67a12d1b6ddfc1', | |
205 | }, | |
0bc56fa6 | 206 | }, |
87fe568c | 207 | { |
574b2a73 | 208 | 'url': 'http://www.nbcnews.com/watch/nbcnews-com/how-twitter-reacted-to-the-snowden-interview-269389891880', |
209 | 'md5': 'af1adfa51312291a017720403826bb64', | |
87fe568c | 210 | 'info_dict': { |
574b2a73 | 211 | 'id': '269389891880', |
10e3d734 | 212 | 'ext': 'mp4', |
87fe568c JMF |
213 | 'title': 'How Twitter Reacted To The Snowden Interview', |
214 | 'description': 'md5:65a0bd5d76fe114f3c2727aa3a81fe64', | |
0437307a RA |
215 | 'uploader': 'NBCU-NEWS', |
216 | 'timestamp': 1401363060, | |
217 | 'upload_date': '20140529', | |
87fe568c | 218 | }, |
87fe568c | 219 | }, |
2df54b4b S |
220 | { |
221 | 'url': 'http://www.nbcnews.com/feature/dateline-full-episodes/full-episode-family-business-n285156', | |
222 | 'md5': 'fdbf39ab73a72df5896b6234ff98518a', | |
223 | 'info_dict': { | |
0437307a | 224 | 'id': '529953347624', |
2df54b4b S |
225 | 'ext': 'mp4', |
226 | 'title': 'FULL EPISODE: Family Business', | |
227 | 'description': 'md5:757988edbaae9d7be1d585eb5d55cc04', | |
228 | }, | |
574b2a73 | 229 | 'skip': 'This page is unavailable.', |
2df54b4b | 230 | }, |
d9aa2b78 RS |
231 | { |
232 | 'url': 'http://www.nbcnews.com/nightly-news/video/nightly-news-with-brian-williams-full-broadcast-february-4-394064451844', | |
574b2a73 | 233 | 'md5': '73135a2e0ef819107bbb55a5a9b2a802', |
d9aa2b78 | 234 | 'info_dict': { |
574b2a73 | 235 | 'id': '394064451844', |
d9aa2b78 RS |
236 | 'ext': 'mp4', |
237 | 'title': 'Nightly News with Brian Williams Full Broadcast (February 4)', | |
238 | 'description': 'md5:1c10c1eccbe84a26e5debb4381e2d3c5', | |
0437307a RA |
239 | 'timestamp': 1423104900, |
240 | 'uploader': 'NBCU-NEWS', | |
241 | 'upload_date': '20150205', | |
d9aa2b78 RS |
242 | }, |
243 | }, | |
574b2a73 | 244 | { |
245 | 'url': 'http://www.nbcnews.com/business/autos/volkswagen-11-million-vehicles-could-have-suspect-software-emissions-scandal-n431456', | |
246 | 'md5': 'a49e173825e5fcd15c13fc297fced39d', | |
247 | 'info_dict': { | |
248 | 'id': '529953347624', | |
249 | 'ext': 'mp4', | |
0437307a RA |
250 | 'title': 'Volkswagen U.S. Chief:\xa0 We Have Totally Screwed Up', |
251 | 'description': 'md5:c8be487b2d80ff0594c005add88d8351', | |
252 | 'upload_date': '20150922', | |
253 | 'timestamp': 1442917800, | |
254 | 'uploader': 'NBCU-NEWS', | |
574b2a73 | 255 | }, |
574b2a73 | 256 | }, |
cb7d4d0e | 257 | { |
258 | 'url': 'http://www.today.com/video/see-the-aurora-borealis-from-space-in-stunning-new-nasa-video-669831235788', | |
259 | 'md5': '118d7ca3f0bea6534f119c68ef539f71', | |
260 | 'info_dict': { | |
261 | 'id': '669831235788', | |
262 | 'ext': 'mp4', | |
263 | 'title': 'See the aurora borealis from space in stunning new NASA video', | |
264 | 'description': 'md5:74752b7358afb99939c5f8bb2d1d04b1', | |
265 | 'upload_date': '20160420', | |
266 | 'timestamp': 1461152093, | |
0437307a RA |
267 | 'uploader': 'NBCU-NEWS', |
268 | }, | |
269 | }, | |
270 | { | |
271 | 'url': 'http://www.msnbc.com/all-in-with-chris-hayes/watch/the-chaotic-gop-immigration-vote-314487875924', | |
272 | 'md5': '6d236bf4f3dddc226633ce6e2c3f814d', | |
273 | 'info_dict': { | |
274 | 'id': '314487875924', | |
275 | 'ext': 'mp4', | |
276 | 'title': 'The chaotic GOP immigration vote', | |
277 | 'description': 'The Republican House votes on a border bill that has no chance of getting through the Senate or signed by the President and is drawing criticism from all sides.', | |
278 | 'thumbnail': 're:^https?://.*\.jpg$', | |
279 | 'timestamp': 1406937606, | |
280 | 'upload_date': '20140802', | |
281 | 'uploader': 'NBCU-NEWS', | |
282 | 'categories': ['MSNBC/Topics/Franchise/Best of last night', 'MSNBC/Topics/General/Congress'], | |
cb7d4d0e | 283 | }, |
284 | }, | |
3f125c8c S |
285 | { |
286 | 'url': 'http://www.nbcnews.com/watch/dateline/full-episode--deadly-betrayal-386250819952', | |
287 | 'only_matching': True, | |
288 | }, | |
5de008e8 YCH |
289 | { |
290 | # From http://www.vulture.com/2016/06/letterman-couldnt-care-less-about-late-night.html | |
291 | 'url': 'http://www.nbcnews.com/widget/video-embed/701714499682', | |
292 | 'only_matching': True, | |
293 | }, | |
87fe568c | 294 | ] |
0bc56fa6 JMF |
295 | |
296 | def _real_extract(self, url): | |
297 | mobj = re.match(self._VALID_URL, url) | |
298 | video_id = mobj.group('id') | |
87fe568c JMF |
299 | if video_id is not None: |
300 | all_info = self._download_xml('http://www.nbcnews.com/id/%s/displaymode/1219' % video_id, video_id) | |
301 | info = all_info.find('video') | |
0bc56fa6 | 302 | |
87fe568c JMF |
303 | return { |
304 | 'id': video_id, | |
305 | 'title': info.find('headline').text, | |
306 | 'ext': 'flv', | |
307 | 'url': find_xpath_attr(info, 'media', 'type', 'flashVideo').text, | |
d890b4cc | 308 | 'description': info.find('caption').text, |
87fe568c JMF |
309 | 'thumbnail': find_xpath_attr(info, 'media', 'type', 'thumbnail').text, |
310 | } | |
311 | else: | |
d9aa2b78 | 312 | # "feature" and "nightly-news" pages use theplatform.com |
0437307a RA |
313 | video_id = mobj.group('mpx_id') |
314 | if not video_id.isdigit(): | |
315 | webpage = self._download_webpage(url, video_id) | |
316 | info = None | |
317 | bootstrap_json = self._search_regex( | |
318 | [r'(?m)(?:var\s+(?:bootstrapJson|playlistData)|NEWS\.videoObj)\s*=\s*({.+});?\s*$', | |
319 | r'videoObj\s*:\s*({.+})', r'data-video="([^"]+)"'], | |
320 | webpage, 'bootstrap json', default=None) | |
321 | bootstrap = self._parse_json( | |
322 | bootstrap_json, video_id, transform_source=unescapeHTML) | |
323 | if 'results' in bootstrap: | |
324 | info = bootstrap['results'][0]['video'] | |
325 | elif 'video' in bootstrap: | |
326 | info = bootstrap['video'] | |
574b2a73 | 327 | else: |
0437307a RA |
328 | info = bootstrap |
329 | video_id = info['mpxId'] | |
87fe568c JMF |
330 | |
331 | return { | |
0437307a | 332 | '_type': 'url_transparent', |
574b2a73 | 333 | 'id': video_id, |
0437307a RA |
334 | # http://feed.theplatform.com/f/2E2eJC/nbcnews also works |
335 | 'url': 'http://feed.theplatform.com/f/2E2eJC/nnd_NBCNews?byId=%s' % video_id, | |
336 | 'ie_key': 'ThePlatformFeed', | |
87fe568c | 337 | } |