]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/nbc.py
7b5449031ebd2b7245d452c04ae50dfaf970d6ca
1 from __future__
import unicode_literals
6 from .common
import InfoExtractor
14 class NBCIE(InfoExtractor
):
15 _VALID_URL
= r
'http://www\.nbc\.com/[^/]+/video/[^/]+/(?P<id>n?\d+)'
18 'url': 'http://www.nbc.com/chicago-fire/video/i-am-a-firefighter/2734188',
19 # md5 checksum is not stable
23 'title': 'I Am a Firefighter',
24 'description': 'An emergency puts Dawson\'sf irefighter skills to the ultimate test in this four-part digital series.',
28 def _real_extract(self
, url
):
29 video_id
= self
._match
_id
(url
)
30 webpage
= self
._download
_webpage
(url
, video_id
)
31 theplatform_url
= self
._search
_regex
('class="video-player video-player-full" data-mpx-url="(.*?)"', webpage
, 'theplatform url')
32 if theplatform_url
.startswith('//'):
33 theplatform_url
= 'http:' + theplatform_url
34 return self
.url_result(theplatform_url
)
37 class NBCNewsIE(InfoExtractor
):
38 _VALID_URL
= r
'''(?x)https?://www\.nbcnews\.com/
39 ((video/.+?/(?P<id>\d+))|
40 (feature/[^/]+/(?P<title>.+)))
45 'url': 'http://www.nbcnews.com/video/nbc-news/52753292',
46 'md5': '47abaac93c6eaf9ad37ee6c4463a5179',
50 'title': 'Crew emerges after four-month Mars food study',
51 'description': 'md5:24e632ffac72b35f8b67a12d1b6ddfc1',
55 'url': 'http://www.nbcnews.com/feature/edward-snowden-interview/how-twitter-reacted-snowden-interview-n117236',
56 'md5': 'b2421750c9f260783721d898f4c42063',
60 'title': 'How Twitter Reacted To The Snowden Interview',
61 'description': 'md5:65a0bd5d76fe114f3c2727aa3a81fe64',
63 'add_ie': ['ThePlatform'],
67 def _real_extract(self
, url
):
68 mobj
= re
.match(self
._VALID
_URL
, url
)
69 video_id
= mobj
.group('id')
70 if video_id
is not None:
71 all_info
= self
._download
_xml
('http://www.nbcnews.com/id/%s/displaymode/1219' % video_id
, video_id
)
72 info
= all_info
.find('video')
76 'title': info
.find('headline').text
,
78 'url': find_xpath_attr(info
, 'media', 'type', 'flashVideo').text
,
79 'description': compat_str(info
.find('caption').text
),
80 'thumbnail': find_xpath_attr(info
, 'media', 'type', 'thumbnail').text
,
83 # "feature" pages use theplatform.com
84 title
= mobj
.group('title')
85 webpage
= self
._download
_webpage
(url
, title
)
86 bootstrap_json
= self
._search
_regex
(
87 r
'var bootstrapJson = ({.+})\s*$', webpage
, 'bootstrap json',
89 bootstrap
= json
.loads(bootstrap_json
)
90 info
= bootstrap
['results'][0]['video']
94 info
['fallbackPlaylistUrl'],
95 info
['associatedPlaylistUrl'],
98 for base_url
in base_urls
:
101 playlist_url
= base_url
+ '?form=MPXNBCNewsAPI'
102 all_videos
= self
._download
_json
(playlist_url
, title
)['videos']
105 info
= next(v
for v
in all_videos
if v
['mpxId'] == mpxid
)
107 except StopIteration:
111 raise ExtractorError('Could not find video in playlists')
115 # We get the best quality video
116 'url': info
['videoAssets'][-1]['publicUrl'],
117 'ie_key': 'ThePlatform',