]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/nbc.py
9dc8f9ebcbe7bd0fbde8374fb91d7727e7ebb648
1 from __future__
import unicode_literals
6 from . common
import InfoExtractor
7 from . theplatform
import ThePlatformIE
8 from . adobepass
import AdobePassIE
18 class NBCIE ( AdobePassIE
):
19 _VALID_URL
= r
'https?(?P<permalink>://(?:www\.)?nbc\.com/(?:classic-tv/)?[^/]+/video/[^/]+/(?P<id>n?\d+))'
23 'url' : 'http://www.nbc.com/the-tonight-show/video/jimmy-fallon-surprises-fans-at-ben-jerrys/2848237' ,
27 'title' : 'Jimmy Fallon Surprises Fans at Ben & Jerry \' s' ,
28 'description' : 'Jimmy gives out free scoops of his new "Tonight Dough" ice cream flavor by surprising customers at the Ben & Jerry \' s scoop shop.' ,
29 'timestamp' : 1424246400 ,
30 'upload_date' : '20150218' ,
31 'uploader' : 'NBCU-COM' ,
35 'skip_download' : True ,
39 'url' : 'http://www.nbc.com/saturday-night-live/video/star-wars-teaser/2832821' ,
43 'title' : 'Star Wars Teaser' ,
44 'description' : 'md5:0b40f9cbde5b671a7ff62fceccc4f442' ,
45 'timestamp' : 1417852800 ,
46 'upload_date' : '20141206' ,
47 'uploader' : 'NBCU-COM' ,
51 'skip_download' : True ,
53 'skip' : 'Only works from US' ,
56 # HLS streams requires the 'hdnea3' cookie
57 'url' : 'http://www.nbc.com/Kings/video/goliath/n1806' ,
59 'id' : '101528f5a9e8127b107e98c5e6ce4638' ,
62 '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.' ,
63 'timestamp' : 1237100400 ,
64 'upload_date' : '20090315' ,
65 'uploader' : 'NBCU-COM' ,
68 'skip_download' : True ,
70 'skip' : 'Only works from US' ,
73 'url' : 'https://www.nbc.com/classic-tv/charles-in-charge/video/charles-in-charge-pilot/n3310' ,
74 'only_matching' : True ,
78 def _real_extract ( self
, url
):
79 permalink
, video_id
= re
. match ( self
._ VALID
_U RL
, url
). groups ()
80 permalink
= 'http' + permalink
81 video_data
= self
._ download
_ json
(
82 'https://api.nbc.com/v3/videos' , video_id
, query
={
83 'filter[permalink]' : permalink
,
84 })[ 'data' ][ 0 ][ 'attributes' ]
89 video_id
= video_data
[ 'guid' ]
90 title
= video_data
[ 'title' ]
91 if video_data
. get ( 'entitlement' ) == 'auth' :
92 resource
= self
._ get
_ mvpd
_ resource
(
93 'nbcentertainment' , title
, video_id
,
94 video_data
. get ( 'vChipRating' ))
95 query
[ 'auth' ] = self
._ extract
_ mvpd
_ auth
(
96 url
, video_id
, 'nbcentertainment' , resource
)
97 theplatform_url
= smuggle_url ( update_url_query (
98 'http://link.theplatform.com/s/NnzsPC/media/guid/2410887629/' + video_id
,
99 query
), { 'force_smil_url' : True })
101 '_type' : 'url_transparent' ,
104 'url' : theplatform_url
,
105 'description' : video_data
. get ( 'description' ),
106 'keywords' : video_data
. get ( 'keywords' ),
107 'season_number' : int_or_none ( video_data
. get ( 'seasonNumber' )),
108 'episode_number' : int_or_none ( video_data
. get ( 'episodeNumber' )),
109 'series' : video_data
. get ( 'showName' ),
110 'ie_key' : 'ThePlatform' ,
114 class NBCSportsVPlayerIE ( InfoExtractor
):
115 _VALID_URL
= r
'https?://vplayer\.nbcsports\.com/(?:[^/]+/)+(?P<id>[0-9a-zA-Z_]+)'
118 'url' : 'https://vplayer.nbcsports.com/p/BxmELC/nbcsports_embed/select/9CsDKds0kvHI' ,
120 'id' : '9CsDKds0kvHI' ,
122 'description' : 'md5:df390f70a9ba7c95ff1daace988f0d8d' ,
123 'title' : 'Tyler Kalinoski hits buzzer-beater to lift Davidson' ,
124 'timestamp' : 1426270238 ,
125 'upload_date' : '20150313' ,
126 'uploader' : 'NBCU-SPORTS' ,
129 'url' : 'https://vplayer.nbcsports.com/p/BxmELC/nbcsports_embed/select/media/_hqLjQ95yx8Z' ,
130 'only_matching' : True ,
134 def _extract_url ( webpage
):
135 iframe_m
= re
. search (
136 r
'<iframe[^>]+src="(?P<url>https?://vplayer\.nbcsports\.com/[^"]+)"' , webpage
)
138 return iframe_m
. group ( 'url' )
140 def _real_extract ( self
, url
):
141 video_id
= self
._ match
_ id
( url
)
142 webpage
= self
._ download
_ webpage
( url
, video_id
)
143 theplatform_url
= self
._ og
_ search
_ video
_u rl
( webpage
). replace (
144 'vplayer.nbcsports.com' , 'player.theplatform.com' )
145 return self
. url_result ( theplatform_url
, 'ThePlatform' )
148 class NBCSportsIE ( InfoExtractor
):
149 # Does not include https because its certificate is invalid
150 _VALID_URL
= r
'https?://(?:www\.)?nbcsports\.com//?(?:[^/]+/)+(?P<id>[0-9a-z-]+)'
153 'url' : 'http://www.nbcsports.com//college-basketball/ncaab/tom-izzo-michigan-st-has-so-much-respect-duke' ,
155 'id' : 'PHJSaFWbrTY9' ,
157 'title' : 'Tom Izzo, Michigan St. has \' so much respect \' for Duke' ,
158 'description' : 'md5:ecb459c9d59e0766ac9c7d5d0eda8113' ,
159 'uploader' : 'NBCU-SPORTS' ,
160 'upload_date' : '20150330' ,
161 'timestamp' : 1427726529 ,
165 def _real_extract ( self
, url
):
166 video_id
= self
._ match
_ id
( url
)
167 webpage
= self
._ download
_ webpage
( url
, video_id
)
168 return self
. url_result (
169 NBCSportsVPlayerIE
._ extract
_u rl
( webpage
), 'NBCSportsVPlayer' )
172 class CSNNEIE ( InfoExtractor
):
173 _VALID_URL
= r
'https?://(?:www\.)?csnne\.com/video/(?P<id>[0-9a-z-]+)'
176 'url' : 'http://www.csnne.com/video/snc-evening-update-wright-named-red-sox-no-5-starter' ,
178 'id' : 'yvBLLUgQ8WU0' ,
180 'title' : 'SNC evening update: Wright named Red Sox \' No. 5 starter.' ,
181 'description' : 'md5:1753cfee40d9352b19b4c9b3e589b9e3' ,
182 'timestamp' : 1459369979 ,
183 'upload_date' : '20160330' ,
184 'uploader' : 'NBCU-SPORTS' ,
188 def _real_extract ( self
, url
):
189 display_id
= self
._ match
_ id
( url
)
190 webpage
= self
._ download
_ webpage
( url
, display_id
)
192 '_type' : 'url_transparent' ,
193 'ie_key' : 'ThePlatform' ,
194 'url' : self
._ html
_ search
_ meta
( 'twitter:player:stream' , webpage
),
195 'display_id' : display_id
,
199 class NBCNewsIE ( ThePlatformIE
):
200 _VALID_URL
= r
'''(?x)https?://(?:www\.)?(?:nbcnews|today|msnbc)\.com/
201 (?:video/.+?/(?P<id>\d+)|
202 ([^/]+/)*(?:.*-)?(?P<mpx_id>[^/?]+))
207 'url' : 'http://www.nbcnews.com/video/nbc-news/52753292' ,
208 'md5' : '47abaac93c6eaf9ad37ee6c4463a5179' ,
212 'title' : 'Crew emerges after four-month Mars food study' ,
213 'description' : 'md5:24e632ffac72b35f8b67a12d1b6ddfc1' ,
217 'url' : 'http://www.nbcnews.com/watch/nbcnews-com/how-twitter-reacted-to-the-snowden-interview-269389891880' ,
218 'md5' : 'af1adfa51312291a017720403826bb64' ,
220 'id' : 'p_tweet_snow_140529' ,
222 'title' : 'How Twitter Reacted To The Snowden Interview' ,
223 'description' : 'md5:65a0bd5d76fe114f3c2727aa3a81fe64' ,
224 'uploader' : 'NBCU-NEWS' ,
225 'timestamp' : 1401363060 ,
226 'upload_date' : '20140529' ,
230 'url' : 'http://www.nbcnews.com/feature/dateline-full-episodes/full-episode-family-business-n285156' ,
231 'md5' : 'fdbf39ab73a72df5896b6234ff98518a' ,
233 'id' : '529953347624' ,
235 'title' : 'FULL EPISODE: Family Business' ,
236 'description' : 'md5:757988edbaae9d7be1d585eb5d55cc04' ,
238 'skip' : 'This page is unavailable.' ,
241 'url' : 'http://www.nbcnews.com/nightly-news/video/nightly-news-with-brian-williams-full-broadcast-february-4-394064451844' ,
242 'md5' : '73135a2e0ef819107bbb55a5a9b2a802' ,
244 'id' : 'nn_netcast_150204' ,
246 'title' : 'Nightly News with Brian Williams Full Broadcast (February 4)' ,
247 'description' : 'md5:1c10c1eccbe84a26e5debb4381e2d3c5' ,
248 'timestamp' : 1423104900 ,
249 'uploader' : 'NBCU-NEWS' ,
250 'upload_date' : '20150205' ,
254 'url' : 'http://www.nbcnews.com/business/autos/volkswagen-11-million-vehicles-could-have-suspect-software-emissions-scandal-n431456' ,
255 'md5' : 'a49e173825e5fcd15c13fc297fced39d' ,
257 'id' : 'x_lon_vwhorn_150922' ,
259 'title' : 'Volkswagen U.S. Chief: \xa0 We Have Totally Screwed Up' ,
260 'description' : 'md5:c8be487b2d80ff0594c005add88d8351' ,
261 'upload_date' : '20150922' ,
262 'timestamp' : 1442917800 ,
263 'uploader' : 'NBCU-NEWS' ,
267 'url' : 'http://www.today.com/video/see-the-aurora-borealis-from-space-in-stunning-new-nasa-video-669831235788' ,
268 'md5' : '118d7ca3f0bea6534f119c68ef539f71' ,
270 'id' : 'tdy_al_space_160420' ,
272 'title' : 'See the aurora borealis from space in stunning new NASA video' ,
273 'description' : 'md5:74752b7358afb99939c5f8bb2d1d04b1' ,
274 'upload_date' : '20160420' ,
275 'timestamp' : 1461152093 ,
276 'uploader' : 'NBCU-NEWS' ,
280 'url' : 'http://www.msnbc.com/all-in-with-chris-hayes/watch/the-chaotic-gop-immigration-vote-314487875924' ,
281 'md5' : '6d236bf4f3dddc226633ce6e2c3f814d' ,
283 'id' : 'n_hayes_Aimm_140801_272214' ,
285 'title' : 'The chaotic GOP immigration vote' ,
286 '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.' ,
287 'thumbnail' : r
're:^https?://.*\.jpg$' ,
288 'timestamp' : 1406937606 ,
289 'upload_date' : '20140802' ,
290 'uploader' : 'NBCU-NEWS' ,
294 'url' : 'http://www.nbcnews.com/watch/dateline/full-episode--deadly-betrayal-386250819952' ,
295 'only_matching' : True ,
298 # From http://www.vulture.com/2016/06/letterman-couldnt-care-less-about-late-night.html
299 'url' : 'http://www.nbcnews.com/widget/video-embed/701714499682' ,
300 'only_matching' : True ,
304 def _real_extract ( self
, url
):
305 mobj
= re
. match ( self
._ VALID
_U RL
, url
)
306 video_id
= mobj
. group ( 'id' )
307 if video_id
is not None :
308 all_info
= self
._ download
_ xml
( 'http://www.nbcnews.com/id/ %s /displaymode/1219' % video_id
, video_id
)
309 info
= all_info
. find ( 'video' )
313 'title' : info
. find ( 'headline' ). text
,
315 'url' : find_xpath_attr ( info
, 'media' , 'type' , 'flashVideo' ). text
,
316 'description' : info
. find ( 'caption' ). text
,
317 'thumbnail' : find_xpath_attr ( info
, 'media' , 'type' , 'thumbnail' ). text
,
320 # "feature" and "nightly-news" pages use theplatform.com
321 video_id
= mobj
. group ( 'mpx_id' )
322 webpage
= self
._ download
_ webpage
( url
, video_id
)
324 filter_param
= 'byId'
325 bootstrap_json
= self
._ search
_ regex
(
326 [ r
'(?m)(?:var\s+(?:bootstrapJson|playlistData)|NEWS\.videoObj)\s*=\s*({.+});?\s*$' ,
327 r
'videoObj\s*:\s*({.+})' , r
'data-video="([^"]+)"' ,
328 r
'jQuery\.extend\(Drupal\.settings\s*,\s*({.+?})\);' ],
329 webpage
, 'bootstrap json' , default
= None )
331 bootstrap
= self
._ parse
_ json
(
332 bootstrap_json
, video_id
, transform_source
= unescapeHTML
)
335 if 'results' in bootstrap
:
336 info
= bootstrap
[ 'results' ][ 0 ][ 'video' ]
337 elif 'video' in bootstrap
:
338 info
= bootstrap
[ 'video' ]
339 elif 'msnbcVideoInfo' in bootstrap
:
340 info
= bootstrap
[ 'msnbcVideoInfo' ][ 'meta' ]
341 elif 'msnbcThePlatform' in bootstrap
:
342 info
= bootstrap
[ 'msnbcThePlatform' ][ 'videoPlayer' ][ 'video' ]
347 video_id
= info
[ 'guid' ]
348 filter_param
= 'byGuid'
349 elif 'mpxId' in info
:
350 video_id
= info
[ 'mpxId' ]
353 '_type' : 'url_transparent' ,
355 # http://feed.theplatform.com/f/2E2eJC/nbcnews also works
356 'url' : update_url_query ( 'http://feed.theplatform.com/f/2E2eJC/nnd_NBCNews' , { filter_param
: video_id
}),
357 'ie_key' : 'ThePlatformFeed' ,
361 class NBCOlympicsIE ( InfoExtractor
):
362 IE_NAME
= 'nbcolympics'
363 _VALID_URL
= r
'https?://www\.nbcolympics\.com/video/(?P<id>[a-z-]+)'
366 # Geo-restricted to US
367 'url' : 'http://www.nbcolympics.com/video/justin-roses-son-leo-was-tears-after-his-dad-won-gold' ,
368 'md5' : '54fecf846d05429fbaa18af557ee523a' ,
370 'id' : 'WjTBzDXx5AUq' ,
371 'display_id' : 'justin-roses-son-leo-was-tears-after-his-dad-won-gold' ,
373 'title' : 'Rose \' s son Leo was in tears after his dad won gold' ,
374 'description' : 'Olympic gold medalist Justin Rose gets emotional talking to the impact his win in men \' s golf has already had on his children.' ,
375 'timestamp' : 1471274964 ,
376 'upload_date' : '20160815' ,
377 'uploader' : 'NBCU-SPORTS' ,
381 def _real_extract ( self
, url
):
382 display_id
= self
._ match
_ id
( url
)
384 webpage
= self
._ download
_ webpage
( url
, display_id
)
386 drupal_settings
= self
._ parse
_ json
( self
._ search
_ regex
(
387 r
'jQuery\.extend\(Drupal\.settings\s*,\s*({.+?})\);' ,
388 webpage
, 'drupal settings' ), display_id
)
390 iframe_url
= drupal_settings
[ 'vod' ][ 'iframe_url' ]
391 theplatform_url
= iframe_url
. replace (
392 'vplayer.nbcolympics.com' , 'player.theplatform.com' )
395 '_type' : 'url_transparent' ,
396 'url' : theplatform_url
,
397 'ie_key' : ThePlatformIE
. ie_key (),
398 'display_id' : display_id
,
402 class NBCOlympicsStreamIE ( AdobePassIE
):
403 IE_NAME
= 'nbcolympics:stream'
404 _VALID_URL
= r
'https?://stream\.nbcolympics\.com/(?P<id>[0-9a-z-]+)'
406 'url' : 'http://stream.nbcolympics.com/2018-winter-olympics-nbcsn-evening-feb-8' ,
410 'title' : 're:Curling, Alpine, Luge [0-9] {4} -[0-9] {2} -[0-9] {2} [0-9] {2} :[0-9] {2} $' ,
414 'skip_download' : True ,
417 _DATA_URL_TEMPLATE
= 'http://stream.nbcolympics.com/data/ %s _ %s .json'
419 def _real_extract ( self
, url
):
420 display_id
= self
._ match
_ id
( url
)
421 webpage
= self
._ download
_ webpage
( url
, display_id
)
422 pid
= self
._ search
_ regex
( r
'pid\s*=\s*(\d+);' , webpage
, 'pid' )
423 resource
= self
._ search
_ regex
(
424 r
"resource\s*=\s*'(.+)';" , webpage
,
425 'resource' ). replace ( "' + pid + '" , pid
)
426 event_config
= self
._ download
_ json
(
427 self
._ DATA
_U RL
_ TEMPLATE
% ( 'event_config' , pid
),
429 title
= self
._l ive
_ title
( event_config
[ 'eventTitle' ])
430 source_url
= self
._ download
_ json
(
431 self
._ DATA
_U RL
_ TEMPLATE
% ( 'live_sources' , pid
),
432 pid
)[ 'videoSources' ][ 0 ][ 'sourceUrl' ]
433 media_token
= self
._ extract
_ mvpd
_ auth
(
434 url
, pid
, event_config
. get ( 'requestorId' , 'NBCOlympics' ), resource
)
435 formats
= self
._ extract
_ m
3u8_ formats
( self
._ download
_ webpage
(
436 'http://sp.auth.adobe.com/tvs/v1/sign' , pid
, query
={
438 'mediaToken' : base64
. b64encode ( media_token
. encode ()),
439 'resource' : base64
. b64encode ( resource
. encode ()),
442 self
._ sort
_ formats
( formats
)
446 'display_id' : display_id
,