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.

41 lines
1.5 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(
  23. r'data-feed-url="([^"]+)"', webpage, 'feed url')
  24. guid = self._search_regex(
  25. r'id="(?:videoPlayer|player-container)"[^>]+data-guid="([^"]+)"',
  26. webpage, 'guid')
  27. feed = self._download_xml('%s?byGuid=%s' % (feed_url, guid), name)
  28. content = feed.find('.//{http://search.yahoo.com/mrss/}content')
  29. theplatform_id = url_basename(content.attrib.get('url'))
  30. return self.url_result(smuggle_url(
  31. 'http://link.theplatform.com/s/ngs/%s?format=SMIL&formats=MPEG4&manifest=f4m' % theplatform_id,
  32. # For some reason, the normal links don't work and we must force the use of f4m
  33. {'force_smil_url': True}))