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.

113 lines
4.0 KiB

  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..utils import (
  4. smuggle_url,
  5. url_basename,
  6. update_url_query,
  7. )
  8. class NationalGeographicIE(InfoExtractor):
  9. IE_NAME = 'natgeo'
  10. _VALID_URL = r'https?://video\.nationalgeographic\.com/.*?'
  11. _TESTS = [
  12. {
  13. 'url': 'http://video.nationalgeographic.com/video/news/150210-news-crab-mating-vin?source=featuredvideo',
  14. 'md5': '730855d559abbad6b42c2be1fa584917',
  15. 'info_dict': {
  16. 'id': '0000014b-70a1-dd8c-af7f-f7b559330001',
  17. 'ext': 'mp4',
  18. 'title': 'Mating Crabs Busted by Sharks',
  19. 'description': 'md5:16f25aeffdeba55aaa8ec37e093ad8b3',
  20. 'timestamp': 1423523799,
  21. 'upload_date': '20150209',
  22. 'uploader': 'NAGS',
  23. },
  24. 'add_ie': ['ThePlatform'],
  25. },
  26. {
  27. 'url': 'http://video.nationalgeographic.com/wild/when-sharks-attack/the-real-jaws',
  28. 'md5': '6a3105eb448c070503b3105fb9b320b5',
  29. 'info_dict': {
  30. 'id': 'ngc-I0IauNSWznb_UV008GxSbwY35BZvgi2e',
  31. 'ext': 'mp4',
  32. 'title': 'The Real Jaws',
  33. 'description': 'md5:8d3e09d9d53a85cd397b4b21b2c77be6',
  34. 'timestamp': 1433772632,
  35. 'upload_date': '20150608',
  36. 'uploader': 'NAGS',
  37. },
  38. 'add_ie': ['ThePlatform'],
  39. },
  40. ]
  41. def _real_extract(self, url):
  42. name = url_basename(url)
  43. webpage = self._download_webpage(url, name)
  44. guid = self._search_regex(
  45. r'id="(?:videoPlayer|player-container)"[^>]+data-guid="([^"]+)"',
  46. webpage, 'guid')
  47. return {
  48. '_type': 'url_transparent',
  49. 'ie_key': 'ThePlatform',
  50. 'url': smuggle_url(
  51. 'http://link.theplatform.com/s/ngs/media/guid/2423130747/%s?mbr=true' % guid,
  52. {'force_smil_url': True}),
  53. 'id': guid,
  54. }
  55. class NationalGeographicChannelIE(InfoExtractor):
  56. IE_NAME = 'natgeo:channel'
  57. _VALID_URL = r'https?://channel\.nationalgeographic\.com/(?:wild/)?[^/]+/videos/(?P<id>[^/?]+)'
  58. _TESTS = [
  59. {
  60. 'url': 'http://channel.nationalgeographic.com/the-story-of-god-with-morgan-freeman/videos/uncovering-a-universal-knowledge/',
  61. 'md5': '518c9aa655686cf81493af5cc21e2a04',
  62. 'info_dict': {
  63. 'id': 'nB5vIAfmyllm',
  64. 'ext': 'mp4',
  65. 'title': 'Uncovering a Universal Knowledge',
  66. 'description': 'md5:1a89148475bf931b3661fcd6ddb2ae3a',
  67. 'timestamp': 1458680907,
  68. 'upload_date': '20160322',
  69. 'uploader': 'NEWA-FNG-NGTV',
  70. },
  71. 'add_ie': ['ThePlatform'],
  72. },
  73. {
  74. 'url': 'http://channel.nationalgeographic.com/wild/destination-wild/videos/the-stunning-red-bird-of-paradise/',
  75. 'md5': 'c4912f656b4cbe58f3e000c489360989',
  76. 'info_dict': {
  77. 'id': '3TmMv9OvGwIR',
  78. 'ext': 'mp4',
  79. 'title': 'The Stunning Red Bird of Paradise',
  80. 'description': 'md5:7bc8cd1da29686be4d17ad1230f0140c',
  81. 'timestamp': 1459362152,
  82. 'upload_date': '20160330',
  83. 'uploader': 'NEWA-FNG-NGTV',
  84. },
  85. 'add_ie': ['ThePlatform'],
  86. },
  87. ]
  88. def _real_extract(self, url):
  89. display_id = self._match_id(url)
  90. webpage = self._download_webpage(url, display_id)
  91. release_url = self._search_regex(
  92. r'video_auth_playlist_url\s*=\s*"([^"]+)"',
  93. webpage, 'release url')
  94. return {
  95. '_type': 'url_transparent',
  96. 'ie_key': 'ThePlatform',
  97. 'url': smuggle_url(
  98. update_url_query(release_url, {'mbr': 'true', 'switch': 'http'}),
  99. {'force_smil_url': True}),
  100. 'display_id': display_id,
  101. }