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