nationalgeographic.py 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. from .common import InfoExtractor
  2. from .fox import FOXIE
  3. from ..utils import (
  4. smuggle_url,
  5. url_basename,
  6. )
  7. class NationalGeographicVideoIE(InfoExtractor):
  8. IE_NAME = 'natgeo:video'
  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. 'timestamp': 1423523799,
  20. 'upload_date': '20150209',
  21. 'uploader': 'NAGS',
  22. },
  23. 'add_ie': ['ThePlatform'],
  24. 'skip': 'Redirects to main page',
  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. 'skip': 'Redirects to main page',
  40. },
  41. ]
  42. def _real_extract(self, url):
  43. name = url_basename(url)
  44. webpage = self._download_webpage(url, name)
  45. guid = self._search_regex(
  46. r'id="(?:videoPlayer|player-container)"[^>]+data-guid="([^"]+)"',
  47. webpage, 'guid')
  48. return {
  49. '_type': 'url_transparent',
  50. 'ie_key': 'ThePlatform',
  51. 'url': smuggle_url(
  52. f'http://link.theplatform.com/s/ngs/media/guid/2423130747/{guid}?mbr=true',
  53. {'force_smil_url': True}),
  54. 'id': guid,
  55. }
  56. class NationalGeographicTVIE(FOXIE): # XXX: Do not subclass from concrete IE
  57. _VALID_URL = r'https?://(?:www\.)?nationalgeographic\.com/tv/watch/(?P<id>[\da-fA-F]+)'
  58. _TESTS = [{
  59. 'url': 'https://www.nationalgeographic.com/tv/watch/6a875e6e734b479beda26438c9f21138/',
  60. 'info_dict': {
  61. 'id': '6a875e6e734b479beda26438c9f21138',
  62. 'ext': 'mp4',
  63. 'title': 'Why Nat Geo? Valley of the Boom',
  64. 'description': 'The lives of prominent figures in the tech world, including their friendships, rivalries, victories and failures.',
  65. 'timestamp': 1542662458,
  66. 'upload_date': '20181119',
  67. 'age_limit': 14,
  68. },
  69. 'params': {
  70. 'skip_download': True,
  71. },
  72. 'skip': 'Content not available',
  73. }]
  74. _HOME_PAGE_URL = 'https://www.nationalgeographic.com/tv/'
  75. _API_KEY = '238bb0a0c2aba67922c48709ce0c06fd'