]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/nationalgeographic.py
1dcf27afef331ceb3b09d6ade66cde65e92e3cd6
1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
6 from .adobepass
import AdobePassIE
15 class NationalGeographicVideoIE(InfoExtractor
):
16 IE_NAME
= 'natgeo:video'
17 _VALID_URL
= r
'https?://video\.nationalgeographic\.com/.*?'
21 'url': 'http://video.nationalgeographic.com/video/news/150210-news-crab-mating-vin?source=featuredvideo',
22 'md5': '730855d559abbad6b42c2be1fa584917',
24 'id': '0000014b-70a1-dd8c-af7f-f7b559330001',
26 'title': 'Mating Crabs Busted by Sharks',
27 'description': 'md5:16f25aeffdeba55aaa8ec37e093ad8b3',
28 'timestamp': 1423523799,
29 'upload_date': '20150209',
32 'add_ie': ['ThePlatform'],
35 'url': 'http://video.nationalgeographic.com/wild/when-sharks-attack/the-real-jaws',
36 'md5': '6a3105eb448c070503b3105fb9b320b5',
38 'id': 'ngc-I0IauNSWznb_UV008GxSbwY35BZvgi2e',
40 'title': 'The Real Jaws',
41 'description': 'md5:8d3e09d9d53a85cd397b4b21b2c77be6',
42 'timestamp': 1433772632,
43 'upload_date': '20150608',
46 'add_ie': ['ThePlatform'],
50 def _real_extract(self
, url
):
51 name
= url_basename(url
)
53 webpage
= self
._download
_webpage
(url
, name
)
54 guid
= self
._search
_regex
(
55 r
'id="(?:videoPlayer|player-container)"[^>]+data-guid="([^"]+)"',
59 '_type': 'url_transparent',
60 'ie_key': 'ThePlatform',
62 'http://link.theplatform.com/s/ngs/media/guid/2423130747/%s?mbr=true' % guid
,
63 {'force_smil_url': True}),
68 class NationalGeographicIE(AdobePassIE
):
70 _VALID_URL
= r
'https?://channel\.nationalgeographic\.com/(?:wild/)?[^/]+/(?:videos|episodes)/(?P<id>[^/?]+)'
74 'url': 'http://channel.nationalgeographic.com/the-story-of-god-with-morgan-freeman/videos/uncovering-a-universal-knowledge/',
75 'md5': '518c9aa655686cf81493af5cc21e2a04',
79 'title': 'Uncovering a Universal Knowledge',
80 'description': 'md5:1a89148475bf931b3661fcd6ddb2ae3a',
81 'timestamp': 1458680907,
82 'upload_date': '20160322',
83 'uploader': 'NEWA-FNG-NGTV',
85 'add_ie': ['ThePlatform'],
88 'url': 'http://channel.nationalgeographic.com/wild/destination-wild/videos/the-stunning-red-bird-of-paradise/',
89 'md5': 'c4912f656b4cbe58f3e000c489360989',
93 'title': 'The Stunning Red Bird of Paradise',
94 'description': 'md5:7bc8cd1da29686be4d17ad1230f0140c',
95 'timestamp': 1459362152,
96 'upload_date': '20160330',
97 'uploader': 'NEWA-FNG-NGTV',
99 'add_ie': ['ThePlatform'],
102 'url': 'http://channel.nationalgeographic.com/the-story-of-god-with-morgan-freeman/episodes/the-power-of-miracles/',
103 'only_matching': True,
107 def _real_extract(self
, url
):
108 display_id
= self
._match
_id
(url
)
109 webpage
= self
._download
_webpage
(url
, display_id
)
110 release_url
= self
._search
_regex
(
111 r
'video_auth_playlist_url\s*=\s*"([^"]+)"',
112 webpage
, 'release url')
117 is_auth
= self
._search
_regex
(r
'video_is_auth\s*=\s*"([^"]+)"', webpage
, 'is auth', fatal
=False)
118 if is_auth
== 'auth':
119 auth_resource_id
= self
._search
_regex
(
120 r
"video_auth_resourceId\s*=\s*'([^']+)'",
121 webpage
, 'auth resource id')
122 query
['auth'] = self
._extract
_mvpd
_auth
(url
, display_id
, 'natgeo', auth_resource_id
)
125 '_type': 'url_transparent',
126 'ie_key': 'ThePlatform',
128 update_url_query(release_url
, query
),
129 {'force_smil_url': True}),
130 'display_id': display_id
,
134 class NationalGeographicEpisodeGuideIE(InfoExtractor
):
135 IE_NAME
= 'natgeo:episodeguide'
136 _VALID_URL
= r
'https?://channel\.nationalgeographic\.com/(?:wild/)?(?P<id>[^/]+)/episode-guide'
139 'url': 'http://channel.nationalgeographic.com/the-story-of-god-with-morgan-freeman/episode-guide/',
141 'id': 'the-story-of-god-with-morgan-freeman-season-1',
142 'title': 'The Story of God with Morgan Freeman - Season 1',
144 'playlist_mincount': 6,
147 'url': 'http://channel.nationalgeographic.com/underworld-inc/episode-guide/?s=2',
149 'id': 'underworld-inc-season-2',
150 'title': 'Underworld, Inc. - Season 2',
152 'playlist_mincount': 7,
156 def _real_extract(self
, url
):
157 display_id
= self
._match
_id
(url
)
158 webpage
= self
._download
_webpage
(url
, display_id
)
159 show
= get_element_by_class('show', webpage
)
160 selected_season
= self
._search
_regex
(
161 r
'<div[^>]+class="select-seasons[^"]*".*?<a[^>]*>(.*?)</a>',
162 webpage
, 'selected season')
164 self
.url_result(self
._proto
_relative
_url
(entry_url
), 'NationalGeographic')
165 for entry_url
in re
.findall('(?s)<div[^>]+class="col-inner"[^>]*?>.*?<a[^>]+href="([^"]+)"', webpage
)]
166 return self
.playlist_result(
167 entries
, '%s-%s' % (display_id
, selected_season
.lower().replace(' ', '-')),
168 '%s - %s' % (show
, selected_season
))