nationalgeographic.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. IE_NAME = 'natgeo'
  9. _VALID_URL = r'https?://video\.nationalgeographic\.com/.*?'
  10. _TESTS = [
  11. {
  12. 'url': 'http://video.nationalgeographic.com/video/news/150210-news-crab-mating-vin?source=featuredvideo',
  13. 'md5': '730855d559abbad6b42c2be1fa584917',
  14. 'info_dict': {
  15. 'id': '0000014b-70a1-dd8c-af7f-f7b559330001',
  16. 'ext': 'mp4',
  17. 'title': 'Mating Crabs Busted by Sharks',
  18. 'description': 'md5:16f25aeffdeba55aaa8ec37e093ad8b3',
  19. },
  20. 'add_ie': ['ThePlatform'],
  21. },
  22. {
  23. 'url': 'http://video.nationalgeographic.com/wild/when-sharks-attack/the-real-jaws',
  24. 'md5': '6a3105eb448c070503b3105fb9b320b5',
  25. 'info_dict': {
  26. 'id': 'ngc-I0IauNSWznb_UV008GxSbwY35BZvgi2e',
  27. 'ext': 'mp4',
  28. 'title': 'The Real Jaws',
  29. 'description': 'md5:8d3e09d9d53a85cd397b4b21b2c77be6',
  30. },
  31. 'add_ie': ['ThePlatform'],
  32. },
  33. ]
  34. def _real_extract(self, url):
  35. name = url_basename(url)
  36. webpage = self._download_webpage(url, name)
  37. guid = self._search_regex(
  38. r'id="(?:videoPlayer|player-container)"[^>]+data-guid="([^"]+)"',
  39. webpage, 'guid')
  40. return {
  41. '_type': 'url_transparent',
  42. 'ie_key': 'ThePlatform',
  43. 'url': smuggle_url(
  44. 'http://link.theplatform.com/s/ngs/media/guid/2423130747/%s?mbr=true' % guid,
  45. {'force_smil_url': True}),
  46. 'id': guid,
  47. }