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.

101 lines
3.5 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. },
  21. 'add_ie': ['ThePlatform'],
  22. },
  23. {
  24. 'url': 'http://video.nationalgeographic.com/wild/when-sharks-attack/the-real-jaws',
  25. 'md5': '6a3105eb448c070503b3105fb9b320b5',
  26. 'info_dict': {
  27. 'id': 'ngc-I0IauNSWznb_UV008GxSbwY35BZvgi2e',
  28. 'ext': 'mp4',
  29. 'title': 'The Real Jaws',
  30. 'description': 'md5:8d3e09d9d53a85cd397b4b21b2c77be6',
  31. },
  32. 'add_ie': ['ThePlatform'],
  33. },
  34. ]
  35. def _real_extract(self, url):
  36. name = url_basename(url)
  37. webpage = self._download_webpage(url, name)
  38. guid = self._search_regex(
  39. r'id="(?:videoPlayer|player-container)"[^>]+data-guid="([^"]+)"',
  40. webpage, 'guid')
  41. return {
  42. '_type': 'url_transparent',
  43. 'ie_key': 'ThePlatform',
  44. 'url': smuggle_url(
  45. 'http://link.theplatform.com/s/ngs/media/guid/2423130747/%s?mbr=true' % guid,
  46. {'force_smil_url': True}),
  47. 'id': guid,
  48. }
  49. class NationalGeographicChannelIE(InfoExtractor):
  50. IE_NAME = 'natgeo:channel'
  51. _VALID_URL = r'https?://channel\.nationalgeographic\.com/(?:wild/)?[^/]+/videos/(?P<id>[^/?]+)'
  52. _TESTS = [
  53. {
  54. 'url': 'http://channel.nationalgeographic.com/the-story-of-god-with-morgan-freeman/videos/uncovering-a-universal-knowledge/',
  55. 'md5': '518c9aa655686cf81493af5cc21e2a04',
  56. 'info_dict': {
  57. 'id': 'nB5vIAfmyllm',
  58. 'ext': 'mp4',
  59. 'title': 'Uncovering a Universal Knowledge',
  60. 'description': 'md5:1a89148475bf931b3661fcd6ddb2ae3a',
  61. },
  62. 'add_ie': ['ThePlatform'],
  63. },
  64. {
  65. 'url': 'http://channel.nationalgeographic.com/wild/destination-wild/videos/the-stunning-red-bird-of-paradise/',
  66. 'md5': 'c4912f656b4cbe58f3e000c489360989',
  67. 'info_dict': {
  68. 'id': '3TmMv9OvGwIR',
  69. 'ext': 'mp4',
  70. 'title': 'The Stunning Red Bird of Paradise',
  71. 'description': 'md5:7bc8cd1da29686be4d17ad1230f0140c',
  72. },
  73. 'add_ie': ['ThePlatform'],
  74. },
  75. ]
  76. def _real_extract(self, url):
  77. display_id = self._match_id(url)
  78. webpage = self._download_webpage(url, display_id)
  79. release_url = self._search_regex(
  80. r'video_auth_playlist_url\s*=\s*"([^"]+)"',
  81. webpage, 'release url')
  82. return {
  83. '_type': 'url_transparent',
  84. 'ie_key': 'ThePlatform',
  85. 'url': smuggle_url(
  86. update_url_query(release_url, {'mbr': 'true', 'switch': 'http'}),
  87. {'force_smil_url': True}),
  88. 'display_id': display_id,
  89. }