logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

nationalgeographic.py (2924B)


  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from .fox import FOXIE
  4. from ..utils import (
  5. smuggle_url,
  6. url_basename,
  7. )
  8. class NationalGeographicVideoIE(InfoExtractor):
  9. IE_NAME = 'natgeo:video'
  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 NationalGeographicTVIE(FOXIE):
  56. _VALID_URL = r'https?://(?:www\.)?nationalgeographic\.com/tv/watch/(?P<id>[\da-fA-F]+)'
  57. _TESTS = [{
  58. 'url': 'https://www.nationalgeographic.com/tv/watch/6a875e6e734b479beda26438c9f21138/',
  59. 'info_dict': {
  60. 'id': '6a875e6e734b479beda26438c9f21138',
  61. 'ext': 'mp4',
  62. 'title': 'Why Nat Geo? Valley of the Boom',
  63. 'description': 'The lives of prominent figures in the tech world, including their friendships, rivalries, victories and failures.',
  64. 'timestamp': 1542662458,
  65. 'upload_date': '20181119',
  66. 'age_limit': 14,
  67. },
  68. 'params': {
  69. 'skip_download': True,
  70. },
  71. }]
  72. _HOME_PAGE_URL = 'https://www.nationalgeographic.com/tv/'
  73. _API_KEY = '238bb0a0c2aba67922c48709ce0c06fd'