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',
41 'url': 'http://www.nbc.com/saturday-night-live/video/star-wars-teaser/2832821',
45 'title': 'Star Wars Teaser',
46 'description': 'md5:0b40f9cbde5b671a7ff62fceccc4f442',
48 'skip': 'Only works from US',
52 def _real_extract(self, url):
53 video_id = self._match_id(url)
54 webpage = self._download_webpage(url, video_id)
55 theplatform_url = self._search_regex(
57 r'(?:class="video-player video-player-full" data-mpx-url|class="player" src)="(.*?)"',
58 r'"embedURL"\s*:\s*"([^"]+)"'
60 webpage, 'theplatform url').replace('_no_endcard', '')
61 if theplatform_url.startswith('//'):
62 theplatform_url = 'http:' + theplatform_url
63 return self.url_result(theplatform_url)
66 class NBCSportsVPlayerIE(InfoExtractor):
67 _VALID_URL = r'https?://vplayer\.nbcsports\.com/(?:[^/]+/)+(?P<id>[0-9a-zA-Z_]+)'
70 'url': 'https://vplayer.nbcsports.com/p/BxmELC/nbcsports_share/select/9CsDKds0kvHI',
74 'description': 'md5:df390f70a9ba7c95ff1daace988f0d8d',
75 'title': 'Tyler Kalinoski hits buzzer-beater to lift Davidson',
78 'url': 'http://vplayer.nbcsports.com/p/BxmELC/nbc_embedshare/select/_hqLjQ95yx8Z',
79 'only_matching': True,
83 def _extract_url(webpage):
85 r'<iframe[^>]+src="(?P<url>https?://vplayer\.nbcsports\.com/[^"]+)"', webpage)
87 return iframe_m.group('url')
89 def _real_extract(self, url):
90 video_id = self._match_id(url)
91 webpage = self._download_webpage(url, video_id)
92 theplatform_url = self._og_search_video_url(webpage)
93 return self.url_result(theplatform_url, 'ThePlatform')
96 class NBCSportsIE(InfoExtractor):
97 # Does not include https becuase its certificate is invalid
98 _VALID_URL = r'http://www\.nbcsports\.com//?(?:[^/]+/)+(?P<id>[0-9a-z-]+)'
101 'url': 'http://www.nbcsports.com//college-basketball/ncaab/tom-izzo-michigan-st-has-so-much-respect-duke',
103 'id': 'PHJSaFWbrTY9',
105 'title': 'Tom Izzo, Michigan St. has \'so much respect\' for Duke',
106 'description': 'md5:ecb459c9d59e0766ac9c7d5d0eda8113',
110 def _real_extract(self, url):
111 video_id = self._match_id(url)
112 webpage = self._download_webpage(url, video_id)
113 return self.url_result(
114 NBCSportsVPlayerIE._extract_url(webpage), 'NBCSportsVPlayer')
117 class NBCNewsIE(InfoExtractor):
118 _VALID_URL = r'''(?x)https?://(?:www\.)?nbcnews\.com/
119 (?:video/.+?/(?P<id>\d+)|
120 (?:feature|nightly-news)/[^/]+/(?P<title>.+))
125 'url': 'http://www.nbcnews.com/video/nbc-news/52753292',
126 'md5': '47abaac93c6eaf9ad37ee6c4463a5179',
130 'title': 'Crew emerges after four-month Mars food study',
131 'description': 'md5:24e632ffac72b35f8b67a12d1b6ddfc1',
135 'url': 'http://www.nbcnews.com/feature/edward-snowden-interview/how-twitter-reacted-snowden-interview-n117236',
136 'md5': 'b2421750c9f260783721d898f4c42063',
138 'id': 'I1wpAI_zmhsQ',
140 'title': 'How Twitter Reacted To The Snowden Interview',
141 'description': 'md5:65a0bd5d76fe114f3c2727aa3a81fe64',
143 'add_ie': ['ThePlatform'],
146 'url': 'http://www.nbcnews.com/feature/dateline-full-episodes/full-episode-family-business-n285156',
147 'md5': 'fdbf39ab73a72df5896b6234ff98518a',
149 'id': 'Wjf9EDR3A_60',
151 'title': 'FULL EPISODE: Family Business',
152 'description': 'md5:757988edbaae9d7be1d585eb5d55cc04',
156 'url': 'http://www.nbcnews.com/nightly-news/video/nightly-news-with-brian-williams-full-broadcast-february-4-394064451844',
157 'md5': 'b5dda8cddd8650baa0dcb616dd2cf60d',
159 'id': 'sekXqyTVnmN3',
161 'title': 'Nightly News with Brian Williams Full Broadcast (February 4)',
162 'description': 'md5:1c10c1eccbe84a26e5debb4381e2d3c5',
167 def _real_extract(self, url):
168 mobj = re.match(self._VALID_URL, url)
169 video_id = mobj.group('id')
170 if video_id is not None:
171 all_info = self._download_xml('http://www.nbcnews.com/id/%s/displaymode/1219' % video_id, video_id)
172 info = all_info.find('video')
176 'title': info.find('headline').text,
178 'url': find_xpath_attr(info, 'media', 'type', 'flashVideo').text,
179 'description': compat_str(info.find('caption').text),
180 'thumbnail': find_xpath_attr(info, 'media', 'type', 'thumbnail').text,
183 # "feature" and "nightly-news" pages use theplatform.com
184 title = mobj.group('title')
185 webpage = self._download_webpage(url, title)
186 bootstrap_json = self._search_regex(
187 r'var\s+(?:bootstrapJson|playlistData)\s*=\s*({.+});?\s*$',
188 webpage, 'bootstrap json', flags=re.MULTILINE)
189 bootstrap = self._parse_json(bootstrap_json, video_id)
190 info = bootstrap['results'][0]['video']
191 mpxid = info['mpxId']
194 info['fallbackPlaylistUrl'],
195 info['associatedPlaylistUrl'],
198 for base_url in base_urls:
201 playlist_url = base_url + '?form=MPXNBCNewsAPI'
204 all_videos = self._download_json(playlist_url, title)
205 except ExtractorError as ee:
206 if isinstance(ee.cause, compat_HTTPError):
210 if not all_videos or 'videos' not in all_videos:
214 info = next(v for v in all_videos['videos'] if v['mpxId'] == mpxid)
216 except StopIteration:
220 raise ExtractorError('Could not find video in playlists')
224 # We get the best quality video
225 'url': info['videoAssets'][-1]['publicUrl'],
226 'ie_key': 'ThePlatform',