]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/dplay.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..compat
import compat_HTTPError
18 class DPlayIE(InfoExtractor
):
19 _PATH_REGEX
= r
'/(?P<id>[^/]+/[^/?#]+)'
20 _VALID_URL
= r
'''(?x)https?://
24 play\.(?P<country>dk|fi|jp|se|no)|
25 iscoveryplus\.(?P<plus_country>dk|es|fi|it|se|no)
28 (?P<subdomain_country>es|it)\.dplay\.com
29 )/[^/]+''' + _PATH_REGEX
32 # non geo restricted, via secure api, unsigned download hls URL
33 'url': 'https://www.dplay.se/videos/nugammalt-77-handelser-som-format-sverige/nugammalt-77-handelser-som-format-sverige-101',
36 'display_id': 'nugammalt-77-handelser-som-format-sverige/nugammalt-77-handelser-som-format-sverige-101',
38 'title': 'Svensken lär sig njuta av livet',
39 'description': 'md5:d3819c9bccffd0fe458ca42451dd50d8',
41 'timestamp': 1365453720,
42 'upload_date': '20130408',
44 'series': 'Nugammalt - 77 händelser som format Sverige',
49 'skip_download': True,
52 # geo restricted, via secure api, unsigned download hls URL
53 'url': 'http://www.dplay.dk/videoer/ted-bundy-mind-of-a-monster/ted-bundy-mind-of-a-monster',
56 'display_id': 'ted-bundy-mind-of-a-monster/ted-bundy-mind-of-a-monster',
58 'title': 'Ted Bundy: Mind Of A Monster',
59 'description': 'md5:8b780f6f18de4dae631668b8a9637995',
61 'timestamp': 1570694400,
62 'upload_date': '20191010',
63 'creator': 'ID - Investigation Discovery',
64 'series': 'Ted Bundy: Mind Of A Monster',
69 'skip_download': True,
73 'url': 'https://www.dplay.no/videoer/i-kongens-klr/sesong-1-episode-7',
76 'display_id': 'i-kongens-klr/sesong-1-episode-7',
79 'description': 'md5:e3e1411b2b9aebeea36a6ec5d50c60cf',
81 'timestamp': 1516726800,
82 'upload_date': '20180123',
83 'series': 'I kongens klær',
88 'skip_download': True,
90 'skip': 'Available for Premium users',
92 'url': 'http://it.dplay.com/nove/biografie-imbarazzanti/luigi-di-maio-la-psicosi-di-stanislawskij/',
93 'md5': '2b808ffb00fc47b884a172ca5d13053c',
96 'display_id': 'biografie-imbarazzanti/luigi-di-maio-la-psicosi-di-stanislawskij',
98 'title': 'Luigi Di Maio: la psicosi di Stanislawskij',
99 'description': 'md5:3c7a4303aef85868f867a26f5cc14813',
100 'thumbnail': r
're:^https?://.*\.jpe?g',
101 'upload_date': '20160524',
102 'timestamp': 1464076800,
103 'series': 'Biografie imbarazzanti',
105 'episode': 'Episode 1',
109 'url': 'https://es.dplay.com/dmax/la-fiebre-del-oro/temporada-8-episodio-1/',
112 'display_id': 'la-fiebre-del-oro/temporada-8-episodio-1',
114 'title': 'Episodio 1',
115 'description': 'md5:b9dcff2071086e003737485210675f69',
116 'thumbnail': r
're:^https?://.*\.png',
117 'upload_date': '20180709',
118 'timestamp': 1531173540,
119 'series': 'La fiebre del oro',
121 'episode': 'Episode 1',
125 'skip_download': True,
128 'url': 'https://www.dplay.fi/videot/shifting-gears-with-aaron-kaufman/episode-16',
129 'only_matching': True,
131 'url': 'https://www.dplay.jp/video/gold-rush/24086',
132 'only_matching': True,
134 'url': 'https://www.discoveryplus.se/videos/nugammalt-77-handelser-som-format-sverige/nugammalt-77-handelser-som-format-sverige-101',
135 'only_matching': True,
137 'url': 'https://www.discoveryplus.dk/videoer/ted-bundy-mind-of-a-monster/ted-bundy-mind-of-a-monster',
138 'only_matching': True,
140 'url': 'https://www.discoveryplus.no/videoer/i-kongens-klr/sesong-1-episode-7',
141 'only_matching': True,
143 'url': 'https://www.discoveryplus.it/videos/biografie-imbarazzanti/luigi-di-maio-la-psicosi-di-stanislawskij',
144 'only_matching': True,
146 'url': 'https://www.discoveryplus.es/videos/la-fiebre-del-oro/temporada-8-episodio-1',
147 'only_matching': True,
149 'url': 'https://www.discoveryplus.fi/videot/shifting-gears-with-aaron-kaufman/episode-16',
150 'only_matching': True,
153 def _process_errors(self
, e
, geo_countries
):
154 info
= self
._parse
_json
(e
.cause
.read().decode('utf-8'), None)
155 error
= info
['errors'][0]
156 error_code
= error
.get('code')
157 if error_code
== 'access.denied.geoblocked':
158 self
.raise_geo_restricted(countries
=geo_countries
)
159 elif error_code
in ('access.denied.missingpackage', 'invalid.token'):
160 raise ExtractorError(
161 'This video is only available for registered users. You may want to use --cookies.', expected
=True)
162 raise ExtractorError(info
['errors'][0]['detail'], expected
=True)
164 def _update_disco_api_headers(self
, headers
, disco_base
, display_id
, realm
):
165 headers
['Authorization'] = 'Bearer ' + self
._download
_json
(
166 disco_base
+ 'token', display_id
, 'Downloading token',
169 })['data']['attributes']['token']
171 def _download_video_playback_info(self
, disco_base
, video_id
, headers
):
172 streaming
= self
._download
_json
(
173 disco_base
+ 'playback/videoPlaybackInfo/' + video_id
,
174 video_id
, headers
=headers
)['data']['attributes']['streaming']
176 for format_id
, format_dict
in streaming
.items():
177 streaming_list
.append({
179 'url': format_dict
.get('url'),
181 return streaming_list
183 def _get_disco_api_info(self
, url
, display_id
, disco_host
, realm
, country
):
184 geo_countries
= [country
.upper()]
185 self
._initialize
_geo
_bypass
({
186 'countries': geo_countries
,
188 disco_base
= 'https://%s/' % disco_host
192 self
._update
_disco
_api
_headers
(headers
, disco_base
, display_id
, realm
)
194 video
= self
._download
_json
(
195 disco_base
+ 'content/videos/' + display_id
, display_id
,
196 headers
=headers
, query
={
197 'fields[channel]': 'name',
198 'fields[image]': 'height,src,width',
199 'fields[show]': 'name',
200 'fields[tag]': 'name',
201 'fields[video]': 'description,episodeNumber,name,publishStart,seasonNumber,videoDuration',
202 'include': 'images,primaryChannel,show,tags'
204 except ExtractorError
as e
:
205 if isinstance(e
.cause
, compat_HTTPError
) and e
.cause
.code
== 400:
206 self
._process
_errors
(e
, geo_countries
)
208 video_id
= video
['data']['id']
209 info
= video
['data']['attributes']
210 title
= info
['name'].strip()
213 streaming
= self
._download
_video
_playback
_info
(
214 disco_base
, video_id
, headers
)
215 except ExtractorError
as e
:
216 if isinstance(e
.cause
, compat_HTTPError
) and e
.cause
.code
== 403:
217 self
._process
_errors
(e
, geo_countries
)
219 for format_dict
in streaming
:
220 if not isinstance(format_dict
, dict):
222 format_url
= format_dict
.get('url')
225 format_id
= format_dict
.get('type')
226 ext
= determine_ext(format_url
)
227 if format_id
== 'dash' or ext
== 'mpd':
228 formats
.extend(self
._extract
_mpd
_formats
(
229 format_url
, display_id
, mpd_id
='dash', fatal
=False))
230 elif format_id
== 'hls' or ext
== 'm3u8':
231 formats
.extend(self
._extract
_m
3u8_formats
(
232 format_url
, display_id
, 'mp4',
233 entry_protocol
='m3u8_native', m3u8_id
='hls',
238 'format_id': format_id
,
240 self
._sort
_formats
(formats
)
242 creator
= series
= None
245 included
= video
.get('included') or []
246 if isinstance(included
, list):
248 attributes
= e
.get('attributes')
251 e_type
= e
.get('type')
252 if e_type
== 'channel':
253 creator
= attributes
.get('name')
254 elif e_type
== 'image':
255 src
= attributes
.get('src')
259 'width': int_or_none(attributes
.get('width')),
260 'height': int_or_none(attributes
.get('height')),
263 series
= attributes
.get('name')
264 elif e_type
== 'tag':
265 name
= attributes
.get('name')
271 'display_id': display_id
,
273 'description': strip_or_none(info
.get('description')),
274 'duration': float_or_none(info
.get('videoDuration'), 1000),
275 'timestamp': unified_timestamp(info
.get('publishStart')),
277 'season_number': int_or_none(info
.get('seasonNumber')),
278 'episode_number': int_or_none(info
.get('episodeNumber')),
281 'thumbnails': thumbnails
,
285 def _real_extract(self
, url
):
286 mobj
= self
._match
_valid
_url
(url
)
287 display_id
= mobj
.group('id')
288 domain
= mobj
.group('domain').lstrip('www.')
289 country
= mobj
.group('country') or mobj
.group('subdomain_country') or mobj
.group('plus_country')
290 host
= 'disco-api.' + domain
if domain
[0] == 'd' else 'eu2-prod.disco-api.com'
291 return self
._get
_disco
_api
_info
(
292 url
, display_id
, host
, 'dplay' + country
, country
)
295 class HGTVDeIE(DPlayIE
):
296 _VALID_URL
= r
'https?://de\.hgtv\.com/sendungen' + DPlayIE
._PATH
_REGEX
298 'url': 'https://de.hgtv.com/sendungen/tiny-house-klein-aber-oho/wer-braucht-schon-eine-toilette/',
301 'display_id': 'tiny-house-klein-aber-oho/wer-braucht-schon-eine-toilette',
303 'title': 'Wer braucht schon eine Toilette',
304 'description': 'md5:05b40a27e7aed2c9172de34d459134e2',
305 'duration': 1177.024,
306 'timestamp': 1595705400,
307 'upload_date': '20200725',
309 'series': 'Tiny House - klein, aber oho',
315 def _real_extract(self
, url
):
316 display_id
= self
._match
_id
(url
)
317 return self
._get
_disco
_api
_info
(
318 url
, display_id
, 'eu1-prod.disco-api.com', 'hgtv', 'de')
321 class DiscoveryPlusIE(DPlayIE
):
322 _VALID_URL
= r
'https?://(?:www\.)?discoveryplus\.com/(?:\w{2}/)?video' + DPlayIE
._PATH
_REGEX
324 'url': 'https://www.discoveryplus.com/video/property-brothers-forever-home/food-and-family',
327 'display_id': 'property-brothers-forever-home/food-and-family',
329 'title': 'Food and Family',
330 'description': 'The brothers help a Richmond family expand their single-level home.',
331 'duration': 2583.113,
332 'timestamp': 1609304400,
333 'upload_date': '20201230',
335 'series': 'Property Brothers: Forever Home',
339 'skip': 'Available for Premium users',
341 'url': 'https://discoveryplus.com/ca/video/bering-sea-gold-discovery-ca/goldslingers',
342 'only_matching': True,
345 _PRODUCT
= 'dplus_us'
346 _API_URL
= 'us1-prod-direct.discoveryplus.com'
348 def _update_disco_api_headers(self
, headers
, disco_base
, display_id
, realm
):
349 headers
['x-disco-client'] = f
'WEB:UNKNOWN:{self._PRODUCT}:25.2.6'
351 def _download_video_playback_info(self
, disco_base
, video_id
, headers
):
352 return self
._download
_json
(
353 disco_base
+ 'playback/v3/videoPlaybackInfo',
354 video_id
, headers
=headers
, data
=json
.dumps({
359 'wisteriaProperties': {
360 'platform': 'desktop',
361 'product': self
._PRODUCT
,
363 }).encode('utf-8'))['data']['attributes']['streaming']
365 def _real_extract(self
, url
):
366 display_id
= self
._match
_id
(url
)
367 return self
._get
_disco
_api
_info
(
368 url
, display_id
, self
._API
_URL
, 'go', 'us')
371 class ScienceChannelIE(DiscoveryPlusIE
):
372 _VALID_URL
= r
'https?://(?:www\.)?sciencechannel\.com/video' + DPlayIE
._PATH
_REGEX
374 'url': 'https://www.sciencechannel.com/video/strangest-things-science-atve-us/nazi-mystery-machine',
377 'display_id': 'strangest-things-science-atve-us/nazi-mystery-machine',
379 'title': 'Nazi Mystery Machine',
380 'description': 'Experts investigate the secrets of a revolutionary encryption machine.',
384 'skip': 'Available for Premium users',
388 _API_URL
= 'us1-prod-direct.sciencechannel.com'
391 class DIYNetworkIE(DiscoveryPlusIE
):
392 _VALID_URL
= r
'https?://(?:watch\.)?diynetwork\.com/video' + DPlayIE
._PATH
_REGEX
394 'url': 'https://watch.diynetwork.com/video/pool-kings-diy-network/bringing-beach-life-to-texas',
397 'display_id': 'pool-kings-diy-network/bringing-beach-life-to-texas',
399 'title': 'Bringing Beach Life to Texas',
400 'description': 'The Pool Kings give a family a day at the beach in their own backyard.',
404 'skip': 'Available for Premium users',
408 _API_URL
= 'us1-prod-direct.watch.diynetwork.com'
411 class AnimalPlanetIE(DiscoveryPlusIE
):
412 _VALID_URL
= r
'https?://(?:www\.)?animalplanet\.com/video' + DPlayIE
._PATH
_REGEX
414 'url': 'https://www.animalplanet.com/video/north-woods-law-animal-planet/squirrel-showdown',
417 'display_id': 'north-woods-law-animal-planet/squirrel-showdown',
419 'title': 'Squirrel Showdown',
420 'description': 'A woman is suspected of being in possession of flying squirrel kits.',
422 'episode_number': 11,
424 'skip': 'Available for Premium users',
428 _API_URL
= 'us1-prod-direct.animalplanet.com'