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