You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.2 KiB

  1. import re
  2. from .common import InfoExtractor
  3. from ..utils import find_xpath_attr, compat_str
  4. class NBCNewsIE(InfoExtractor):
  5. _VALID_URL = r'https?://www\.nbcnews\.com/video/.+?/(?P<id>\d+)'
  6. _TEST = {
  7. u'url': u'http://www.nbcnews.com/video/nbc-news/52753292',
  8. u'file': u'52753292.flv',
  9. u'md5': u'47abaac93c6eaf9ad37ee6c4463a5179',
  10. u'info_dict': {
  11. u'title': u'Crew emerges after four-month Mars food study',
  12. u'description': u'md5:24e632ffac72b35f8b67a12d1b6ddfc1',
  13. },
  14. }
  15. def _real_extract(self, url):
  16. mobj = re.match(self._VALID_URL, url)
  17. video_id = mobj.group('id')
  18. all_info = self._download_xml('http://www.nbcnews.com/id/%s/displaymode/1219' % video_id, video_id)
  19. info = all_info.find('video')
  20. return {'id': video_id,
  21. 'title': info.find('headline').text,
  22. 'ext': 'flv',
  23. 'url': find_xpath_attr(info, 'media', 'type', 'flashVideo').text,
  24. 'description': compat_str(info.find('caption').text),
  25. 'thumbnail': find_xpath_attr(info, 'media', 'type', 'thumbnail').text,
  26. }