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.

38 lines
1.4 KiB

  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..utils import (
  4. smuggle_url,
  5. url_basename,
  6. )
  7. class NationalGeographicIE(InfoExtractor):
  8. _VALID_URL = r'http://video\.nationalgeographic\.com/video/.*?'
  9. _TEST = {
  10. 'url': 'http://video.nationalgeographic.com/video/news/150210-news-crab-mating-vin?source=featuredvideo',
  11. 'info_dict': {
  12. 'id': '4DmDACA6Qtk_',
  13. 'ext': 'flv',
  14. 'title': 'Mating Crabs Busted by Sharks',
  15. 'description': 'md5:16f25aeffdeba55aaa8ec37e093ad8b3',
  16. },
  17. 'add_ie': ['ThePlatform'],
  18. }
  19. def _real_extract(self, url):
  20. name = url_basename(url)
  21. webpage = self._download_webpage(url, name)
  22. feed_url = self._search_regex(r'data-feed-url="([^"]+)"', webpage, 'feed url')
  23. guid = self._search_regex(r'data-video-guid="([^"]+)"', webpage, 'guid')
  24. feed = self._download_xml('%s?byGuid=%s' % (feed_url, guid), name)
  25. content = feed.find('.//{http://search.yahoo.com/mrss/}content')
  26. theplatform_id = url_basename(content.attrib.get('url'))
  27. return self.url_result(smuggle_url(
  28. 'http://link.theplatform.com/s/ngs/%s?format=SMIL&formats=MPEG4&manifest=f4m' % theplatform_id,
  29. # For some reason, the normal links don't work and we must force the use of f4m
  30. {'force_smil_url': True}))