]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/nbc.py
1 from __future__
import unicode_literals
5 from . common
import InfoExtractor
6 from . theplatform
import ThePlatformIE
7 from . adobepass
import AdobePassIE
17 class NBCIE ( AdobePassIE
):
18 _VALID_URL
= r
'https?(?P<permalink>://(?:www\.)?nbc\.com/(?:classic-tv/)?[^/]+/video/[^/]+/(?P<id>n?\d+))'
22 'url' : 'http://www.nbc.com/the-tonight-show/video/jimmy-fallon-surprises-fans-at-ben-jerrys/2848237' ,
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.' ,
28 'timestamp' : 1424246400 ,
29 'upload_date' : '20150218' ,
30 'uploader' : 'NBCU-COM' ,
34 'skip_download' : True ,
38 'url' : 'http://www.nbc.com/saturday-night-live/video/star-wars-teaser/2832821' ,
42 'title' : 'Star Wars Teaser' ,
43 'description' : 'md5:0b40f9cbde5b671a7ff62fceccc4f442' ,
44 'timestamp' : 1417852800 ,
45 'upload_date' : '20141206' ,
46 'uploader' : 'NBCU-COM' ,
50 'skip_download' : True ,
52 'skip' : 'Only works from US' ,
55 # HLS streams requires the 'hdnea3' cookie
56 'url' : 'http://www.nbc.com/Kings/video/goliath/n1806' ,
58 'id' : '101528f5a9e8127b107e98c5e6ce4638' ,
61 '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.' ,
62 'timestamp' : 1237100400 ,
63 'upload_date' : '20090315' ,
64 'uploader' : 'NBCU-COM' ,
67 'skip_download' : True ,
69 'skip' : 'Only works from US' ,
72 'url' : 'https://www.nbc.com/classic-tv/charles-in-charge/video/charles-in-charge-pilot/n3310' ,
73 'only_matching' : True ,
77 def _real_extract ( self
, url
):
78 permalink
, video_id
= re
. match ( self
._ VALID
_U RL
, url
). groups ()
79 permalink
= 'http' + permalink
80 video_data
= self
._ download
_ json
(
81 'https://api.nbc.com/v3/videos' , video_id
, query
={
82 'filter[permalink]' : permalink
,
83 })[ 'data' ][ 0 ][ 'attributes' ]
88 video_id
= video_data
[ 'guid' ]
89 title
= video_data
[ 'title' ]
90 if video_data
. get ( 'entitlement' ) == 'auth' :
91 resource
= self
._ get
_ mvpd
_ resource
(
92 'nbcentertainment' , title
, video_id
,
93 video_data
. get ( 'vChipRating' ))
94 query
[ 'auth' ] = self
._ extract
_ mvpd
_ auth
(
95 url
, video_id
, 'nbcentertainment' , resource
)
96 theplatform_url
= smuggle_url ( update_url_query (
97 'http://link.theplatform.com/s/NnzsPC/media/guid/2410887629/' + video_id
,
98 query
), { 'force_smil_url' : True })
100 '_type' : 'url_transparent' ,
103 'url' : theplatform_url
,
104 'description' : video_data
. get ( 'description' ),
105 'keywords' : video_data
. get ( 'keywords' ),
106 'season_number' : int_or_none ( video_data
. get ( 'seasonNumber' )),
107 'episode_number' : int_or_none ( video_data
. get ( 'episodeNumber' )),
108 'series' : video_data
. get ( 'showName' ),
109 'ie_key' : 'ThePlatform' ,
113 class NBCSportsVPlayerIE ( InfoExtractor
):
114 _VALID_URL
= r
'https?://vplayer\.nbcsports\.com/(?:[^/]+/)+(?P<id>[0-9a-zA-Z_]+)'
117 'url' : 'https://vplayer.nbcsports.com/p/BxmELC/nbcsports_embed/select/9CsDKds0kvHI' ,
119 'id' : '9CsDKds0kvHI' ,
121 'description' : 'md5:df390f70a9ba7c95ff1daace988f0d8d' ,
122 'title' : 'Tyler Kalinoski hits buzzer-beater to lift Davidson' ,
123 'timestamp' : 1426270238 ,
124 'upload_date' : '20150313' ,
125 'uploader' : 'NBCU-SPORTS' ,
128 'url' : 'https://vplayer.nbcsports.com/p/BxmELC/nbcsports_embed/select/media/_hqLjQ95yx8Z' ,
129 'only_matching' : True ,
133 def _extract_url ( webpage
):
134 iframe_m
= re
. search (
135 r
'<iframe[^>]+src="(?P<url>https?://vplayer\.nbcsports\.com/[^"]+)"' , webpage
)
137 return iframe_m
. group ( 'url' )
139 def _real_extract ( self
, url
):
140 video_id
= self
._ match
_ id
( url
)
141 webpage
= self
._ download
_ webpage
( url
, video_id
)
142 theplatform_url
= self
._ og
_ search
_ video
_u rl
( webpage
). replace (
143 'vplayer.nbcsports.com' , 'player.theplatform.com' )
144 return self
. url_result ( theplatform_url
, 'ThePlatform' )
147 class NBCSportsIE ( InfoExtractor
):
148 # Does not include https because its certificate is invalid
149 _VALID_URL
= r
'https?://(?:www\.)?nbcsports\.com//?(?:[^/]+/)+(?P<id>[0-9a-z-]+)'
152 'url' : 'http://www.nbcsports.com//college-basketball/ncaab/tom-izzo-michigan-st-has-so-much-respect-duke' ,
154 'id' : 'PHJSaFWbrTY9' ,
156 'title' : 'Tom Izzo, Michigan St. has \' so much respect \' for Duke' ,
157 'description' : 'md5:ecb459c9d59e0766ac9c7d5d0eda8113' ,
158 'uploader' : 'NBCU-SPORTS' ,
159 'upload_date' : '20150330' ,
160 'timestamp' : 1427726529 ,
164 def _real_extract ( self
, url
):
165 video_id
= self
._ match
_ id
( url
)
166 webpage
= self
._ download
_ webpage
( url
, video_id
)
167 return self
. url_result (
168 NBCSportsVPlayerIE
._ extract
_u rl
( webpage
), 'NBCSportsVPlayer' )
171 class CSNNEIE ( InfoExtractor
):
172 _VALID_URL
= r
'https?://(?:www\.)?csnne\.com/video/(?P<id>[0-9a-z-]+)'
175 'url' : 'http://www.csnne.com/video/snc-evening-update-wright-named-red-sox-no-5-starter' ,
177 'id' : 'yvBLLUgQ8WU0' ,
179 'title' : 'SNC evening update: Wright named Red Sox \' No. 5 starter.' ,
180 'description' : 'md5:1753cfee40d9352b19b4c9b3e589b9e3' ,
181 'timestamp' : 1459369979 ,
182 'upload_date' : '20160330' ,
183 'uploader' : 'NBCU-SPORTS' ,
187 def _real_extract ( self
, url
):
188 display_id
= self
._ match
_ id
( url
)
189 webpage
= self
._ download
_ webpage
( url
, display_id
)
191 '_type' : 'url_transparent' ,
192 'ie_key' : 'ThePlatform' ,
193 'url' : self
._ html
_ search
_ meta
( 'twitter:player:stream' , webpage
),
194 'display_id' : display_id
,
198 class NBCNewsIE ( ThePlatformIE
):
199 _VALID_URL
= r
'''(?x)https?://(?:www\.)?(?:nbcnews|today|msnbc)\.com/
200 (?:video/.+?/(?P<id>\d+)|
201 ([^/]+/)*(?:.*-)?(?P<mpx_id>[^/?]+))
206 'url' : 'http://www.nbcnews.com/video/nbc-news/52753292' ,
207 'md5' : '47abaac93c6eaf9ad37ee6c4463a5179' ,
211 'title' : 'Crew emerges after four-month Mars food study' ,
212 'description' : 'md5:24e632ffac72b35f8b67a12d1b6ddfc1' ,
216 'url' : 'http://www.nbcnews.com/watch/nbcnews-com/how-twitter-reacted-to-the-snowden-interview-269389891880' ,
217 'md5' : 'af1adfa51312291a017720403826bb64' ,
219 'id' : 'p_tweet_snow_140529' ,
221 'title' : 'How Twitter Reacted To The Snowden Interview' ,
222 'description' : 'md5:65a0bd5d76fe114f3c2727aa3a81fe64' ,
223 'uploader' : 'NBCU-NEWS' ,
224 'timestamp' : 1401363060 ,
225 'upload_date' : '20140529' ,
229 'url' : 'http://www.nbcnews.com/feature/dateline-full-episodes/full-episode-family-business-n285156' ,
230 'md5' : 'fdbf39ab73a72df5896b6234ff98518a' ,
232 'id' : '529953347624' ,
234 'title' : 'FULL EPISODE: Family Business' ,
235 'description' : 'md5:757988edbaae9d7be1d585eb5d55cc04' ,
237 'skip' : 'This page is unavailable.' ,
240 'url' : 'http://www.nbcnews.com/nightly-news/video/nightly-news-with-brian-williams-full-broadcast-february-4-394064451844' ,
241 'md5' : '73135a2e0ef819107bbb55a5a9b2a802' ,
243 'id' : 'nn_netcast_150204' ,
245 'title' : 'Nightly News with Brian Williams Full Broadcast (February 4)' ,
246 'description' : 'md5:1c10c1eccbe84a26e5debb4381e2d3c5' ,
247 'timestamp' : 1423104900 ,
248 'uploader' : 'NBCU-NEWS' ,
249 'upload_date' : '20150205' ,
253 'url' : 'http://www.nbcnews.com/business/autos/volkswagen-11-million-vehicles-could-have-suspect-software-emissions-scandal-n431456' ,
254 'md5' : 'a49e173825e5fcd15c13fc297fced39d' ,
256 'id' : 'x_lon_vwhorn_150922' ,
258 'title' : 'Volkswagen U.S. Chief: \xa0 We Have Totally Screwed Up' ,
259 'description' : 'md5:c8be487b2d80ff0594c005add88d8351' ,
260 'upload_date' : '20150922' ,
261 'timestamp' : 1442917800 ,
262 'uploader' : 'NBCU-NEWS' ,
266 'url' : 'http://www.today.com/video/see-the-aurora-borealis-from-space-in-stunning-new-nasa-video-669831235788' ,
267 'md5' : '118d7ca3f0bea6534f119c68ef539f71' ,
269 'id' : 'tdy_al_space_160420' ,
271 'title' : 'See the aurora borealis from space in stunning new NASA video' ,
272 'description' : 'md5:74752b7358afb99939c5f8bb2d1d04b1' ,
273 'upload_date' : '20160420' ,
274 'timestamp' : 1461152093 ,
275 'uploader' : 'NBCU-NEWS' ,
279 'url' : 'http://www.msnbc.com/all-in-with-chris-hayes/watch/the-chaotic-gop-immigration-vote-314487875924' ,
280 'md5' : '6d236bf4f3dddc226633ce6e2c3f814d' ,
282 'id' : 'n_hayes_Aimm_140801_272214' ,
284 'title' : 'The chaotic GOP immigration vote' ,
285 '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.' ,
286 'thumbnail' : r
're:^https?://.*\.jpg$' ,
287 'timestamp' : 1406937606 ,
288 'upload_date' : '20140802' ,
289 'uploader' : 'NBCU-NEWS' ,
293 'url' : 'http://www.nbcnews.com/watch/dateline/full-episode--deadly-betrayal-386250819952' ,
294 'only_matching' : True ,
297 # From http://www.vulture.com/2016/06/letterman-couldnt-care-less-about-late-night.html
298 'url' : 'http://www.nbcnews.com/widget/video-embed/701714499682' ,
299 'only_matching' : True ,
303 def _real_extract ( self
, url
):
304 mobj
= re
. match ( self
._ VALID
_U RL
, url
)
305 video_id
= mobj
. group ( 'id' )
306 if video_id
is not None :
307 all_info
= self
._ download
_ xml
( 'http://www.nbcnews.com/id/ %s /displaymode/1219' % video_id
, video_id
)
308 info
= all_info
. find ( 'video' )
312 'title' : info
. find ( 'headline' ). text
,
314 'url' : find_xpath_attr ( info
, 'media' , 'type' , 'flashVideo' ). text
,
315 'description' : info
. find ( 'caption' ). text
,
316 'thumbnail' : find_xpath_attr ( info
, 'media' , 'type' , 'thumbnail' ). text
,
319 # "feature" and "nightly-news" pages use theplatform.com
320 video_id
= mobj
. group ( 'mpx_id' )
321 webpage
= self
._ download
_ webpage
( url
, video_id
)
323 filter_param
= 'byId'
324 bootstrap_json
= self
._ search
_ regex
(
325 [ r
'(?m)(?:var\s+(?:bootstrapJson|playlistData)|NEWS\.videoObj)\s*=\s*({.+});?\s*$' ,
326 r
'videoObj\s*:\s*({.+})' , r
'data-video="([^"]+)"' ,
327 r
'jQuery\.extend\(Drupal\.settings\s*,\s*({.+?})\);' ],
328 webpage
, 'bootstrap json' , default
= None )
330 bootstrap
= self
._ parse
_ json
(
331 bootstrap_json
, video_id
, transform_source
= unescapeHTML
)
334 if 'results' in bootstrap
:
335 info
= bootstrap
[ 'results' ][ 0 ][ 'video' ]
336 elif 'video' in bootstrap
:
337 info
= bootstrap
[ 'video' ]
338 elif 'msnbcVideoInfo' in bootstrap
:
339 info
= bootstrap
[ 'msnbcVideoInfo' ][ 'meta' ]
340 elif 'msnbcThePlatform' in bootstrap
:
341 info
= bootstrap
[ 'msnbcThePlatform' ][ 'videoPlayer' ][ 'video' ]
346 video_id
= info
[ 'guid' ]
347 filter_param
= 'byGuid'
348 elif 'mpxId' in info
:
349 video_id
= info
[ 'mpxId' ]
352 '_type' : 'url_transparent' ,
354 # http://feed.theplatform.com/f/2E2eJC/nbcnews also works
355 'url' : update_url_query ( 'http://feed.theplatform.com/f/2E2eJC/nnd_NBCNews' , { filter_param
: video_id
}),
356 'ie_key' : 'ThePlatformFeed' ,
360 class NBCOlympicsIE ( InfoExtractor
):
361 _VALID_URL
= r
'https?://www\.nbcolympics\.com/video/(?P<id>[a-z-]+)'
364 # Geo-restricted to US
365 'url' : 'http://www.nbcolympics.com/video/justin-roses-son-leo-was-tears-after-his-dad-won-gold' ,
366 'md5' : '54fecf846d05429fbaa18af557ee523a' ,
368 'id' : 'WjTBzDXx5AUq' ,
369 'display_id' : 'justin-roses-son-leo-was-tears-after-his-dad-won-gold' ,
371 'title' : 'Rose \' s son Leo was in tears after his dad won gold' ,
372 'description' : 'Olympic gold medalist Justin Rose gets emotional talking to the impact his win in men \' s golf has already had on his children.' ,
373 'timestamp' : 1471274964 ,
374 'upload_date' : '20160815' ,
375 'uploader' : 'NBCU-SPORTS' ,
379 def _real_extract ( self
, url
):
380 display_id
= self
._ match
_ id
( url
)
382 webpage
= self
._ download
_ webpage
( url
, display_id
)
384 drupal_settings
= self
._ parse
_ json
( self
._ search
_ regex
(
385 r
'jQuery\.extend\(Drupal\.settings\s*,\s*({.+?})\);' ,
386 webpage
, 'drupal settings' ), display_id
)
388 iframe_url
= drupal_settings
[ 'vod' ][ 'iframe_url' ]
389 theplatform_url
= iframe_url
. replace (
390 'vplayer.nbcolympics.com' , 'player.theplatform.com' )
393 '_type' : 'url_transparent' ,
394 'url' : theplatform_url
,
395 'ie_key' : ThePlatformIE
. ie_key (),
396 'display_id' : display_id
,