]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/nbc.py
836a41f0694dd20b3024ecdd97376d340f322e02
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
'(?P<permalink>https?://(?:www\.)?nbc\.com/[^/]+/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' ,
73 def _real_extract ( self
, url
):
74 permalink
, video_id
= re
. match ( self
._ VALID
_U RL
, url
). groups ()
75 video_data
= self
._ download
_ json
(
76 'https://api.nbc.com/v3/videos' , video_id
, query
={
77 'filter[permalink]' : permalink
,
78 })[ 'data' ][ 0 ][ 'attributes' ]
83 video_id
= video_data
[ 'guid' ]
84 title
= video_data
[ 'title' ]
85 if video_data
. get ( 'entitlement' ) == 'auth' :
86 resource
= self
._ get
_ mvpd
_ resource
(
87 'nbcentertainment' , title
, video_id
,
88 video_data
. get ( 'vChipRating' ))
89 query
[ 'auth' ] = self
._ extract
_ mvpd
_ auth
(
90 url
, video_id
, 'nbcentertainment' , resource
)
91 theplatform_url
= smuggle_url ( update_url_query (
92 'http://link.theplatform.com/s/NnzsPC/media/guid/2410887629/' + video_id
,
93 query
), { 'force_smil_url' : True })
95 '_type' : 'url_transparent' ,
98 'url' : theplatform_url
,
99 'description' : video_data
. get ( 'description' ),
100 'keywords' : video_data
. get ( 'keywords' ),
101 'season_number' : int_or_none ( video_data
. get ( 'seasonNumber' )),
102 'episode_number' : int_or_none ( video_data
. get ( 'episodeNumber' )),
103 'series' : video_data
. get ( 'showName' ),
104 'ie_key' : 'ThePlatform' ,
108 class NBCSportsVPlayerIE ( InfoExtractor
):
109 _VALID_URL
= r
'https?://vplayer\.nbcsports\.com/(?:[^/]+/)+(?P<id>[0-9a-zA-Z_]+)'
112 'url' : 'https://vplayer.nbcsports.com/p/BxmELC/nbcsports_embed/select/9CsDKds0kvHI' ,
114 'id' : '9CsDKds0kvHI' ,
116 'description' : 'md5:df390f70a9ba7c95ff1daace988f0d8d' ,
117 'title' : 'Tyler Kalinoski hits buzzer-beater to lift Davidson' ,
118 'timestamp' : 1426270238 ,
119 'upload_date' : '20150313' ,
120 'uploader' : 'NBCU-SPORTS' ,
123 'url' : 'https://vplayer.nbcsports.com/p/BxmELC/nbcsports_embed/select/media/_hqLjQ95yx8Z' ,
124 'only_matching' : True ,
128 def _extract_url ( webpage
):
129 iframe_m
= re
. search (
130 r
'<iframe[^>]+src="(?P<url>https?://vplayer\.nbcsports\.com/[^"]+)"' , webpage
)
132 return iframe_m
. group ( 'url' )
134 def _real_extract ( self
, url
):
135 video_id
= self
._ match
_ id
( url
)
136 webpage
= self
._ download
_ webpage
( url
, video_id
)
137 theplatform_url
= self
._ og
_ search
_ video
_u rl
( webpage
). replace (
138 'vplayer.nbcsports.com' , 'player.theplatform.com' )
139 return self
. url_result ( theplatform_url
, 'ThePlatform' )
142 class NBCSportsIE ( InfoExtractor
):
143 # Does not include https because its certificate is invalid
144 _VALID_URL
= r
'https?://(?:www\.)?nbcsports\.com//?(?:[^/]+/)+(?P<id>[0-9a-z-]+)'
147 'url' : 'http://www.nbcsports.com//college-basketball/ncaab/tom-izzo-michigan-st-has-so-much-respect-duke' ,
149 'id' : 'PHJSaFWbrTY9' ,
151 'title' : 'Tom Izzo, Michigan St. has \' so much respect \' for Duke' ,
152 'description' : 'md5:ecb459c9d59e0766ac9c7d5d0eda8113' ,
153 'uploader' : 'NBCU-SPORTS' ,
154 'upload_date' : '20150330' ,
155 'timestamp' : 1427726529 ,
159 def _real_extract ( self
, url
):
160 video_id
= self
._ match
_ id
( url
)
161 webpage
= self
._ download
_ webpage
( url
, video_id
)
162 return self
. url_result (
163 NBCSportsVPlayerIE
._ extract
_u rl
( webpage
), 'NBCSportsVPlayer' )
166 class CSNNEIE ( InfoExtractor
):
167 _VALID_URL
= r
'https?://(?:www\.)?csnne\.com/video/(?P<id>[0-9a-z-]+)'
170 'url' : 'http://www.csnne.com/video/snc-evening-update-wright-named-red-sox-no-5-starter' ,
172 'id' : 'yvBLLUgQ8WU0' ,
174 'title' : 'SNC evening update: Wright named Red Sox \' No. 5 starter.' ,
175 'description' : 'md5:1753cfee40d9352b19b4c9b3e589b9e3' ,
176 'timestamp' : 1459369979 ,
177 'upload_date' : '20160330' ,
178 'uploader' : 'NBCU-SPORTS' ,
182 def _real_extract ( self
, url
):
183 display_id
= self
._ match
_ id
( url
)
184 webpage
= self
._ download
_ webpage
( url
, display_id
)
186 '_type' : 'url_transparent' ,
187 'ie_key' : 'ThePlatform' ,
188 'url' : self
._ html
_ search
_ meta
( 'twitter:player:stream' , webpage
),
189 'display_id' : display_id
,
193 class NBCNewsIE ( ThePlatformIE
):
194 _VALID_URL
= r
'''(?x)https?://(?:www\.)?(?:nbcnews|today|msnbc)\.com/
195 (?:video/.+?/(?P<id>\d+)|
196 ([^/]+/)*(?:.*-)?(?P<mpx_id>[^/?]+))
201 'url' : 'http://www.nbcnews.com/video/nbc-news/52753292' ,
202 'md5' : '47abaac93c6eaf9ad37ee6c4463a5179' ,
206 'title' : 'Crew emerges after four-month Mars food study' ,
207 'description' : 'md5:24e632ffac72b35f8b67a12d1b6ddfc1' ,
211 'url' : 'http://www.nbcnews.com/watch/nbcnews-com/how-twitter-reacted-to-the-snowden-interview-269389891880' ,
212 'md5' : 'af1adfa51312291a017720403826bb64' ,
214 'id' : 'p_tweet_snow_140529' ,
216 'title' : 'How Twitter Reacted To The Snowden Interview' ,
217 'description' : 'md5:65a0bd5d76fe114f3c2727aa3a81fe64' ,
218 'uploader' : 'NBCU-NEWS' ,
219 'timestamp' : 1401363060 ,
220 'upload_date' : '20140529' ,
224 'url' : 'http://www.nbcnews.com/feature/dateline-full-episodes/full-episode-family-business-n285156' ,
225 'md5' : 'fdbf39ab73a72df5896b6234ff98518a' ,
227 'id' : '529953347624' ,
229 'title' : 'FULL EPISODE: Family Business' ,
230 'description' : 'md5:757988edbaae9d7be1d585eb5d55cc04' ,
232 'skip' : 'This page is unavailable.' ,
235 'url' : 'http://www.nbcnews.com/nightly-news/video/nightly-news-with-brian-williams-full-broadcast-february-4-394064451844' ,
236 'md5' : '73135a2e0ef819107bbb55a5a9b2a802' ,
238 'id' : 'nn_netcast_150204' ,
240 'title' : 'Nightly News with Brian Williams Full Broadcast (February 4)' ,
241 'description' : 'md5:1c10c1eccbe84a26e5debb4381e2d3c5' ,
242 'timestamp' : 1423104900 ,
243 'uploader' : 'NBCU-NEWS' ,
244 'upload_date' : '20150205' ,
248 'url' : 'http://www.nbcnews.com/business/autos/volkswagen-11-million-vehicles-could-have-suspect-software-emissions-scandal-n431456' ,
249 'md5' : 'a49e173825e5fcd15c13fc297fced39d' ,
251 'id' : 'x_lon_vwhorn_150922' ,
253 'title' : 'Volkswagen U.S. Chief: \xa0 We Have Totally Screwed Up' ,
254 'description' : 'md5:c8be487b2d80ff0594c005add88d8351' ,
255 'upload_date' : '20150922' ,
256 'timestamp' : 1442917800 ,
257 'uploader' : 'NBCU-NEWS' ,
261 'url' : 'http://www.today.com/video/see-the-aurora-borealis-from-space-in-stunning-new-nasa-video-669831235788' ,
262 'md5' : '118d7ca3f0bea6534f119c68ef539f71' ,
264 'id' : 'tdy_al_space_160420' ,
266 'title' : 'See the aurora borealis from space in stunning new NASA video' ,
267 'description' : 'md5:74752b7358afb99939c5f8bb2d1d04b1' ,
268 'upload_date' : '20160420' ,
269 'timestamp' : 1461152093 ,
270 'uploader' : 'NBCU-NEWS' ,
274 'url' : 'http://www.msnbc.com/all-in-with-chris-hayes/watch/the-chaotic-gop-immigration-vote-314487875924' ,
275 'md5' : '6d236bf4f3dddc226633ce6e2c3f814d' ,
277 'id' : 'n_hayes_Aimm_140801_272214' ,
279 'title' : 'The chaotic GOP immigration vote' ,
280 '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.' ,
281 'thumbnail' : r
're:^https?://.*\.jpg$' ,
282 'timestamp' : 1406937606 ,
283 'upload_date' : '20140802' ,
284 'uploader' : 'NBCU-NEWS' ,
288 'url' : 'http://www.nbcnews.com/watch/dateline/full-episode--deadly-betrayal-386250819952' ,
289 'only_matching' : True ,
292 # From http://www.vulture.com/2016/06/letterman-couldnt-care-less-about-late-night.html
293 'url' : 'http://www.nbcnews.com/widget/video-embed/701714499682' ,
294 'only_matching' : True ,
298 def _real_extract ( self
, url
):
299 mobj
= re
. match ( self
._ VALID
_U RL
, url
)
300 video_id
= mobj
. group ( 'id' )
301 if video_id
is not None :
302 all_info
= self
._ download
_ xml
( 'http://www.nbcnews.com/id/ %s /displaymode/1219' % video_id
, video_id
)
303 info
= all_info
. find ( 'video' )
307 'title' : info
. find ( 'headline' ). text
,
309 'url' : find_xpath_attr ( info
, 'media' , 'type' , 'flashVideo' ). text
,
310 'description' : info
. find ( 'caption' ). text
,
311 'thumbnail' : find_xpath_attr ( info
, 'media' , 'type' , 'thumbnail' ). text
,
314 # "feature" and "nightly-news" pages use theplatform.com
315 video_id
= mobj
. group ( 'mpx_id' )
316 webpage
= self
._ download
_ webpage
( url
, video_id
)
318 filter_param
= 'byId'
319 bootstrap_json
= self
._ search
_ regex
(
320 [ r
'(?m)(?:var\s+(?:bootstrapJson|playlistData)|NEWS\.videoObj)\s*=\s*({.+});?\s*$' ,
321 r
'videoObj\s*:\s*({.+})' , r
'data-video="([^"]+)"' ,
322 r
'jQuery\.extend\(Drupal\.settings\s*,\s*({.+?})\);' ],
323 webpage
, 'bootstrap json' , default
= None )
325 bootstrap
= self
._ parse
_ json
(
326 bootstrap_json
, video_id
, transform_source
= unescapeHTML
)
329 if 'results' in bootstrap
:
330 info
= bootstrap
[ 'results' ][ 0 ][ 'video' ]
331 elif 'video' in bootstrap
:
332 info
= bootstrap
[ 'video' ]
333 elif 'msnbcVideoInfo' in bootstrap
:
334 info
= bootstrap
[ 'msnbcVideoInfo' ][ 'meta' ]
335 elif 'msnbcThePlatform' in bootstrap
:
336 info
= bootstrap
[ 'msnbcThePlatform' ][ 'videoPlayer' ][ 'video' ]
341 video_id
= info
[ 'guid' ]
342 filter_param
= 'byGuid'
343 elif 'mpxId' in info
:
344 video_id
= info
[ 'mpxId' ]
347 '_type' : 'url_transparent' ,
349 # http://feed.theplatform.com/f/2E2eJC/nbcnews also works
350 'url' : update_url_query ( 'http://feed.theplatform.com/f/2E2eJC/nnd_NBCNews' , { filter_param
: video_id
}),
351 'ie_key' : 'ThePlatformFeed' ,
355 class NBCOlympicsIE ( InfoExtractor
):
356 _VALID_URL
= r
'https?://www\.nbcolympics\.com/video/(?P<id>[a-z-]+)'
359 # Geo-restricted to US
360 'url' : 'http://www.nbcolympics.com/video/justin-roses-son-leo-was-tears-after-his-dad-won-gold' ,
361 'md5' : '54fecf846d05429fbaa18af557ee523a' ,
363 'id' : 'WjTBzDXx5AUq' ,
364 'display_id' : 'justin-roses-son-leo-was-tears-after-his-dad-won-gold' ,
366 'title' : 'Rose \' s son Leo was in tears after his dad won gold' ,
367 'description' : 'Olympic gold medalist Justin Rose gets emotional talking to the impact his win in men \' s golf has already had on his children.' ,
368 'timestamp' : 1471274964 ,
369 'upload_date' : '20160815' ,
370 'uploader' : 'NBCU-SPORTS' ,
374 def _real_extract ( self
, url
):
375 display_id
= self
._ match
_ id
( url
)
377 webpage
= self
._ download
_ webpage
( url
, display_id
)
379 drupal_settings
= self
._ parse
_ json
( self
._ search
_ regex
(
380 r
'jQuery\.extend\(Drupal\.settings\s*,\s*({.+?})\);' ,
381 webpage
, 'drupal settings' ), display_id
)
383 iframe_url
= drupal_settings
[ 'vod' ][ 'iframe_url' ]
384 theplatform_url
= iframe_url
. replace (
385 'vplayer.nbcolympics.com' , 'player.theplatform.com' )
388 '_type' : 'url_transparent' ,
389 'url' : theplatform_url
,
390 'ie_key' : ThePlatformIE
. ie_key (),
391 'display_id' : display_id
,