]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/nbc.py
d2e4acbada5b99c5c3eac4fe6b966ce77dab1ef9
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': '54d0fbc33e0b853a65d7b4de5c06d64e',
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 mobj
= re
.match(self
._VALID
_URL
, url
)
30 video_id
= mobj
.group('id')
31 webpage
= self
._download
_webpage
(url
, video_id
)
32 theplatform_url
= self
._search
_regex
('class="video-player video-player-full" data-mpx-url="(.*?)"', webpage
, 'theplatform url')
33 if theplatform_url
.startswith('//'):
34 theplatform_url
= 'http:' + theplatform_url
35 return self
.url_result(theplatform_url
)
38 class NBCNewsIE(InfoExtractor
):
39 _VALID_URL
= r
'''(?x)https?://www\.nbcnews\.com/
40 ((video/.+?/(?P<id>\d+))|
41 (feature/[^/]+/(?P<title>.+)))
46 'url': 'http://www.nbcnews.com/video/nbc-news/52753292',
47 'md5': '47abaac93c6eaf9ad37ee6c4463a5179',
51 'title': 'Crew emerges after four-month Mars food study',
52 'description': 'md5:24e632ffac72b35f8b67a12d1b6ddfc1',
56 'url': 'http://www.nbcnews.com/feature/edward-snowden-interview/how-twitter-reacted-snowden-interview-n117236',
57 'md5': 'b2421750c9f260783721d898f4c42063',
61 'title': 'How Twitter Reacted To The Snowden Interview',
62 'description': 'md5:65a0bd5d76fe114f3c2727aa3a81fe64',
64 'add_ie': ['ThePlatform'],
68 def _real_extract(self
, url
):
69 mobj
= re
.match(self
._VALID
_URL
, url
)
70 video_id
= mobj
.group('id')
71 if video_id
is not None:
72 all_info
= self
._download
_xml
('http://www.nbcnews.com/id/%s/displaymode/1219' % video_id
, video_id
)
73 info
= all_info
.find('video')
77 'title': info
.find('headline').text
,
79 'url': find_xpath_attr(info
, 'media', 'type', 'flashVideo').text
,
80 'description': compat_str(info
.find('caption').text
),
81 'thumbnail': find_xpath_attr(info
, 'media', 'type', 'thumbnail').text
,
84 # "feature" pages use theplatform.com
85 title
= mobj
.group('title')
86 webpage
= self
._download
_webpage
(url
, title
)
87 bootstrap_json
= self
._search
_regex
(
88 r
'var bootstrapJson = ({.+})\s*$', webpage
, 'bootstrap json',
90 bootstrap
= json
.loads(bootstrap_json
)
91 info
= bootstrap
['results'][0]['video']
95 info
['fallbackPlaylistUrl'],
96 info
['associatedPlaylistUrl'],
99 for base_url
in base_urls
:
100 playlist_url
= base_url
+ '?form=MPXNBCNewsAPI'
101 all_videos
= self
._download
_json
(playlist_url
, title
)['videos']
104 info
= next(v
for v
in all_videos
if v
['mpxId'] == mpxid
)
106 except StopIteration:
110 raise ExtractorError('Could not find video in playlists')
114 # We get the best quality video
115 'url': info
['videoAssets'][-1]['publicUrl'],
116 'ie_key': 'ThePlatform',