]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/dplay.py
4 from .common
import InfoExtractor
5 from ..compat
import compat_HTTPError
18 class DPlayBaseIE(InfoExtractor
):
19 _PATH_REGEX
= r
'/(?P<id>[^/]+/[^/?#]+)'
20 _auth_token_cache
= {}
22 def _get_auth(self
, disco_base
, display_id
, realm
, needs_device_id
=True):
23 key
= (disco_base
, realm
)
24 st
= self
._get
_cookies
(disco_base
).get('st')
25 token
= (st
and st
.value
) or self
._auth
_token
_cache
.get(key
)
28 query
= {'realm': realm}
30 query
['deviceId'] = uuid
.uuid4().hex
31 token
= self
._download
_json
(
32 disco_base
+ 'token', display_id
, 'Downloading token',
33 query
=query
)['data']['attributes']['token']
35 # Save cache only if cookies are not being set
36 if not self
._get
_cookies
(disco_base
).get('st'):
37 self
._auth
_token
_cache
[key
] = token
39 return f
'Bearer {token}'
41 def _process_errors(self
, e
, geo_countries
):
42 info
= self
._parse
_json
(e
.cause
.read().decode('utf-8'), None)
43 error
= info
['errors'][0]
44 error_code
= error
.get('code')
45 if error_code
== 'access.denied.geoblocked':
46 self
.raise_geo_restricted(countries
=geo_countries
)
47 elif error_code
in ('access.denied.missingpackage', 'invalid.token'):
49 'This video is only available for registered users. You may want to use --cookies.', expected
=True)
50 raise ExtractorError(info
['errors'][0]['detail'], expected
=True)
52 def _update_disco_api_headers(self
, headers
, disco_base
, display_id
, realm
):
53 headers
['Authorization'] = self
._get
_auth
(disco_base
, display_id
, realm
, False)
55 def _download_video_playback_info(self
, disco_base
, video_id
, headers
):
56 streaming
= self
._download
_json
(
57 disco_base
+ 'playback/videoPlaybackInfo/' + video_id
,
58 video_id
, headers
=headers
)['data']['attributes']['streaming']
60 for format_id
, format_dict
in streaming
.items():
61 streaming_list
.append({
63 'url': format_dict
.get('url'),
67 def _get_disco_api_info(self
, url
, display_id
, disco_host
, realm
, country
, domain
=''):
68 geo_countries
= [country
.upper()]
69 self
._initialize
_geo
_bypass
({
70 'countries': geo_countries
,
72 disco_base
= 'https://%s/' % disco_host
76 self
._update
_disco
_api
_headers
(headers
, disco_base
, display_id
, realm
)
78 video
= self
._download
_json
(
79 disco_base
+ 'content/videos/' + display_id
, display_id
,
80 headers
=headers
, query
={
81 'fields[channel]': 'name',
82 'fields[image]': 'height,src,width',
83 'fields[show]': 'name',
84 'fields[tag]': 'name',
85 'fields[video]': 'description,episodeNumber,name,publishStart,seasonNumber,videoDuration',
86 'include': 'images,primaryChannel,show,tags'
88 except ExtractorError
as e
:
89 if isinstance(e
.cause
, compat_HTTPError
) and e
.cause
.code
== 400:
90 self
._process
_errors
(e
, geo_countries
)
92 video_id
= video
['data']['id']
93 info
= video
['data']['attributes']
94 title
= info
['name'].strip()
98 streaming
= self
._download
_video
_playback
_info
(
99 disco_base
, video_id
, headers
)
100 except ExtractorError
as e
:
101 if isinstance(e
.cause
, compat_HTTPError
) and e
.cause
.code
== 403:
102 self
._process
_errors
(e
, geo_countries
)
104 for format_dict
in streaming
:
105 if not isinstance(format_dict
, dict):
107 format_url
= format_dict
.get('url')
110 format_id
= format_dict
.get('type')
111 ext
= determine_ext(format_url
)
112 if format_id
== 'dash' or ext
== 'mpd':
113 dash_fmts
, dash_subs
= self
._extract
_mpd
_formats
_and
_subtitles
(
114 format_url
, display_id
, mpd_id
='dash', fatal
=False)
115 formats
.extend(dash_fmts
)
116 subtitles
= self
._merge
_subtitles
(subtitles
, dash_subs
)
117 elif format_id
== 'hls' or ext
== 'm3u8':
118 m3u8_fmts
, m3u8_subs
= self
._extract
_m
3u8_formats
_and
_subtitles
(
119 format_url
, display_id
, 'mp4',
120 entry_protocol
='m3u8_native', m3u8_id
='hls',
122 formats
.extend(m3u8_fmts
)
123 subtitles
= self
._merge
_subtitles
(subtitles
, m3u8_subs
)
127 'format_id': format_id
,
129 self
._sort
_formats
(formats
)
131 creator
= series
= None
134 included
= video
.get('included') or []
135 if isinstance(included
, list):
137 attributes
= e
.get('attributes')
140 e_type
= e
.get('type')
141 if e_type
== 'channel':
142 creator
= attributes
.get('name')
143 elif e_type
== 'image':
144 src
= attributes
.get('src')
148 'width': int_or_none(attributes
.get('width')),
149 'height': int_or_none(attributes
.get('height')),
152 series
= attributes
.get('name')
153 elif e_type
== 'tag':
154 name
= attributes
.get('name')
159 'display_id': display_id
,
161 'description': strip_or_none(info
.get('description')),
162 'duration': float_or_none(info
.get('videoDuration'), 1000),
163 'timestamp': unified_timestamp(info
.get('publishStart')),
165 'season_number': int_or_none(info
.get('seasonNumber')),
166 'episode_number': int_or_none(info
.get('episodeNumber')),
169 'thumbnails': thumbnails
,
171 'subtitles': subtitles
,
178 class DPlayIE(DPlayBaseIE
):
179 _VALID_URL
= r
'''(?x)https?://
183 play\.(?P<country>dk|fi|jp|se|no)|
184 iscoveryplus\.(?P<plus_country>dk|es|fi|it|se|no)
187 (?P<subdomain_country>es|it)\.dplay\.com
188 )/[^/]+''' + DPlayBaseIE
._PATH
_REGEX
191 # non geo restricted, via secure api, unsigned download hls URL
192 'url': 'https://www.dplay.se/videos/nugammalt-77-handelser-som-format-sverige/nugammalt-77-handelser-som-format-sverige-101',
195 'display_id': 'nugammalt-77-handelser-som-format-sverige/nugammalt-77-handelser-som-format-sverige-101',
197 'title': 'Svensken lär sig njuta av livet',
198 'description': 'md5:d3819c9bccffd0fe458ca42451dd50d8',
199 'duration': 2649.856,
200 'timestamp': 1365453720,
201 'upload_date': '20130408',
202 'creator': 'Kanal 5',
203 'series': 'Nugammalt - 77 händelser som format Sverige',
208 'skip_download': True,
211 # geo restricted, via secure api, unsigned download hls URL
212 'url': 'http://www.dplay.dk/videoer/ted-bundy-mind-of-a-monster/ted-bundy-mind-of-a-monster',
215 'display_id': 'ted-bundy-mind-of-a-monster/ted-bundy-mind-of-a-monster',
217 'title': 'Ted Bundy: Mind Of A Monster',
218 'description': 'md5:8b780f6f18de4dae631668b8a9637995',
219 'duration': 5290.027,
220 'timestamp': 1570694400,
221 'upload_date': '20191010',
222 'creator': 'ID - Investigation Discovery',
223 'series': 'Ted Bundy: Mind Of A Monster',
228 'skip_download': True,
232 'url': 'https://www.dplay.no/videoer/i-kongens-klr/sesong-1-episode-7',
235 'display_id': 'i-kongens-klr/sesong-1-episode-7',
237 'title': 'Episode 7',
238 'description': 'md5:e3e1411b2b9aebeea36a6ec5d50c60cf',
240 'timestamp': 1516726800,
241 'upload_date': '20180123',
242 'series': 'I kongens klær',
247 'skip_download': True,
249 'skip': 'Available for Premium users',
251 'url': 'http://it.dplay.com/nove/biografie-imbarazzanti/luigi-di-maio-la-psicosi-di-stanislawskij/',
252 'md5': '2b808ffb00fc47b884a172ca5d13053c',
255 'display_id': 'biografie-imbarazzanti/luigi-di-maio-la-psicosi-di-stanislawskij',
257 'title': 'Luigi Di Maio: la psicosi di Stanislawskij',
258 'description': 'md5:3c7a4303aef85868f867a26f5cc14813',
259 'thumbnail': r
're:^https?://.*\.jpe?g',
260 'upload_date': '20160524',
261 'timestamp': 1464076800,
262 'series': 'Biografie imbarazzanti',
264 'episode': 'Episode 1',
268 'url': 'https://es.dplay.com/dmax/la-fiebre-del-oro/temporada-8-episodio-1/',
271 'display_id': 'la-fiebre-del-oro/temporada-8-episodio-1',
273 'title': 'Episodio 1',
274 'description': 'md5:b9dcff2071086e003737485210675f69',
275 'thumbnail': r
're:^https?://.*\.png',
276 'upload_date': '20180709',
277 'timestamp': 1531173540,
278 'series': 'La fiebre del oro',
280 'episode': 'Episode 1',
284 'skip_download': True,
287 'url': 'https://www.dplay.fi/videot/shifting-gears-with-aaron-kaufman/episode-16',
288 'only_matching': True,
290 'url': 'https://www.dplay.jp/video/gold-rush/24086',
291 'only_matching': True,
293 'url': 'https://www.discoveryplus.se/videos/nugammalt-77-handelser-som-format-sverige/nugammalt-77-handelser-som-format-sverige-101',
294 'only_matching': True,
296 'url': 'https://www.discoveryplus.dk/videoer/ted-bundy-mind-of-a-monster/ted-bundy-mind-of-a-monster',
297 'only_matching': True,
299 'url': 'https://www.discoveryplus.no/videoer/i-kongens-klr/sesong-1-episode-7',
300 'only_matching': True,
302 'url': 'https://www.discoveryplus.it/videos/biografie-imbarazzanti/luigi-di-maio-la-psicosi-di-stanislawskij',
303 'only_matching': True,
305 'url': 'https://www.discoveryplus.es/videos/la-fiebre-del-oro/temporada-8-episodio-1',
306 'only_matching': True,
308 'url': 'https://www.discoveryplus.fi/videot/shifting-gears-with-aaron-kaufman/episode-16',
309 'only_matching': True,
312 def _real_extract(self
, url
):
313 mobj
= self
._match
_valid
_url
(url
)
314 display_id
= mobj
.group('id')
315 domain
= remove_start(mobj
.group('domain'), 'www.')
316 country
= mobj
.group('country') or mobj
.group('subdomain_country') or mobj
.group('plus_country')
317 host
= 'disco-api.' + domain
if domain
[0] == 'd' else 'eu2-prod.disco-api.com'
318 return self
._get
_disco
_api
_info
(
319 url
, display_id
, host
, 'dplay' + country
, country
, domain
)
322 class HGTVDeIE(DPlayBaseIE
):
323 _VALID_URL
= r
'https?://de\.hgtv\.com/sendungen' + DPlayBaseIE
._PATH
_REGEX
325 'url': 'https://de.hgtv.com/sendungen/tiny-house-klein-aber-oho/wer-braucht-schon-eine-toilette/',
328 'display_id': 'tiny-house-klein-aber-oho/wer-braucht-schon-eine-toilette',
330 'title': 'Wer braucht schon eine Toilette',
331 'description': 'md5:05b40a27e7aed2c9172de34d459134e2',
332 'duration': 1177.024,
333 'timestamp': 1595705400,
334 'upload_date': '20200725',
336 'series': 'Tiny House - klein, aber oho',
342 def _real_extract(self
, url
):
343 display_id
= self
._match
_id
(url
)
344 return self
._get
_disco
_api
_info
(
345 url
, display_id
, 'eu1-prod.disco-api.com', 'hgtv', 'de')
348 class DiscoveryPlusBaseIE(DPlayBaseIE
):
349 def _update_disco_api_headers(self
, headers
, disco_base
, display_id
, realm
):
350 headers
['x-disco-client'] = f
'WEB:UNKNOWN:{self._PRODUCT}:25.2.6'
352 def _download_video_playback_info(self
, disco_base
, video_id
, headers
):
353 return self
._download
_json
(
354 disco_base
+ 'playback/v3/videoPlaybackInfo',
355 video_id
, headers
=headers
, data
=json
.dumps({
360 'wisteriaProperties': {
361 'platform': 'desktop',
362 'product': self
._PRODUCT
,
364 }).encode('utf-8'))['data']['attributes']['streaming']
366 def _real_extract(self
, url
):
367 return self
._get
_disco
_api
_info
(url
, self
._match
_id
(url
), **self
._DISCO
_API
_PARAMS
)
370 class GoDiscoveryIE(DiscoveryPlusBaseIE
):
371 _VALID_URL
= r
'https?://(?:go\.)?discovery\.com/video' + DPlayBaseIE
._PATH
_REGEX
373 'url': 'https://go.discovery.com/video/dirty-jobs-discovery-atve-us/rodbuster-galvanizer',
376 'display_id': 'dirty-jobs-discovery-atve-us/rodbuster-galvanizer',
378 'title': 'Rodbuster / Galvanizer',
379 'description': 'Mike installs rebar with a team of rodbusters, then he galvanizes steel.',
383 'skip': 'Available for Premium users',
385 'url': 'https://discovery.com/video/dirty-jobs-discovery-atve-us/rodbuster-galvanizer',
386 'only_matching': True,
390 _DISCO_API_PARAMS
= {
391 'disco_host': 'us1-prod-direct.go.discovery.com',
397 class TravelChannelIE(DiscoveryPlusBaseIE
):
398 _VALID_URL
= r
'https?://(?:watch\.)?travelchannel\.com/video' + DPlayBaseIE
._PATH
_REGEX
400 'url': 'https://watch.travelchannel.com/video/ghost-adventures-travel-channel/ghost-train-of-ely',
403 'display_id': 'ghost-adventures-travel-channel/ghost-train-of-ely',
405 'title': 'Ghost Train of Ely',
406 'description': 'The crew investigates the dark history of the Nevada Northern Railway.',
410 'skip': 'Available for Premium users',
412 'url': 'https://watch.travelchannel.com/video/ghost-adventures-travel-channel/ghost-train-of-ely',
413 'only_matching': True,
417 _DISCO_API_PARAMS
= {
418 'disco_host': 'us1-prod-direct.watch.travelchannel.com',
424 class CookingChannelIE(DiscoveryPlusBaseIE
):
425 _VALID_URL
= r
'https?://(?:watch\.)?cookingchanneltv\.com/video' + DPlayBaseIE
._PATH
_REGEX
427 'url': 'https://watch.cookingchanneltv.com/video/carnival-eats-cooking-channel/the-postman-always-brings-rice-2348634',
430 'display_id': 'carnival-eats-cooking-channel/the-postman-always-brings-rice-2348634',
432 'title': 'The Postman Always Brings Rice',
433 'description': 'Noah visits the Maui Fair and the Aurora Winter Festival in Vancouver.',
437 'skip': 'Available for Premium users',
439 'url': 'https://watch.cookingchanneltv.com/video/carnival-eats-cooking-channel/the-postman-always-brings-rice-2348634',
440 'only_matching': True,
444 _DISCO_API_PARAMS
= {
445 'disco_host': 'us1-prod-direct.watch.cookingchanneltv.com',
451 class HGTVUsaIE(DiscoveryPlusBaseIE
):
452 _VALID_URL
= r
'https?://(?:watch\.)?hgtv\.com/video' + DPlayBaseIE
._PATH
_REGEX
454 'url': 'https://watch.hgtv.com/video/home-inspector-joe-hgtv-atve-us/this-mold-house',
457 'display_id': 'home-inspector-joe-hgtv-atve-us/this-mold-house',
459 'title': 'This Mold House',
460 'description': 'Joe and Noel help take a familys dream home from hazardous to fabulous.',
464 'skip': 'Available for Premium users',
466 'url': 'https://watch.hgtv.com/video/home-inspector-joe-hgtv-atve-us/this-mold-house',
467 'only_matching': True,
471 _DISCO_API_PARAMS
= {
472 'disco_host': 'us1-prod-direct.watch.hgtv.com',
478 class FoodNetworkIE(DiscoveryPlusBaseIE
):
479 _VALID_URL
= r
'https?://(?:watch\.)?foodnetwork\.com/video' + DPlayBaseIE
._PATH
_REGEX
481 'url': 'https://watch.foodnetwork.com/video/kids-baking-championship-food-network/float-like-a-butterfly',
484 'display_id': 'kids-baking-championship-food-network/float-like-a-butterfly',
486 'title': 'Float Like a Butterfly',
487 'description': 'The 12 kid bakers create colorful carved butterfly cakes.',
491 'skip': 'Available for Premium users',
493 'url': 'https://watch.foodnetwork.com/video/kids-baking-championship-food-network/float-like-a-butterfly',
494 'only_matching': True,
498 _DISCO_API_PARAMS
= {
499 'disco_host': 'us1-prod-direct.watch.foodnetwork.com',
505 class DestinationAmericaIE(DiscoveryPlusBaseIE
):
506 _VALID_URL
= r
'https?://(?:www\.)?destinationamerica\.com/video' + DPlayBaseIE
._PATH
_REGEX
508 'url': 'https://www.destinationamerica.com/video/alaska-monsters-destination-america-atve-us/central-alaskas-bigfoot',
511 'display_id': 'alaska-monsters-destination-america-atve-us/central-alaskas-bigfoot',
513 'title': 'Central Alaskas Bigfoot',
514 'description': 'A team heads to central Alaska to investigate an aggressive Bigfoot.',
518 'skip': 'Available for Premium users',
520 'url': 'https://www.destinationamerica.com/video/alaska-monsters-destination-america-atve-us/central-alaskas-bigfoot',
521 'only_matching': True,
525 _DISCO_API_PARAMS
= {
526 'disco_host': 'us1-prod-direct.destinationamerica.com',
532 class InvestigationDiscoveryIE(DiscoveryPlusBaseIE
):
533 _VALID_URL
= r
'https?://(?:www\.)?investigationdiscovery\.com/video' + DPlayBaseIE
._PATH
_REGEX
535 'url': 'https://www.investigationdiscovery.com/video/unmasked-investigation-discovery/the-killer-clown',
538 'display_id': 'unmasked-investigation-discovery/the-killer-clown',
540 'title': 'The Killer Clown',
541 'description': 'A wealthy Florida woman is fatally shot in the face by a clown at her door.',
545 'skip': 'Available for Premium users',
547 'url': 'https://www.investigationdiscovery.com/video/unmasked-investigation-discovery/the-killer-clown',
548 'only_matching': True,
552 _DISCO_API_PARAMS
= {
553 'disco_host': 'us1-prod-direct.investigationdiscovery.com',
559 class AmHistoryChannelIE(DiscoveryPlusBaseIE
):
560 _VALID_URL
= r
'https?://(?:www\.)?ahctv\.com/video' + DPlayBaseIE
._PATH
_REGEX
562 'url': 'https://www.ahctv.com/video/modern-sniper-ahc/army',
565 'display_id': 'modern-sniper-ahc/army',
568 'description': 'Snipers today face challenges their predecessors couldve only dreamed of.',
572 'skip': 'Available for Premium users',
574 'url': 'https://www.ahctv.com/video/modern-sniper-ahc/army',
575 'only_matching': True,
579 _DISCO_API_PARAMS
= {
580 'disco_host': 'us1-prod-direct.ahctv.com',
586 class ScienceChannelIE(DiscoveryPlusBaseIE
):
587 _VALID_URL
= r
'https?://(?:www\.)?sciencechannel\.com/video' + DPlayBaseIE
._PATH
_REGEX
589 'url': 'https://www.sciencechannel.com/video/strangest-things-science-atve-us/nazi-mystery-machine',
592 'display_id': 'strangest-things-science-atve-us/nazi-mystery-machine',
594 'title': 'Nazi Mystery Machine',
595 'description': 'Experts investigate the secrets of a revolutionary encryption machine.',
599 'skip': 'Available for Premium users',
601 'url': 'https://www.sciencechannel.com/video/strangest-things-science-atve-us/nazi-mystery-machine',
602 'only_matching': True,
606 _DISCO_API_PARAMS
= {
607 'disco_host': 'us1-prod-direct.sciencechannel.com',
613 class DIYNetworkIE(DiscoveryPlusBaseIE
):
614 _VALID_URL
= r
'https?://(?:watch\.)?diynetwork\.com/video' + DPlayBaseIE
._PATH
_REGEX
616 'url': 'https://watch.diynetwork.com/video/pool-kings-diy-network/bringing-beach-life-to-texas',
619 'display_id': 'pool-kings-diy-network/bringing-beach-life-to-texas',
621 'title': 'Bringing Beach Life to Texas',
622 'description': 'The Pool Kings give a family a day at the beach in their own backyard.',
626 'skip': 'Available for Premium users',
628 'url': 'https://watch.diynetwork.com/video/pool-kings-diy-network/bringing-beach-life-to-texas',
629 'only_matching': True,
633 _DISCO_API_PARAMS
= {
634 'disco_host': 'us1-prod-direct.watch.diynetwork.com',
640 class DiscoveryLifeIE(DiscoveryPlusBaseIE
):
641 _VALID_URL
= r
'https?://(?:www\.)?discoverylife\.com/video' + DPlayBaseIE
._PATH
_REGEX
643 'url': 'https://www.discoverylife.com/video/surviving-death-discovery-life-atve-us/bodily-trauma',
646 'display_id': 'surviving-death-discovery-life-atve-us/bodily-trauma',
648 'title': 'Bodily Trauma',
649 'description': 'Meet three people who tested the limits of the human body.',
653 'skip': 'Available for Premium users',
655 'url': 'https://www.discoverylife.com/video/surviving-death-discovery-life-atve-us/bodily-trauma',
656 'only_matching': True,
660 _DISCO_API_PARAMS
= {
661 'disco_host': 'us1-prod-direct.discoverylife.com',
667 class AnimalPlanetIE(DiscoveryPlusBaseIE
):
668 _VALID_URL
= r
'https?://(?:www\.)?animalplanet\.com/video' + DPlayBaseIE
._PATH
_REGEX
670 'url': 'https://www.animalplanet.com/video/north-woods-law-animal-planet/squirrel-showdown',
673 'display_id': 'north-woods-law-animal-planet/squirrel-showdown',
675 'title': 'Squirrel Showdown',
676 'description': 'A woman is suspected of being in possession of flying squirrel kits.',
678 'episode_number': 11,
680 'skip': 'Available for Premium users',
682 'url': 'https://www.animalplanet.com/video/north-woods-law-animal-planet/squirrel-showdown',
683 'only_matching': True,
687 _DISCO_API_PARAMS
= {
688 'disco_host': 'us1-prod-direct.animalplanet.com',
694 class TLCIE(DiscoveryPlusBaseIE
):
695 _VALID_URL
= r
'https?://(?:go\.)?tlc\.com/video' + DPlayBaseIE
._PATH
_REGEX
697 'url': 'https://go.tlc.com/video/my-600-lb-life-tlc/melissas-story-part-1',
700 'display_id': 'my-600-lb-life-tlc/melissas-story-part-1',
702 'title': 'Melissas Story (Part 1)',
703 'description': 'At 650 lbs, Melissa is ready to begin her seven-year weight loss journey.',
707 'skip': 'Available for Premium users',
709 'url': 'https://go.tlc.com/video/my-600-lb-life-tlc/melissas-story-part-1',
710 'only_matching': True,
714 _DISCO_API_PARAMS
= {
715 'disco_host': 'us1-prod-direct.tlc.com',
721 class DiscoveryPlusIE(DiscoveryPlusBaseIE
):
722 _VALID_URL
= r
'https?://(?:www\.)?discoveryplus\.com/(?!it/)(?:\w{2}/)?video' + DPlayBaseIE
._PATH
_REGEX
724 'url': 'https://www.discoveryplus.com/video/property-brothers-forever-home/food-and-family',
727 'display_id': 'property-brothers-forever-home/food-and-family',
729 'title': 'Food and Family',
730 'description': 'The brothers help a Richmond family expand their single-level home.',
731 'duration': 2583.113,
732 'timestamp': 1609304400,
733 'upload_date': '20201230',
735 'series': 'Property Brothers: Forever Home',
739 'skip': 'Available for Premium users',
741 'url': 'https://discoveryplus.com/ca/video/bering-sea-gold-discovery-ca/goldslingers',
742 'only_matching': True,
745 _PRODUCT
= 'dplus_us'
746 _DISCO_API_PARAMS
= {
747 'disco_host': 'us1-prod-direct.discoveryplus.com',
753 class DiscoveryPlusIndiaIE(DiscoveryPlusBaseIE
):
754 _VALID_URL
= r
'https?://(?:www\.)?discoveryplus\.in/videos?' + DPlayBaseIE
._PATH
_REGEX
756 'url': 'https://www.discoveryplus.in/videos/how-do-they-do-it/fugu-and-more?seasonId=8&type=EPISODE',
760 'display_id': 'how-do-they-do-it/fugu-and-more',
761 'title': 'Fugu and More',
762 'description': 'The Japanese catch, prepare and eat the deadliest fish on the planet.',
764 'timestamp': 1582309800,
765 'upload_date': '20200221',
766 'series': 'How Do They Do It?',
769 'creator': 'Discovery Channel',
770 'thumbnail': r
're:https://.+\.jpeg',
771 'episode': 'Episode 2',
772 'season': 'Season 8',
776 'skip_download': True,
780 _PRODUCT
= 'dplus-india'
781 _DISCO_API_PARAMS
= {
782 'disco_host': 'ap2-prod-direct.discoveryplus.in',
783 'realm': 'dplusindia',
785 'domain': 'https://www.discoveryplus.in/',
788 def _update_disco_api_headers(self
, headers
, disco_base
, display_id
, realm
):
790 'x-disco-params': 'realm=%s' % realm
,
791 'x-disco-client': f
'WEB:UNKNOWN:{self._PRODUCT}:17.0.0',
792 'Authorization': self
._get
_auth
(disco_base
, display_id
, realm
),
796 class DiscoveryNetworksDeIE(DPlayBaseIE
):
797 _VALID_URL
= r
'https?://(?:www\.)?(?P<domain>(?:tlc|dmax)\.de|dplay\.co\.uk)/(?:programme|show|sendungen)/(?P<programme>[^/]+)/(?:video/)?(?P<alternate_id>[^/]+)'
800 'url': 'https://www.tlc.de/programme/breaking-amish/video/die-welt-da-drauen/DCB331270001100',
804 'title': 'Die Welt da draußen',
805 'description': 'md5:61033c12b73286e409d99a41742ef608',
806 'timestamp': 1554069600,
807 'upload_date': '20190331',
809 'season': 'Season 1',
810 'series': 'Breaking Amish',
812 'tags': ['new york', 'großstadt', 'amische', 'landleben', 'modern', 'infos', 'tradition', 'herausforderung'],
813 'display_id': 'breaking-amish/die-welt-da-drauen',
814 'episode': 'Episode 1',
815 'duration': 2625.024,
817 'thumbnail': r
're:https://.+\.jpg',
820 'skip_download': True,
823 'url': 'https://www.dmax.de/programme/dmax-highlights/video/tuning-star-sidney-hoffmann-exklusiv-bei-dmax/191023082312316',
824 'only_matching': True,
826 'url': 'https://www.dplay.co.uk/show/ghost-adventures/video/hotel-leger-103620/EHD_280313B',
827 'only_matching': True,
829 'url': 'https://tlc.de/sendungen/breaking-amish/die-welt-da-drauen/',
830 'only_matching': True,
833 def _real_extract(self
, url
):
834 domain
, programme
, alternate_id
= self
._match
_valid
_url
(url
).groups()
835 country
= 'GB' if domain
== 'dplay.co.uk' else 'DE'
836 realm
= 'questuk' if country
== 'GB' else domain
.replace('.', '')
837 return self
._get
_disco
_api
_info
(
838 url
, '%s/%s' % (programme
, alternate_id
),
839 'sonic-eu1-prod.disco-api.com', realm
, country
)
842 class DiscoveryPlusShowBaseIE(DPlayBaseIE
):
844 def _entries(self
, show_name
):
846 'x-disco-client': self
._X
_CLIENT
,
847 'x-disco-params': f
'realm={self._REALM}',
848 'referer': self
._DOMAIN
,
849 'Authentication': self
._get
_auth
(self
._BASE
_API
, None, self
._REALM
),
851 show_json
= self
._download
_json
(
852 f
'{self._BASE_API}cms/routes/{self._SHOW_STR}/{show_name}?include=default',
853 video_id
=show_name
, headers
=headers
)['included'][self
._INDEX
]['attributes']['component']
854 show_id
= show_json
['mandatoryParams'].split('=')[-1]
855 season_url
= self
._BASE
_API
+ 'content/videos?sort=episodeNumber&filter[seasonNumber]={}&filter[show.id]={}&page[size]=100&page[number]={}'
856 for season
in show_json
['filters'][0]['options']:
857 season_id
= season
['id']
858 total_pages
, page_num
= 1, 0
859 while page_num
< total_pages
:
860 season_json
= self
._download
_json
(
861 season_url
.format(season_id
, show_id
, str(page_num
+ 1)), show_name
, headers
=headers
,
862 note
='Downloading season %s JSON metadata%s' % (season_id
, ' page %d' % page_num
if page_num
else ''))
864 total_pages
= try_get(season_json
, lambda x
: x
['meta']['totalPages'], int) or 1
865 episodes_json
= season_json
['data']
866 for episode
in episodes_json
:
867 video_path
= episode
['attributes']['path']
868 yield self
.url_result(
869 '%svideos/%s' % (self
._DOMAIN
, video_path
),
870 ie
=self
._VIDEO
_IE
.ie_key(), video_id
=episode
.get('id') or video_path
)
873 def _real_extract(self
, url
):
874 show_name
= self
._match
_valid
_url
(url
).group('show_name')
875 return self
.playlist_result(self
._entries
(show_name
), playlist_id
=show_name
)
878 class DiscoveryPlusItalyIE(DiscoveryPlusBaseIE
):
879 _VALID_URL
= r
'https?://(?:www\.)?discoveryplus\.com/it/video' + DPlayBaseIE
._PATH
_REGEX
881 'url': 'https://www.discoveryplus.com/it/video/i-signori-della-neve/stagione-2-episodio-1-i-preparativi',
882 'only_matching': True,
885 _PRODUCT
= 'dplus_us'
886 _DISCO_API_PARAMS
= {
887 'disco_host': 'eu1-prod-direct.discoveryplus.com',
893 class DiscoveryPlusItalyShowIE(DiscoveryPlusShowBaseIE
):
894 _VALID_URL
= r
'https?://(?:www\.)?discoveryplus\.it/programmi/(?P<show_name>[^/]+)/?(?:[?#]|$)'
896 'url': 'https://www.discoveryplus.it/programmi/deal-with-it-stai-al-gioco',
897 'playlist_mincount': 168,
899 'id': 'deal-with-it-stai-al-gioco',
903 _BASE_API
= 'https://disco-api.discoveryplus.it/'
904 _DOMAIN
= 'https://www.discoveryplus.it/'
905 _X_CLIENT
= 'WEB:UNKNOWN:dplay-client:2.6.0'
907 _SHOW_STR
= 'programmi'
912 class DiscoveryPlusIndiaShowIE(DiscoveryPlusShowBaseIE
):
913 _VALID_URL
= r
'https?://(?:www\.)?discoveryplus\.in/show/(?P<show_name>[^/]+)/?(?:[?#]|$)'
915 'url': 'https://www.discoveryplus.in/show/how-do-they-do-it',
916 'playlist_mincount': 140,
918 'id': 'how-do-they-do-it',
922 _BASE_API
= 'https://ap2-prod-direct.discoveryplus.in/'
923 _DOMAIN
= 'https://www.discoveryplus.in/'
924 _X_CLIENT
= 'WEB:UNKNOWN:dplus-india:prod'
925 _REALM
= 'dplusindia'
928 _VIDEO_IE
= DiscoveryPlusIndiaIE