]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/nbc.py
1 from __future__
import unicode_literals
5 from . common
import InfoExtractor
18 class NBCIE ( InfoExtractor
):
19 _VALID_URL
= r
'https?://www\.nbc\.com/(?:[^/]+/)+(?P<id>n?\d+)'
23 'url' : 'http://www.nbc.com/the-tonight-show/segments/112966' ,
24 # md5 checksum is not stable
28 'title' : 'Jimmy Fallon Surprises Fans at Ben & Jerry \' s' ,
29 'description' : 'Jimmy gives out free scoops of his new "Tonight Dough" ice cream flavor by surprising customers at the Ben & Jerry \' s scoop shop.' ,
33 'url' : 'http://www.nbc.com/the-tonight-show/episodes/176' ,
37 'title' : 'Ricky Gervais, Steven Van Zandt, ILoveMakonnen' ,
38 'description' : 'A brand new episode of The Tonight Show welcomes Ricky Gervais, Steven Van Zandt and ILoveMakonnen.' ,
40 'skip' : 'Only works from US' ,
43 'url' : 'http://www.nbc.com/saturday-night-live/video/star-wars-teaser/2832821' ,
47 'title' : 'Star Wars Teaser' ,
48 'description' : 'md5:0b40f9cbde5b671a7ff62fceccc4f442' ,
50 'skip' : 'Only works from US' ,
53 # This video has expired but with an escaped embedURL
54 'url' : 'http://www.nbc.com/parenthood/episode-guide/season-5/just-like-at-home/515' ,
59 def _real_extract ( self
, url
):
60 video_id
= self
._ match
_ id
( url
)
61 webpage
= self
._ download
_ webpage
( url
, video_id
)
62 theplatform_url
= unescapeHTML ( lowercase_escape ( self
._ html
_ search
_ regex
(
64 r
'(?:class="video-player video-player-full" data-mpx-url|class="player" src)="(.*?)"' ,
65 r
'"embedURL"\s*:\s*"([^"]+)"'
67 webpage
, 'theplatform url' ). replace ( '_no_endcard' , '' ). replace ( ' \\ /' , '/' )))
68 if theplatform_url
. startswith ( '//' ):
69 theplatform_url
= 'http:' + theplatform_url
70 return self
. url_result ( theplatform_url
)
73 class NBCSportsVPlayerIE ( InfoExtractor
):
74 _VALID_URL
= r
'https?://vplayer\.nbcsports\.com/(?:[^/]+/)+(?P<id>[0-9a-zA-Z_]+)'
77 'url' : 'https://vplayer.nbcsports.com/p/BxmELC/nbcsports_share/select/9CsDKds0kvHI' ,
81 'description' : 'md5:df390f70a9ba7c95ff1daace988f0d8d' ,
82 'title' : 'Tyler Kalinoski hits buzzer-beater to lift Davidson' ,
85 'url' : 'http://vplayer.nbcsports.com/p/BxmELC/nbc_embedshare/select/_hqLjQ95yx8Z' ,
86 'only_matching' : True ,
90 def _extract_url ( webpage
):
92 r
'<iframe[^>]+src="(?P<url>https?://vplayer\.nbcsports\.com/[^"]+)"' , webpage
)
94 return iframe_m
. group ( 'url' )
96 def _real_extract ( self
, url
):
97 video_id
= self
._ match
_ id
( url
)
98 webpage
= self
._ download
_ webpage
( url
, video_id
)
99 theplatform_url
= self
._ og
_ search
_ video
_u rl
( webpage
)
100 return self
. url_result ( theplatform_url
, 'ThePlatform' )
103 class NBCSportsIE ( InfoExtractor
):
104 # Does not include https becuase its certificate is invalid
105 _VALID_URL
= r
'http://www\.nbcsports\.com//?(?:[^/]+/)+(?P<id>[0-9a-z-]+)'
108 'url' : 'http://www.nbcsports.com//college-basketball/ncaab/tom-izzo-michigan-st-has-so-much-respect-duke' ,
110 'id' : 'PHJSaFWbrTY9' ,
112 'title' : 'Tom Izzo, Michigan St. has \' so much respect \' for Duke' ,
113 'description' : 'md5:ecb459c9d59e0766ac9c7d5d0eda8113' ,
117 def _real_extract ( self
, url
):
118 video_id
= self
._ match
_ id
( url
)
119 webpage
= self
._ download
_ webpage
( url
, video_id
)
120 return self
. url_result (
121 NBCSportsVPlayerIE
._ extract
_u rl
( webpage
), 'NBCSportsVPlayer' )
124 class NBCNewsIE ( InfoExtractor
):
125 _VALID_URL
= r
'''(?x)https?://(?:www\.)?nbcnews\.com/
126 (?:video/.+?/(?P<id>\d+)|
127 (?:watch|feature|nightly-news)/[^/]+/(?P<title>.+))
132 'url' : 'http://www.nbcnews.com/video/nbc-news/52753292' ,
133 'md5' : '47abaac93c6eaf9ad37ee6c4463a5179' ,
137 'title' : 'Crew emerges after four-month Mars food study' ,
138 'description' : 'md5:24e632ffac72b35f8b67a12d1b6ddfc1' ,
142 'url' : 'http://www.nbcnews.com/feature/edward-snowden-interview/how-twitter-reacted-snowden-interview-n117236' ,
143 'md5' : 'b2421750c9f260783721d898f4c42063' ,
145 'id' : 'I1wpAI_zmhsQ' ,
147 'title' : 'How Twitter Reacted To The Snowden Interview' ,
148 'description' : 'md5:65a0bd5d76fe114f3c2727aa3a81fe64' ,
150 'add_ie' : [ 'ThePlatform' ],
153 'url' : 'http://www.nbcnews.com/feature/dateline-full-episodes/full-episode-family-business-n285156' ,
154 'md5' : 'fdbf39ab73a72df5896b6234ff98518a' ,
156 'id' : 'Wjf9EDR3A_60' ,
158 'title' : 'FULL EPISODE: Family Business' ,
159 'description' : 'md5:757988edbaae9d7be1d585eb5d55cc04' ,
163 'url' : 'http://www.nbcnews.com/nightly-news/video/nightly-news-with-brian-williams-full-broadcast-february-4-394064451844' ,
164 'md5' : 'b5dda8cddd8650baa0dcb616dd2cf60d' ,
166 'id' : 'sekXqyTVnmN3' ,
168 'title' : 'Nightly News with Brian Williams Full Broadcast (February 4)' ,
169 'description' : 'md5:1c10c1eccbe84a26e5debb4381e2d3c5' ,
173 'url' : 'http://www.nbcnews.com/watch/dateline/full-episode--deadly-betrayal-386250819952' ,
174 'only_matching' : True ,
178 def _real_extract ( self
, url
):
179 mobj
= re
. match ( self
._ VALID
_U RL
, url
)
180 video_id
= mobj
. group ( 'id' )
181 if video_id
is not None :
182 all_info
= self
._ download
_ xml
( 'http://www.nbcnews.com/id/ %s /displaymode/1219' % video_id
, video_id
)
183 info
= all_info
. find ( 'video' )
187 'title' : info
. find ( 'headline' ). text
,
189 'url' : find_xpath_attr ( info
, 'media' , 'type' , 'flashVideo' ). text
,
190 'description' : compat_str ( info
. find ( 'caption' ). text
),
191 'thumbnail' : find_xpath_attr ( info
, 'media' , 'type' , 'thumbnail' ). text
,
194 # "feature" and "nightly-news" pages use theplatform.com
195 title
= mobj
. group ( 'title' )
196 webpage
= self
._ download
_ webpage
( url
, title
)
197 bootstrap_json
= self
._ search
_ regex
(
198 r
'var\s+(?:bootstrapJson|playlistData)\s*=\s*({.+});?\s*$' ,
199 webpage
, 'bootstrap json' , flags
= re
. MULTILINE
)
200 bootstrap
= self
._ parse
_ json
( bootstrap_json
, video_id
)
201 info
= bootstrap
[ 'results' ][ 0 ][ 'video' ]
202 mpxid
= info
[ 'mpxId' ]
205 info
[ 'fallbackPlaylistUrl' ],
206 info
[ 'associatedPlaylistUrl' ],
209 for base_url
in base_urls
:
212 playlist_url
= base_url
+ '?form=MPXNBCNewsAPI'
215 all_videos
= self
._ download
_ json
( playlist_url
, title
)
216 except ExtractorError
as ee
:
217 if isinstance ( ee
. cause
, compat_HTTPError
):
221 if not all_videos
or 'videos' not in all_videos
:
225 info
= next ( v
for v
in all_videos
[ 'videos' ] if v
[ 'mpxId' ] == mpxid
)
227 except StopIteration :
231 raise ExtractorError ( 'Could not find video in playlists' )
235 # We get the best quality video
236 'url' : info
[ 'videoAssets' ][- 1 ][ 'publicUrl' ],
237 'ie_key' : 'ThePlatform' ,
241 class MSNBCIE ( InfoExtractor
):
242 # https URLs redirect to corresponding http ones
243 _VALID_URL
= r
'http://www\.msnbc\.com/[^/]+/watch/(?P<id>[^/]+)'
245 'url' : 'http://www.msnbc.com/all-in-with-chris-hayes/watch/the-chaotic-gop-immigration-vote-314487875924' ,
246 'md5' : '6d236bf4f3dddc226633ce6e2c3f814d' ,
248 'id' : 'n_hayes_Aimm_140801_272214' ,
250 'title' : 'The chaotic GOP immigration vote' ,
251 '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.' ,
252 'thumbnail' : 're:^https?://.*\.jpg$' ,
253 'timestamp' : 1406937606 ,
254 'upload_date' : '20140802' ,
255 'categories' : [ 'MSNBC/Topics/Franchise/Best of last night' , 'MSNBC/Topics/General/Congress' ],
259 def _real_extract ( self
, url
):
260 video_id
= self
._ match
_ id
( url
)
261 webpage
= self
._ download
_ webpage
( url
, video_id
)
262 embed_url
= self
._ html
_ search
_ meta
( 'embedURL' , webpage
)
263 return self
. url_result ( embed_url
)