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.

36 lines
1.2 KiB

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