]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/nbc.py
debian/NEWS: Write news about new behavior of youtube-dl.
[youtubedl] / youtube_dl / extractor / nbc.py
1 import re
2
3 from .common import InfoExtractor
4 from ..utils import find_xpath_attr, compat_str
5
6
7 class NBCNewsIE(InfoExtractor):
8 _VALID_URL = r'https?://www\.nbcnews\.com/video/.+?/(?P<id>\d+)'
9
10 _TEST = {
11 u'url': u'http://www.nbcnews.com/video/nbc-news/52753292',
12 u'file': u'52753292.flv',
13 u'md5': u'47abaac93c6eaf9ad37ee6c4463a5179',
14 u'info_dict': {
15 u'title': u'Crew emerges after four-month Mars food study',
16 u'description': u'md5:24e632ffac72b35f8b67a12d1b6ddfc1',
17 },
18 }
19
20 def _real_extract(self, url):
21 mobj = re.match(self._VALID_URL, url)
22 video_id = mobj.group('id')
23 all_info = self._download_xml('http://www.nbcnews.com/id/%s/displaymode/1219' % video_id, video_id)
24 info = all_info.find('video')
25
26 return {'id': video_id,
27 'title': info.find('headline').text,
28 'ext': 'flv',
29 'url': find_xpath_attr(info, 'media', 'type', 'flashVideo').text,
30 'description': compat_str(info.find('caption').text),
31 'thumbnail': find_xpath_attr(info, 'media', 'type', 'thumbnail').text,
32 }