1 from __future__ import unicode_literals
5 from .common import InfoExtractor
16 class NBCIE(InfoExtractor):
17 _VALID_URL = r'https?://www\.nbc\.com/(?:[^/]+/)+(?P<id>n?\d+)'
21 'url': 'http://www.nbc.com/the-tonight-show/segments/112966',
22 # md5 checksum is not stable
26 'title': 'Jimmy Fallon Surprises Fans at Ben & Jerry\'s',
27 'description': 'Jimmy gives out free scoops of his new "Tonight Dough" ice cream flavor by surprising customers at the Ben & Jerry\'s scoop shop.',
31 'url': 'http://www.nbc.com/the-tonight-show/episodes/176',
35 'title': 'Ricky Gervais, Steven Van Zandt, ILoveMakonnen',
36 'description': 'A brand new episode of The Tonight Show welcomes Ricky Gervais, Steven Van Zandt and ILoveMakonnen.',
38 'skip': 'Only works from US',
42 def _real_extract(self, url):
43 video_id = self._match_id(url)
44 webpage = self._download_webpage(url, video_id)
45 theplatform_url = self._search_regex(
46 '(?:class="video-player video-player-full" data-mpx-url|class="player" src)="(.*?)"',
47 webpage, 'theplatform url').replace('_no_endcard', '')
48 if theplatform_url.startswith('//'):
49 theplatform_url = 'http:' + theplatform_url
50 return self.url_result(theplatform_url)
53 class NBCSportsVPlayerIE(InfoExtractor):
54 _VALID_URL = r'https?://vplayer\.nbcsports\.com/(?:[^/]+/)+(?P<id>[0-9a-zA-Z]+)'
57 'url': 'https://vplayer.nbcsports.com/p/BxmELC/nbcsports_share/select/9CsDKds0kvHI',
58 'md5': 'ceae8dced5c14a1c1ffcb7a32194cca5',
62 'description': 'md5:df390f70a9ba7c95ff1daace988f0d8d',
63 'title': 'Tyler Kalinoski hits buzzer-beater to lift Davidson',
68 def _extract_url(webpage):
70 r'<iframe[^>]+src="(?P<url>https?://vplayer\.nbcsports\.com/[^"]+)"', webpage)
72 return iframe_m.group('url')
74 def _real_extract(self, url):
75 video_id = self._match_id(url)
76 webpage = self._download_webpage(url, video_id)
77 theplatform_url = self._og_search_video_url(webpage)
78 return self.url_result(theplatform_url, 'ThePlatform')
81 class NBCSportsIE(InfoExtractor):
82 # Does not include https becuase its certificate is invalid
83 _VALID_URL = r'http://www\.nbcsports\.com//?(?:[^/]+/)+(?P<id>[0-9a-z-]+)'
86 'url': 'http://www.nbcsports.com//college-basketball/ncaab/tom-izzo-michigan-st-has-so-much-respect-duke',
87 'md5': 'ba6c93f96b67bf05344f78bd523dac0f',
91 'title': 'Tom Izzo, Michigan St. has \'so much respect\' for Duke',
92 'description': 'md5:ecb459c9d59e0766ac9c7d5d0eda8113',
96 def _real_extract(self, url):
97 video_id = self._match_id(url)
98 webpage = self._download_webpage(url, video_id)
99 return self.url_result(
100 NBCSportsVPlayerIE._extract_url(webpage), 'NBCSportsVPlayer')
103 class NBCNewsIE(InfoExtractor):
104 _VALID_URL = r'''(?x)https?://(?:www\.)?nbcnews\.com/
105 (?:video/.+?/(?P<id>\d+)|
106 (?:feature|nightly-news)/[^/]+/(?P<title>.+))
111 'url': 'http://www.nbcnews.com/video/nbc-news/52753292',
112 'md5': '47abaac93c6eaf9ad37ee6c4463a5179',
116 'title': 'Crew emerges after four-month Mars food study',
117 'description': 'md5:24e632ffac72b35f8b67a12d1b6ddfc1',
121 'url': 'http://www.nbcnews.com/feature/edward-snowden-interview/how-twitter-reacted-snowden-interview-n117236',
122 'md5': 'b2421750c9f260783721d898f4c42063',
124 'id': 'I1wpAI_zmhsQ',
126 'title': 'How Twitter Reacted To The Snowden Interview',
127 'description': 'md5:65a0bd5d76fe114f3c2727aa3a81fe64',
129 'add_ie': ['ThePlatform'],
132 'url': 'http://www.nbcnews.com/feature/dateline-full-episodes/full-episode-family-business-n285156',
133 'md5': 'fdbf39ab73a72df5896b6234ff98518a',
135 'id': 'Wjf9EDR3A_60',
137 'title': 'FULL EPISODE: Family Business',
138 'description': 'md5:757988edbaae9d7be1d585eb5d55cc04',
142 'url': 'http://www.nbcnews.com/nightly-news/video/nightly-news-with-brian-williams-full-broadcast-february-4-394064451844',
143 'md5': 'b5dda8cddd8650baa0dcb616dd2cf60d',
145 'id': 'sekXqyTVnmN3',
147 'title': 'Nightly News with Brian Williams Full Broadcast (February 4)',
148 'description': 'md5:1c10c1eccbe84a26e5debb4381e2d3c5',
153 def _real_extract(self, url):
154 mobj = re.match(self._VALID_URL, url)
155 video_id = mobj.group('id')
156 if video_id is not None:
157 all_info = self._download_xml('http://www.nbcnews.com/id/%s/displaymode/1219' % video_id, video_id)
158 info = all_info.find('video')
162 'title': info.find('headline').text,
164 'url': find_xpath_attr(info, 'media', 'type', 'flashVideo').text,
165 'description': compat_str(info.find('caption').text),
166 'thumbnail': find_xpath_attr(info, 'media', 'type', 'thumbnail').text,
169 # "feature" and "nightly-news" pages use theplatform.com
170 title = mobj.group('title')
171 webpage = self._download_webpage(url, title)
172 bootstrap_json = self._search_regex(
173 r'var\s+(?:bootstrapJson|playlistData)\s*=\s*({.+});?\s*$',
174 webpage, 'bootstrap json', flags=re.MULTILINE)
175 bootstrap = self._parse_json(bootstrap_json, video_id)
176 info = bootstrap['results'][0]['video']
177 mpxid = info['mpxId']
180 info['fallbackPlaylistUrl'],
181 info['associatedPlaylistUrl'],
184 for base_url in base_urls:
187 playlist_url = base_url + '?form=MPXNBCNewsAPI'
190 all_videos = self._download_json(playlist_url, title)
191 except ExtractorError as ee:
192 if isinstance(ee.cause, compat_HTTPError):
196 if not all_videos or 'videos' not in all_videos:
200 info = next(v for v in all_videos['videos'] if v['mpxId'] == mpxid)
202 except StopIteration:
206 raise ExtractorError('Could not find video in playlists')
210 # We get the best quality video
211 'url': info['videoAssets'][-1]['publicUrl'],
212 'ie_key': 'ThePlatform',