nationalgeographic.py (2924B)
1 from __future__ import unicode_literals 2 3 from .common import InfoExtractor 4 from .fox import FOXIE 5 from ..utils import ( 6 smuggle_url, 7 url_basename, 8 ) 9 10 11 class NationalGeographicVideoIE(InfoExtractor): 12 IE_NAME = 'natgeo:video' 13 _VALID_URL = r'https?://video\.nationalgeographic\.com/.*?' 14 15 _TESTS = [ 16 { 17 'url': 'http://video.nationalgeographic.com/video/news/150210-news-crab-mating-vin?source=featuredvideo', 18 'md5': '730855d559abbad6b42c2be1fa584917', 19 'info_dict': { 20 'id': '0000014b-70a1-dd8c-af7f-f7b559330001', 21 'ext': 'mp4', 22 'title': 'Mating Crabs Busted by Sharks', 23 'description': 'md5:16f25aeffdeba55aaa8ec37e093ad8b3', 24 'timestamp': 1423523799, 25 'upload_date': '20150209', 26 'uploader': 'NAGS', 27 }, 28 'add_ie': ['ThePlatform'], 29 }, 30 { 31 'url': 'http://video.nationalgeographic.com/wild/when-sharks-attack/the-real-jaws', 32 'md5': '6a3105eb448c070503b3105fb9b320b5', 33 'info_dict': { 34 'id': 'ngc-I0IauNSWznb_UV008GxSbwY35BZvgi2e', 35 'ext': 'mp4', 36 'title': 'The Real Jaws', 37 'description': 'md5:8d3e09d9d53a85cd397b4b21b2c77be6', 38 'timestamp': 1433772632, 39 'upload_date': '20150608', 40 'uploader': 'NAGS', 41 }, 42 'add_ie': ['ThePlatform'], 43 }, 44 ] 45 46 def _real_extract(self, url): 47 name = url_basename(url) 48 49 webpage = self._download_webpage(url, name) 50 guid = self._search_regex( 51 r'id="(?:videoPlayer|player-container)"[^>]+data-guid="([^"]+)"', 52 webpage, 'guid') 53 54 return { 55 '_type': 'url_transparent', 56 'ie_key': 'ThePlatform', 57 'url': smuggle_url( 58 'http://link.theplatform.com/s/ngs/media/guid/2423130747/%s?mbr=true' % guid, 59 {'force_smil_url': True}), 60 'id': guid, 61 } 62 63 64 class NationalGeographicTVIE(FOXIE): 65 _VALID_URL = r'https?://(?:www\.)?nationalgeographic\.com/tv/watch/(?P<id>[\da-fA-F]+)' 66 _TESTS = [{ 67 'url': 'https://www.nationalgeographic.com/tv/watch/6a875e6e734b479beda26438c9f21138/', 68 'info_dict': { 69 'id': '6a875e6e734b479beda26438c9f21138', 70 'ext': 'mp4', 71 'title': 'Why Nat Geo? Valley of the Boom', 72 'description': 'The lives of prominent figures in the tech world, including their friendships, rivalries, victories and failures.', 73 'timestamp': 1542662458, 74 'upload_date': '20181119', 75 'age_limit': 14, 76 }, 77 'params': { 78 'skip_download': True, 79 }, 80 }] 81 _HOME_PAGE_URL = 'https://www.nationalgeographic.com/tv/' 82 _API_KEY = '238bb0a0c2aba67922c48709ce0c06fd'