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.

60 lines
2.2 KiB

11 years ago
11 years ago
11 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 NBCIE(InfoExtractor):
  6. _VALID_URL = r'http://www\.nbc\.com/[^/]+/video/[^/]+/(?P<id>n?\d+)'
  7. _TEST = {
  8. 'url': 'http://www.nbc.com/chicago-fire/video/i-am-a-firefighter/2734188',
  9. 'md5': '54d0fbc33e0b853a65d7b4de5c06d64e',
  10. 'info_dict': {
  11. 'id': 'u1RInQZRN7QJ',
  12. 'ext': 'flv',
  13. 'title': 'I Am a Firefighter',
  14. 'description': 'An emergency puts Dawson\'sf irefighter skills to the ultimate test in this four-part digital series.',
  15. },
  16. }
  17. def _real_extract(self, url):
  18. mobj = re.match(self._VALID_URL, url)
  19. video_id = mobj.group('id')
  20. webpage = self._download_webpage(url, video_id)
  21. theplatform_url = self._search_regex('class="video-player video-player-full" data-mpx-url="(.*?)"', webpage, 'theplatform url')
  22. if theplatform_url.startswith('//'):
  23. theplatform_url = 'http:' + theplatform_url
  24. return self.url_result(theplatform_url)
  25. class NBCNewsIE(InfoExtractor):
  26. _VALID_URL = r'https?://www\.nbcnews\.com/video/.+?/(?P<id>\d+)'
  27. _TEST = {
  28. 'url': 'http://www.nbcnews.com/video/nbc-news/52753292',
  29. 'md5': '47abaac93c6eaf9ad37ee6c4463a5179',
  30. 'info_dict': {
  31. 'id': '52753292',
  32. 'ext': 'flv',
  33. 'title': 'Crew emerges after four-month Mars food study',
  34. 'description': 'md5:24e632ffac72b35f8b67a12d1b6ddfc1',
  35. },
  36. }
  37. def _real_extract(self, url):
  38. mobj = re.match(self._VALID_URL, url)
  39. video_id = mobj.group('id')
  40. all_info = self._download_xml('http://www.nbcnews.com/id/%s/displaymode/1219' % video_id, video_id)
  41. info = all_info.find('video')
  42. return {
  43. 'id': video_id,
  44. 'title': info.find('headline').text,
  45. 'ext': 'flv',
  46. 'url': find_xpath_attr(info, 'media', 'type', 'flashVideo').text,
  47. 'description': compat_str(info.find('caption').text),
  48. 'thumbnail': find_xpath_attr(info, 'media', 'type', 'thumbnail').text,
  49. }