]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/dplay.py
d624808108dd51b786453c25760aa9da2fab1997
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 'format': 'bestvideo',
50 'skip_download': True,
53 # geo restricted, via secure api, unsigned download hls URL
54 'url': 'http://www.dplay.dk/videoer/ted-bundy-mind-of-a-monster/ted-bundy-mind-of-a-monster',
57 'display_id': 'ted-bundy-mind-of-a-monster/ted-bundy-mind-of-a-monster',
59 'title': 'Ted Bundy: Mind Of A Monster',
60 'description': 'md5:8b780f6f18de4dae631668b8a9637995',
62 'timestamp': 1570694400,
63 'upload_date': '20191010',
64 'creator': 'ID - Investigation Discovery',
65 'series': 'Ted Bundy: Mind Of A Monster',
70 'format': 'bestvideo',
71 'skip_download': True,
75 'url': 'https://www.dplay.no/videoer/i-kongens-klr/sesong-1-episode-7',
78 'display_id': 'i-kongens-klr/sesong-1-episode-7',
81 'description': 'md5:e3e1411b2b9aebeea36a6ec5d50c60cf',
83 'timestamp': 1516726800,
84 'upload_date': '20180123',
85 'series': 'I kongens klær',
90 'format': 'bestvideo',
91 'skip_download': True,
93 'skip': 'Available for Premium users',
95 'url': 'http://it.dplay.com/nove/biografie-imbarazzanti/luigi-di-maio-la-psicosi-di-stanislawskij/',
96 'md5': '2b808ffb00fc47b884a172ca5d13053c',
99 'display_id': 'biografie-imbarazzanti/luigi-di-maio-la-psicosi-di-stanislawskij',
101 'title': 'Luigi Di Maio: la psicosi di Stanislawskij',
102 'description': 'md5:3c7a4303aef85868f867a26f5cc14813',
103 'thumbnail': r
're:^https?://.*\.jpe?g',
104 'upload_date': '20160524',
105 'timestamp': 1464076800,
106 'series': 'Biografie imbarazzanti',
108 'episode': 'Episode 1',
112 'url': 'https://es.dplay.com/dmax/la-fiebre-del-oro/temporada-8-episodio-1/',
115 'display_id': 'la-fiebre-del-oro/temporada-8-episodio-1',
117 'title': 'Episodio 1',
118 'description': 'md5:b9dcff2071086e003737485210675f69',
119 'thumbnail': r
're:^https?://.*\.png',
120 'upload_date': '20180709',
121 'timestamp': 1531173540,
122 'series': 'La fiebre del oro',
124 'episode': 'Episode 1',
128 'skip_download': True,
131 'url': 'https://www.dplay.fi/videot/shifting-gears-with-aaron-kaufman/episode-16',
132 'only_matching': True,
134 'url': 'https://www.dplay.jp/video/gold-rush/24086',
135 'only_matching': True,
137 'url': 'https://www.discoveryplus.se/videos/nugammalt-77-handelser-som-format-sverige/nugammalt-77-handelser-som-format-sverige-101',
138 'only_matching': True,
140 'url': 'https://www.discoveryplus.dk/videoer/ted-bundy-mind-of-a-monster/ted-bundy-mind-of-a-monster',
141 'only_matching': True,
143 'url': 'https://www.discoveryplus.no/videoer/i-kongens-klr/sesong-1-episode-7',
144 'only_matching': True,
146 'url': 'https://www.discoveryplus.it/videos/biografie-imbarazzanti/luigi-di-maio-la-psicosi-di-stanislawskij',
147 'only_matching': True,
149 'url': 'https://www.discoveryplus.es/videos/la-fiebre-del-oro/temporada-8-episodio-1',
150 'only_matching': True,
152 'url': 'https://www.discoveryplus.fi/videot/shifting-gears-with-aaron-kaufman/episode-16',
153 'only_matching': True,
156 def _process_errors(self
, e
, geo_countries
):
157 info
= self
._parse
_json
(e
.cause
.read().decode('utf-8'), None)
158 error
= info
['errors'][0]
159 error_code
= error
.get('code')
160 if error_code
== 'access.denied.geoblocked':
161 self
.raise_geo_restricted(countries
=geo_countries
)
162 elif error_code
in ('access.denied.missingpackage', 'invalid.token'):
163 raise ExtractorError(
164 'This video is only available for registered users. You may want to use --cookies.', expected
=True)
165 raise ExtractorError(info
['errors'][0]['detail'], expected
=True)
167 def _update_disco_api_headers(self
, headers
, disco_base
, display_id
, realm
):
168 headers
['Authorization'] = 'Bearer ' + self
._download
_json
(
169 disco_base
+ 'token', display_id
, 'Downloading token',
172 })['data']['attributes']['token']
174 def _download_video_playback_info(self
, disco_base
, video_id
, headers
):
175 streaming
= self
._download
_json
(
176 disco_base
+ 'playback/videoPlaybackInfo/' + video_id
,
177 video_id
, headers
=headers
)['data']['attributes']['streaming']
179 for format_id
, format_dict
in streaming
.items():
180 streaming_list
.append({
182 'url': format_dict
.get('url'),
184 return streaming_list
186 def _get_disco_api_info(self
, url
, display_id
, disco_host
, realm
, country
):
187 geo_countries
= [country
.upper()]
188 self
._initialize
_geo
_bypass
({
189 'countries': geo_countries
,
191 disco_base
= 'https://%s/' % disco_host
195 self
._update
_disco
_api
_headers
(headers
, disco_base
, display_id
, realm
)
197 video
= self
._download
_json
(
198 disco_base
+ 'content/videos/' + display_id
, display_id
,
199 headers
=headers
, query
={
200 'fields[channel]': 'name',
201 'fields[image]': 'height,src,width',
202 'fields[show]': 'name',
203 'fields[tag]': 'name',
204 'fields[video]': 'description,episodeNumber,name,publishStart,seasonNumber,videoDuration',
205 'include': 'images,primaryChannel,show,tags'
207 except ExtractorError
as e
:
208 if isinstance(e
.cause
, compat_HTTPError
) and e
.cause
.code
== 400:
209 self
._process
_errors
(e
, geo_countries
)
211 video_id
= video
['data']['id']
212 info
= video
['data']['attributes']
213 title
= info
['name'].strip()
216 streaming
= self
._download
_video
_playback
_info
(
217 disco_base
, video_id
, headers
)
218 except ExtractorError
as e
:
219 if isinstance(e
.cause
, compat_HTTPError
) and e
.cause
.code
== 403:
220 self
._process
_errors
(e
, geo_countries
)
222 for format_dict
in streaming
:
223 if not isinstance(format_dict
, dict):
225 format_url
= format_dict
.get('url')
228 format_id
= format_dict
.get('type')
229 ext
= determine_ext(format_url
)
230 if format_id
== 'dash' or ext
== 'mpd':
231 formats
.extend(self
._extract
_mpd
_formats
(
232 format_url
, display_id
, mpd_id
='dash', fatal
=False))
233 elif format_id
== 'hls' or ext
== 'm3u8':
234 formats
.extend(self
._extract
_m
3u8_formats
(
235 format_url
, display_id
, 'mp4',
236 entry_protocol
='m3u8_native', m3u8_id
='hls',
241 'format_id': format_id
,
243 self
._sort
_formats
(formats
)
245 creator
= series
= None
248 included
= video
.get('included') or []
249 if isinstance(included
, list):
251 attributes
= e
.get('attributes')
254 e_type
= e
.get('type')
255 if e_type
== 'channel':
256 creator
= attributes
.get('name')
257 elif e_type
== 'image':
258 src
= attributes
.get('src')
262 'width': int_or_none(attributes
.get('width')),
263 'height': int_or_none(attributes
.get('height')),
266 series
= attributes
.get('name')
267 elif e_type
== 'tag':
268 name
= attributes
.get('name')
274 'display_id': display_id
,
276 'description': strip_or_none(info
.get('description')),
277 'duration': float_or_none(info
.get('videoDuration'), 1000),
278 'timestamp': unified_timestamp(info
.get('publishStart')),
280 'season_number': int_or_none(info
.get('seasonNumber')),
281 'episode_number': int_or_none(info
.get('episodeNumber')),
284 'thumbnails': thumbnails
,
288 def _real_extract(self
, url
):
289 mobj
= self
._match
_valid
_url
(url
)
290 display_id
= mobj
.group('id')
291 domain
= mobj
.group('domain').lstrip('www.')
292 country
= mobj
.group('country') or mobj
.group('subdomain_country') or mobj
.group('plus_country')
293 host
= 'disco-api.' + domain
if domain
[0] == 'd' else 'eu2-prod.disco-api.com'
294 return self
._get
_disco
_api
_info
(
295 url
, display_id
, host
, 'dplay' + country
, country
)
298 class HGTVDeIE(DPlayIE
):
299 _VALID_URL
= r
'https?://de\.hgtv\.com/sendungen' + DPlayIE
._PATH
_REGEX
301 'url': 'https://de.hgtv.com/sendungen/tiny-house-klein-aber-oho/wer-braucht-schon-eine-toilette/',
304 'display_id': 'tiny-house-klein-aber-oho/wer-braucht-schon-eine-toilette',
306 'title': 'Wer braucht schon eine Toilette',
307 'description': 'md5:05b40a27e7aed2c9172de34d459134e2',
308 'duration': 1177.024,
309 'timestamp': 1595705400,
310 'upload_date': '20200725',
312 'series': 'Tiny House - klein, aber oho',
317 'format': 'bestvideo',
321 def _real_extract(self
, url
):
322 display_id
= self
._match
_id
(url
)
323 return self
._get
_disco
_api
_info
(
324 url
, display_id
, 'eu1-prod.disco-api.com', 'hgtv', 'de')
327 class DiscoveryPlusIE(DPlayIE
):
328 _VALID_URL
= r
'https?://(?:www\.)?discoveryplus\.com/(?:\w{2}/)?video' + DPlayIE
._PATH
_REGEX
330 'url': 'https://www.discoveryplus.com/video/property-brothers-forever-home/food-and-family',
333 'display_id': 'property-brothers-forever-home/food-and-family',
335 'title': 'Food and Family',
336 'description': 'The brothers help a Richmond family expand their single-level home.',
337 'duration': 2583.113,
338 'timestamp': 1609304400,
339 'upload_date': '20201230',
341 'series': 'Property Brothers: Forever Home',
345 'skip': 'Available for Premium users',
347 'url': 'https://discoveryplus.com/ca/video/bering-sea-gold-discovery-ca/goldslingers',
348 'only_matching': True,
351 _PRODUCT
= 'dplus_us'
352 _API_URL
= 'us1-prod-direct.discoveryplus.com'
354 def _update_disco_api_headers(self
, headers
, disco_base
, display_id
, realm
):
355 headers
['x-disco-client'] = f
'WEB:UNKNOWN:{self._PRODUCT}:25.2.6'
357 def _download_video_playback_info(self
, disco_base
, video_id
, headers
):
358 return self
._download
_json
(
359 disco_base
+ 'playback/v3/videoPlaybackInfo',
360 video_id
, headers
=headers
, data
=json
.dumps({
365 'wisteriaProperties': {
366 'platform': 'desktop',
367 'product': self
._PRODUCT
,
369 }).encode('utf-8'))['data']['attributes']['streaming']
371 def _real_extract(self
, url
):
372 display_id
= self
._match
_id
(url
)
373 return self
._get
_disco
_api
_info
(
374 url
, display_id
, self
._API
_URL
, 'go', 'us')
377 class ScienceChannelIE(DiscoveryPlusIE
):
378 _VALID_URL
= r
'https?://(?:www\.)?sciencechannel\.com/video' + DPlayIE
._PATH
_REGEX
380 'url': 'https://www.sciencechannel.com/video/strangest-things-science-atve-us/nazi-mystery-machine',
383 'display_id': 'strangest-things-science-atve-us/nazi-mystery-machine',
385 'title': 'Nazi Mystery Machine',
386 'description': 'Experts investigate the secrets of a revolutionary encryption machine.',
390 'skip': 'Available for Premium users',
394 _API_URL
= 'us1-prod-direct.sciencechannel.com'
397 class DIYNetworkIE(DiscoveryPlusIE
):
398 _VALID_URL
= r
'https?://(?:watch\.)?diynetwork\.com/video' + DPlayIE
._PATH
_REGEX
400 'url': 'https://watch.diynetwork.com/video/pool-kings-diy-network/bringing-beach-life-to-texas',
403 'display_id': 'pool-kings-diy-network/bringing-beach-life-to-texas',
405 'title': 'Bringing Beach Life to Texas',
406 'description': 'The Pool Kings give a family a day at the beach in their own backyard.',
410 'skip': 'Available for Premium users',
414 _API_URL
= 'us1-prod-direct.watch.diynetwork.com'
417 class AnimalPlanetIE(DiscoveryPlusIE
):
418 _VALID_URL
= r
'https?://(?:www\.)?animalplanet\.com/video' + DPlayIE
._PATH
_REGEX
420 'url': 'https://www.animalplanet.com/video/north-woods-law-animal-planet/squirrel-showdown',
423 'display_id': 'north-woods-law-animal-planet/squirrel-showdown',
425 'title': 'Squirrel Showdown',
426 'description': 'A woman is suspected of being in possession of flying squirrel kits.',
428 'episode_number': 11,
430 'skip': 'Available for Premium users',
434 _API_URL
= 'us1-prod-direct.animalplanet.com'