]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/dplay.py
4 from .common
import InfoExtractor
5 from ..compat
import compat_HTTPError
17 class DPlayBaseIE(InfoExtractor
):
18 _PATH_REGEX
= r
'/(?P<id>[^/]+/[^/?#]+)'
19 _auth_token_cache
= {}
21 def _get_auth(self
, disco_base
, display_id
, realm
, needs_device_id
=True):
22 key
= (disco_base
, realm
)
23 st
= self
._get
_cookies
(disco_base
).get('st')
24 token
= (st
and st
.value
) or self
._auth
_token
_cache
.get(key
)
27 query
= {'realm': realm}
29 query
['deviceId'] = uuid
.uuid4().hex
30 token
= self
._download
_json
(
31 disco_base
+ 'token', display_id
, 'Downloading token',
32 query
=query
)['data']['attributes']['token']
34 # Save cache only if cookies are not being set
35 if not self
._get
_cookies
(disco_base
).get('st'):
36 self
._auth
_token
_cache
[key
] = token
38 return f
'Bearer {token}'
40 def _process_errors(self
, e
, geo_countries
):
41 info
= self
._parse
_json
(e
.cause
.read().decode('utf-8'), None)
42 error
= info
['errors'][0]
43 error_code
= error
.get('code')
44 if error_code
== 'access.denied.geoblocked':
45 self
.raise_geo_restricted(countries
=geo_countries
)
46 elif error_code
in ('access.denied.missingpackage', 'invalid.token'):
48 'This video is only available for registered users. You may want to use --cookies.', expected
=True)
49 raise ExtractorError(info
['errors'][0]['detail'], expected
=True)
51 def _update_disco_api_headers(self
, headers
, disco_base
, display_id
, realm
):
52 headers
['Authorization'] = self
._get
_auth
(disco_base
, display_id
, realm
, False)
54 def _download_video_playback_info(self
, disco_base
, video_id
, headers
):
55 streaming
= self
._download
_json
(
56 disco_base
+ 'playback/videoPlaybackInfo/' + video_id
,
57 video_id
, headers
=headers
)['data']['attributes']['streaming']
59 for format_id
, format_dict
in streaming
.items():
60 streaming_list
.append({
62 'url': format_dict
.get('url'),
66 def _get_disco_api_info(self
, url
, display_id
, disco_host
, realm
, country
, domain
=''):
67 geo_countries
= [country
.upper()]
68 self
._initialize
_geo
_bypass
({
69 'countries': geo_countries
,
71 disco_base
= 'https://%s/' % disco_host
75 self
._update
_disco
_api
_headers
(headers
, disco_base
, display_id
, realm
)
77 video
= self
._download
_json
(
78 disco_base
+ 'content/videos/' + display_id
, display_id
,
79 headers
=headers
, query
={
80 'fields[channel]': 'name',
81 'fields[image]': 'height,src,width',
82 'fields[show]': 'name',
83 'fields[tag]': 'name',
84 'fields[video]': 'description,episodeNumber,name,publishStart,seasonNumber,videoDuration',
85 'include': 'images,primaryChannel,show,tags'
87 except ExtractorError
as e
:
88 if isinstance(e
.cause
, compat_HTTPError
) and e
.cause
.code
== 400:
89 self
._process
_errors
(e
, geo_countries
)
91 video_id
= video
['data']['id']
92 info
= video
['data']['attributes']
93 title
= info
['name'].strip()
97 streaming
= self
._download
_video
_playback
_info
(
98 disco_base
, video_id
, headers
)
99 except ExtractorError
as e
:
100 if isinstance(e
.cause
, compat_HTTPError
) and e
.cause
.code
== 403:
101 self
._process
_errors
(e
, geo_countries
)
103 for format_dict
in streaming
:
104 if not isinstance(format_dict
, dict):
106 format_url
= format_dict
.get('url')
109 format_id
= format_dict
.get('type')
110 ext
= determine_ext(format_url
)
111 if format_id
== 'dash' or ext
== 'mpd':
112 dash_fmts
, dash_subs
= self
._extract
_mpd
_formats
_and
_subtitles
(
113 format_url
, display_id
, mpd_id
='dash', fatal
=False)
114 formats
.extend(dash_fmts
)
115 subtitles
= self
._merge
_subtitles
(subtitles
, dash_subs
)
116 elif format_id
== 'hls' or ext
== 'm3u8':
117 m3u8_fmts
, m3u8_subs
= self
._extract
_m
3u8_formats
_and
_subtitles
(
118 format_url
, display_id
, 'mp4',
119 entry_protocol
='m3u8_native', m3u8_id
='hls',
121 formats
.extend(m3u8_fmts
)
122 subtitles
= self
._merge
_subtitles
(subtitles
, m3u8_subs
)
126 'format_id': format_id
,
128 self
._sort
_formats
(formats
)
130 creator
= series
= None
133 included
= video
.get('included') or []
134 if isinstance(included
, list):
136 attributes
= e
.get('attributes')
139 e_type
= e
.get('type')
140 if e_type
== 'channel':
141 creator
= attributes
.get('name')
142 elif e_type
== 'image':
143 src
= attributes
.get('src')
147 'width': int_or_none(attributes
.get('width')),
148 'height': int_or_none(attributes
.get('height')),
151 series
= attributes
.get('name')
152 elif e_type
== 'tag':
153 name
= attributes
.get('name')
158 'display_id': display_id
,
160 'description': strip_or_none(info
.get('description')),
161 'duration': float_or_none(info
.get('videoDuration'), 1000),
162 'timestamp': unified_timestamp(info
.get('publishStart')),
164 'season_number': int_or_none(info
.get('seasonNumber')),
165 'episode_number': int_or_none(info
.get('episodeNumber')),
168 'thumbnails': thumbnails
,
170 'subtitles': subtitles
,
177 class DPlayIE(DPlayBaseIE
):
178 _VALID_URL
= r
'''(?x)https?://
182 play\.(?P<country>dk|fi|jp|se|no)|
183 iscoveryplus\.(?P<plus_country>dk|es|fi|it|se|no)
186 (?P<subdomain_country>es|it)\.dplay\.com
187 )/[^/]+''' + DPlayBaseIE
._PATH
_REGEX
190 # non geo restricted, via secure api, unsigned download hls URL
191 'url': 'https://www.dplay.se/videos/nugammalt-77-handelser-som-format-sverige/nugammalt-77-handelser-som-format-sverige-101',
194 'display_id': 'nugammalt-77-handelser-som-format-sverige/nugammalt-77-handelser-som-format-sverige-101',
196 'title': 'Svensken lär sig njuta av livet',
197 'description': 'md5:d3819c9bccffd0fe458ca42451dd50d8',
198 'duration': 2649.856,
199 'timestamp': 1365453720,
200 'upload_date': '20130408',
201 'creator': 'Kanal 5',
202 'series': 'Nugammalt - 77 händelser som format Sverige',
207 'skip_download': True,
210 # geo restricted, via secure api, unsigned download hls URL
211 'url': 'http://www.dplay.dk/videoer/ted-bundy-mind-of-a-monster/ted-bundy-mind-of-a-monster',
214 'display_id': 'ted-bundy-mind-of-a-monster/ted-bundy-mind-of-a-monster',
216 'title': 'Ted Bundy: Mind Of A Monster',
217 'description': 'md5:8b780f6f18de4dae631668b8a9637995',
218 'duration': 5290.027,
219 'timestamp': 1570694400,
220 'upload_date': '20191010',
221 'creator': 'ID - Investigation Discovery',
222 'series': 'Ted Bundy: Mind Of A Monster',
227 'skip_download': True,
231 'url': 'https://www.dplay.no/videoer/i-kongens-klr/sesong-1-episode-7',
234 'display_id': 'i-kongens-klr/sesong-1-episode-7',
236 'title': 'Episode 7',
237 'description': 'md5:e3e1411b2b9aebeea36a6ec5d50c60cf',
239 'timestamp': 1516726800,
240 'upload_date': '20180123',
241 'series': 'I kongens klær',
246 'skip_download': True,
248 'skip': 'Available for Premium users',
250 'url': 'http://it.dplay.com/nove/biografie-imbarazzanti/luigi-di-maio-la-psicosi-di-stanislawskij/',
251 'md5': '2b808ffb00fc47b884a172ca5d13053c',
254 'display_id': 'biografie-imbarazzanti/luigi-di-maio-la-psicosi-di-stanislawskij',
256 'title': 'Luigi Di Maio: la psicosi di Stanislawskij',
257 'description': 'md5:3c7a4303aef85868f867a26f5cc14813',
258 'thumbnail': r
're:^https?://.*\.jpe?g',
259 'upload_date': '20160524',
260 'timestamp': 1464076800,
261 'series': 'Biografie imbarazzanti',
263 'episode': 'Episode 1',
267 'url': 'https://es.dplay.com/dmax/la-fiebre-del-oro/temporada-8-episodio-1/',
270 'display_id': 'la-fiebre-del-oro/temporada-8-episodio-1',
272 'title': 'Episodio 1',
273 'description': 'md5:b9dcff2071086e003737485210675f69',
274 'thumbnail': r
're:^https?://.*\.png',
275 'upload_date': '20180709',
276 'timestamp': 1531173540,
277 'series': 'La fiebre del oro',
279 'episode': 'Episode 1',
283 'skip_download': True,
286 'url': 'https://www.dplay.fi/videot/shifting-gears-with-aaron-kaufman/episode-16',
287 'only_matching': True,
289 'url': 'https://www.dplay.jp/video/gold-rush/24086',
290 'only_matching': True,
292 'url': 'https://www.discoveryplus.se/videos/nugammalt-77-handelser-som-format-sverige/nugammalt-77-handelser-som-format-sverige-101',
293 'only_matching': True,
295 'url': 'https://www.discoveryplus.dk/videoer/ted-bundy-mind-of-a-monster/ted-bundy-mind-of-a-monster',
296 'only_matching': True,
298 'url': 'https://www.discoveryplus.no/videoer/i-kongens-klr/sesong-1-episode-7',
299 'only_matching': True,
301 'url': 'https://www.discoveryplus.it/videos/biografie-imbarazzanti/luigi-di-maio-la-psicosi-di-stanislawskij',
302 'only_matching': True,
304 'url': 'https://www.discoveryplus.es/videos/la-fiebre-del-oro/temporada-8-episodio-1',
305 'only_matching': True,
307 'url': 'https://www.discoveryplus.fi/videot/shifting-gears-with-aaron-kaufman/episode-16',
308 'only_matching': True,
311 def _real_extract(self
, url
):
312 mobj
= self
._match
_valid
_url
(url
)
313 display_id
= mobj
.group('id')
314 domain
= mobj
.group('domain').lstrip('www.')
315 country
= mobj
.group('country') or mobj
.group('subdomain_country') or mobj
.group('plus_country')
316 host
= 'disco-api.' + domain
if domain
[0] == 'd' else 'eu2-prod.disco-api.com'
317 return self
._get
_disco
_api
_info
(
318 url
, display_id
, host
, 'dplay' + country
, country
, domain
)
321 class HGTVDeIE(DPlayBaseIE
):
322 _VALID_URL
= r
'https?://de\.hgtv\.com/sendungen' + DPlayBaseIE
._PATH
_REGEX
324 'url': 'https://de.hgtv.com/sendungen/tiny-house-klein-aber-oho/wer-braucht-schon-eine-toilette/',
327 'display_id': 'tiny-house-klein-aber-oho/wer-braucht-schon-eine-toilette',
329 'title': 'Wer braucht schon eine Toilette',
330 'description': 'md5:05b40a27e7aed2c9172de34d459134e2',
331 'duration': 1177.024,
332 'timestamp': 1595705400,
333 'upload_date': '20200725',
335 'series': 'Tiny House - klein, aber oho',
341 def _real_extract(self
, url
):
342 display_id
= self
._match
_id
(url
)
343 return self
._get
_disco
_api
_info
(
344 url
, display_id
, 'eu1-prod.disco-api.com', 'hgtv', 'de')
347 class DiscoveryPlusBaseIE(DPlayBaseIE
):
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 return self
._get
_disco
_api
_info
(url
, self
._match
_id
(url
), **self
._DISCO
_API
_PARAMS
)
369 class GoDiscoveryIE(DiscoveryPlusBaseIE
):
370 _VALID_URL
= r
'https?://(?:go\.)?discovery\.com/video' + DPlayBaseIE
._PATH
_REGEX
372 'url': 'https://go.discovery.com/video/dirty-jobs-discovery-atve-us/rodbuster-galvanizer',
375 'display_id': 'dirty-jobs-discovery-atve-us/rodbuster-galvanizer',
377 'title': 'Rodbuster / Galvanizer',
378 'description': 'Mike installs rebar with a team of rodbusters, then he galvanizes steel.',
382 'skip': 'Available for Premium users',
384 'url': 'https://discovery.com/video/dirty-jobs-discovery-atve-us/rodbuster-galvanizer',
385 'only_matching': True,
389 _DISCO_API_PARAMS
= {
390 'disco_host': 'us1-prod-direct.go.discovery.com',
396 class TravelChannelIE(DiscoveryPlusBaseIE
):
397 _VALID_URL
= r
'https?://(?:watch\.)?travelchannel\.com/video' + DPlayBaseIE
._PATH
_REGEX
399 'url': 'https://watch.travelchannel.com/video/ghost-adventures-travel-channel/ghost-train-of-ely',
402 'display_id': 'ghost-adventures-travel-channel/ghost-train-of-ely',
404 'title': 'Ghost Train of Ely',
405 'description': 'The crew investigates the dark history of the Nevada Northern Railway.',
409 'skip': 'Available for Premium users',
411 'url': 'https://watch.travelchannel.com/video/ghost-adventures-travel-channel/ghost-train-of-ely',
412 'only_matching': True,
416 _DISCO_API_PARAMS
= {
417 'disco_host': 'us1-prod-direct.watch.travelchannel.com',
423 class CookingChannelIE(DiscoveryPlusBaseIE
):
424 _VALID_URL
= r
'https?://(?:watch\.)?cookingchanneltv\.com/video' + DPlayBaseIE
._PATH
_REGEX
426 'url': 'https://watch.cookingchanneltv.com/video/carnival-eats-cooking-channel/the-postman-always-brings-rice-2348634',
429 'display_id': 'carnival-eats-cooking-channel/the-postman-always-brings-rice-2348634',
431 'title': 'The Postman Always Brings Rice',
432 'description': 'Noah visits the Maui Fair and the Aurora Winter Festival in Vancouver.',
436 'skip': 'Available for Premium users',
438 'url': 'https://watch.cookingchanneltv.com/video/carnival-eats-cooking-channel/the-postman-always-brings-rice-2348634',
439 'only_matching': True,
443 _DISCO_API_PARAMS
= {
444 'disco_host': 'us1-prod-direct.watch.cookingchanneltv.com',
450 class HGTVUsaIE(DiscoveryPlusBaseIE
):
451 _VALID_URL
= r
'https?://(?:watch\.)?hgtv\.com/video' + DPlayBaseIE
._PATH
_REGEX
453 'url': 'https://watch.hgtv.com/video/home-inspector-joe-hgtv-atve-us/this-mold-house',
456 'display_id': 'home-inspector-joe-hgtv-atve-us/this-mold-house',
458 'title': 'This Mold House',
459 'description': 'Joe and Noel help take a familys dream home from hazardous to fabulous.',
463 'skip': 'Available for Premium users',
465 'url': 'https://watch.hgtv.com/video/home-inspector-joe-hgtv-atve-us/this-mold-house',
466 'only_matching': True,
470 _DISCO_API_PARAMS
= {
471 'disco_host': 'us1-prod-direct.watch.hgtv.com',
477 class FoodNetworkIE(DiscoveryPlusBaseIE
):
478 _VALID_URL
= r
'https?://(?:watch\.)?foodnetwork\.com/video' + DPlayBaseIE
._PATH
_REGEX
480 'url': 'https://watch.foodnetwork.com/video/kids-baking-championship-food-network/float-like-a-butterfly',
483 'display_id': 'kids-baking-championship-food-network/float-like-a-butterfly',
485 'title': 'Float Like a Butterfly',
486 'description': 'The 12 kid bakers create colorful carved butterfly cakes.',
490 'skip': 'Available for Premium users',
492 'url': 'https://watch.foodnetwork.com/video/kids-baking-championship-food-network/float-like-a-butterfly',
493 'only_matching': True,
497 _DISCO_API_PARAMS
= {
498 'disco_host': 'us1-prod-direct.watch.foodnetwork.com',
504 class DestinationAmericaIE(DiscoveryPlusBaseIE
):
505 _VALID_URL
= r
'https?://(?:www\.)?destinationamerica\.com/video' + DPlayBaseIE
._PATH
_REGEX
507 'url': 'https://www.destinationamerica.com/video/alaska-monsters-destination-america-atve-us/central-alaskas-bigfoot',
510 'display_id': 'alaska-monsters-destination-america-atve-us/central-alaskas-bigfoot',
512 'title': 'Central Alaskas Bigfoot',
513 'description': 'A team heads to central Alaska to investigate an aggressive Bigfoot.',
517 'skip': 'Available for Premium users',
519 'url': 'https://www.destinationamerica.com/video/alaska-monsters-destination-america-atve-us/central-alaskas-bigfoot',
520 'only_matching': True,
524 _DISCO_API_PARAMS
= {
525 'disco_host': 'us1-prod-direct.destinationamerica.com',
531 class InvestigationDiscoveryIE(DiscoveryPlusBaseIE
):
532 _VALID_URL
= r
'https?://(?:www\.)?investigationdiscovery\.com/video' + DPlayBaseIE
._PATH
_REGEX
534 'url': 'https://www.investigationdiscovery.com/video/unmasked-investigation-discovery/the-killer-clown',
537 'display_id': 'unmasked-investigation-discovery/the-killer-clown',
539 'title': 'The Killer Clown',
540 'description': 'A wealthy Florida woman is fatally shot in the face by a clown at her door.',
544 'skip': 'Available for Premium users',
546 'url': 'https://www.investigationdiscovery.com/video/unmasked-investigation-discovery/the-killer-clown',
547 'only_matching': True,
551 _DISCO_API_PARAMS
= {
552 'disco_host': 'us1-prod-direct.investigationdiscovery.com',
558 class AmHistoryChannelIE(DiscoveryPlusBaseIE
):
559 _VALID_URL
= r
'https?://(?:www\.)?ahctv\.com/video' + DPlayBaseIE
._PATH
_REGEX
561 'url': 'https://www.ahctv.com/video/modern-sniper-ahc/army',
564 'display_id': 'modern-sniper-ahc/army',
567 'description': 'Snipers today face challenges their predecessors couldve only dreamed of.',
571 'skip': 'Available for Premium users',
573 'url': 'https://www.ahctv.com/video/modern-sniper-ahc/army',
574 'only_matching': True,
578 _DISCO_API_PARAMS
= {
579 'disco_host': 'us1-prod-direct.ahctv.com',
585 class ScienceChannelIE(DiscoveryPlusBaseIE
):
586 _VALID_URL
= r
'https?://(?:www\.)?sciencechannel\.com/video' + DPlayBaseIE
._PATH
_REGEX
588 'url': 'https://www.sciencechannel.com/video/strangest-things-science-atve-us/nazi-mystery-machine',
591 'display_id': 'strangest-things-science-atve-us/nazi-mystery-machine',
593 'title': 'Nazi Mystery Machine',
594 'description': 'Experts investigate the secrets of a revolutionary encryption machine.',
598 'skip': 'Available for Premium users',
600 'url': 'https://www.sciencechannel.com/video/strangest-things-science-atve-us/nazi-mystery-machine',
601 'only_matching': True,
605 _DISCO_API_PARAMS
= {
606 'disco_host': 'us1-prod-direct.sciencechannel.com',
612 class DIYNetworkIE(DiscoveryPlusBaseIE
):
613 _VALID_URL
= r
'https?://(?:watch\.)?diynetwork\.com/video' + DPlayBaseIE
._PATH
_REGEX
615 'url': 'https://watch.diynetwork.com/video/pool-kings-diy-network/bringing-beach-life-to-texas',
618 'display_id': 'pool-kings-diy-network/bringing-beach-life-to-texas',
620 'title': 'Bringing Beach Life to Texas',
621 'description': 'The Pool Kings give a family a day at the beach in their own backyard.',
625 'skip': 'Available for Premium users',
627 'url': 'https://watch.diynetwork.com/video/pool-kings-diy-network/bringing-beach-life-to-texas',
628 'only_matching': True,
632 _DISCO_API_PARAMS
= {
633 'disco_host': 'us1-prod-direct.watch.diynetwork.com',
639 class DiscoveryLifeIE(DiscoveryPlusBaseIE
):
640 _VALID_URL
= r
'https?://(?:www\.)?discoverylife\.com/video' + DPlayBaseIE
._PATH
_REGEX
642 'url': 'https://www.discoverylife.com/video/surviving-death-discovery-life-atve-us/bodily-trauma',
645 'display_id': 'surviving-death-discovery-life-atve-us/bodily-trauma',
647 'title': 'Bodily Trauma',
648 'description': 'Meet three people who tested the limits of the human body.',
652 'skip': 'Available for Premium users',
654 'url': 'https://www.discoverylife.com/video/surviving-death-discovery-life-atve-us/bodily-trauma',
655 'only_matching': True,
659 _DISCO_API_PARAMS
= {
660 'disco_host': 'us1-prod-direct.discoverylife.com',
666 class AnimalPlanetIE(DiscoveryPlusBaseIE
):
667 _VALID_URL
= r
'https?://(?:www\.)?animalplanet\.com/video' + DPlayBaseIE
._PATH
_REGEX
669 'url': 'https://www.animalplanet.com/video/north-woods-law-animal-planet/squirrel-showdown',
672 'display_id': 'north-woods-law-animal-planet/squirrel-showdown',
674 'title': 'Squirrel Showdown',
675 'description': 'A woman is suspected of being in possession of flying squirrel kits.',
677 'episode_number': 11,
679 'skip': 'Available for Premium users',
681 'url': 'https://www.animalplanet.com/video/north-woods-law-animal-planet/squirrel-showdown',
682 'only_matching': True,
686 _DISCO_API_PARAMS
= {
687 'disco_host': 'us1-prod-direct.animalplanet.com',
693 class TLCIE(DiscoveryPlusBaseIE
):
694 _VALID_URL
= r
'https?://(?:go\.)?tlc\.com/video' + DPlayBaseIE
._PATH
_REGEX
696 'url': 'https://go.tlc.com/video/my-600-lb-life-tlc/melissas-story-part-1',
699 'display_id': 'my-600-lb-life-tlc/melissas-story-part-1',
701 'title': 'Melissas Story (Part 1)',
702 'description': 'At 650 lbs, Melissa is ready to begin her seven-year weight loss journey.',
706 'skip': 'Available for Premium users',
708 'url': 'https://go.tlc.com/video/my-600-lb-life-tlc/melissas-story-part-1',
709 'only_matching': True,
713 _DISCO_API_PARAMS
= {
714 'disco_host': 'us1-prod-direct.tlc.com',
720 class DiscoveryPlusIE(DiscoveryPlusBaseIE
):
721 _VALID_URL
= r
'https?://(?:www\.)?discoveryplus\.com/(?!it/)(?:\w{2}/)?video' + DPlayBaseIE
._PATH
_REGEX
723 'url': 'https://www.discoveryplus.com/video/property-brothers-forever-home/food-and-family',
726 'display_id': 'property-brothers-forever-home/food-and-family',
728 'title': 'Food and Family',
729 'description': 'The brothers help a Richmond family expand their single-level home.',
730 'duration': 2583.113,
731 'timestamp': 1609304400,
732 'upload_date': '20201230',
734 'series': 'Property Brothers: Forever Home',
738 'skip': 'Available for Premium users',
740 'url': 'https://discoveryplus.com/ca/video/bering-sea-gold-discovery-ca/goldslingers',
741 'only_matching': True,
744 _PRODUCT
= 'dplus_us'
745 _DISCO_API_PARAMS
= {
746 'disco_host': 'us1-prod-direct.discoveryplus.com',
752 class DiscoveryPlusIndiaIE(DiscoveryPlusBaseIE
):
753 _VALID_URL
= r
'https?://(?:www\.)?discoveryplus\.in/videos?' + DPlayBaseIE
._PATH
_REGEX
755 'url': 'https://www.discoveryplus.in/videos/how-do-they-do-it/fugu-and-more?seasonId=8&type=EPISODE',
759 'display_id': 'how-do-they-do-it/fugu-and-more',
760 'title': 'Fugu and More',
761 'description': 'The Japanese catch, prepare and eat the deadliest fish on the planet.',
763 'timestamp': 1582309800,
764 'upload_date': '20200221',
765 'series': 'How Do They Do It?',
768 'creator': 'Discovery Channel',
769 'thumbnail': r
're:https://.+\.jpeg',
770 'episode': 'Episode 2',
771 'season': 'Season 8',
775 'skip_download': True,
779 _PRODUCT
= 'dplus-india'
780 _DISCO_API_PARAMS
= {
781 'disco_host': 'ap2-prod-direct.discoveryplus.in',
782 'realm': 'dplusindia',
784 'domain': 'https://www.discoveryplus.in/',
787 def _update_disco_api_headers(self
, headers
, disco_base
, display_id
, realm
):
789 'x-disco-params': 'realm=%s' % realm
,
790 'x-disco-client': f
'WEB:UNKNOWN:{self._PRODUCT}:17.0.0',
791 'Authorization': self
._get
_auth
(disco_base
, display_id
, realm
),
795 class DiscoveryNetworksDeIE(DPlayBaseIE
):
796 _VALID_URL
= r
'https?://(?:www\.)?(?P<domain>(?:tlc|dmax)\.de|dplay\.co\.uk)/(?:programme|show|sendungen)/(?P<programme>[^/]+)/(?:video/)?(?P<alternate_id>[^/]+)'
799 'url': 'https://www.tlc.de/programme/breaking-amish/video/die-welt-da-drauen/DCB331270001100',
803 'title': 'Die Welt da draußen',
804 'description': 'md5:61033c12b73286e409d99a41742ef608',
805 'timestamp': 1554069600,
806 'upload_date': '20190331',
808 'season': 'Season 1',
809 'series': 'Breaking Amish',
811 'tags': ['new york', 'großstadt', 'amische', 'landleben', 'modern', 'infos', 'tradition', 'herausforderung'],
812 'display_id': 'breaking-amish/die-welt-da-drauen',
813 'episode': 'Episode 1',
814 'duration': 2625.024,
816 'thumbnail': r
're:https://.+\.jpg',
819 'skip_download': True,
822 'url': 'https://www.dmax.de/programme/dmax-highlights/video/tuning-star-sidney-hoffmann-exklusiv-bei-dmax/191023082312316',
823 'only_matching': True,
825 'url': 'https://www.dplay.co.uk/show/ghost-adventures/video/hotel-leger-103620/EHD_280313B',
826 'only_matching': True,
828 'url': 'https://tlc.de/sendungen/breaking-amish/die-welt-da-drauen/',
829 'only_matching': True,
832 def _real_extract(self
, url
):
833 domain
, programme
, alternate_id
= self
._match
_valid
_url
(url
).groups()
834 country
= 'GB' if domain
== 'dplay.co.uk' else 'DE'
835 realm
= 'questuk' if country
== 'GB' else domain
.replace('.', '')
836 return self
._get
_disco
_api
_info
(
837 url
, '%s/%s' % (programme
, alternate_id
),
838 'sonic-eu1-prod.disco-api.com', realm
, country
)
841 class DiscoveryPlusShowBaseIE(DPlayBaseIE
):
843 def _entries(self
, show_name
):
845 'x-disco-client': self
._X
_CLIENT
,
846 'x-disco-params': f
'realm={self._REALM}',
847 'referer': self
._DOMAIN
,
848 'Authentication': self
._get
_auth
(self
._BASE
_API
, None, self
._REALM
),
850 show_json
= self
._download
_json
(
851 f
'{self._BASE_API}cms/routes/{self._SHOW_STR}/{show_name}?include=default',
852 video_id
=show_name
, headers
=headers
)['included'][self
._INDEX
]['attributes']['component']
853 show_id
= show_json
['mandatoryParams'].split('=')[-1]
854 season_url
= self
._BASE
_API
+ 'content/videos?sort=episodeNumber&filter[seasonNumber]={}&filter[show.id]={}&page[size]=100&page[number]={}'
855 for season
in show_json
['filters'][0]['options']:
856 season_id
= season
['id']
857 total_pages
, page_num
= 1, 0
858 while page_num
< total_pages
:
859 season_json
= self
._download
_json
(
860 season_url
.format(season_id
, show_id
, str(page_num
+ 1)), show_name
, headers
=headers
,
861 note
='Downloading season %s JSON metadata%s' % (season_id
, ' page %d' % page_num
if page_num
else ''))
863 total_pages
= try_get(season_json
, lambda x
: x
['meta']['totalPages'], int) or 1
864 episodes_json
= season_json
['data']
865 for episode
in episodes_json
:
866 video_path
= episode
['attributes']['path']
867 yield self
.url_result(
868 '%svideos/%s' % (self
._DOMAIN
, video_path
),
869 ie
=self
._VIDEO
_IE
.ie_key(), video_id
=episode
.get('id') or video_path
)
872 def _real_extract(self
, url
):
873 show_name
= self
._match
_valid
_url
(url
).group('show_name')
874 return self
.playlist_result(self
._entries
(show_name
), playlist_id
=show_name
)
877 class DiscoveryPlusItalyIE(DiscoveryPlusBaseIE
):
878 _VALID_URL
= r
'https?://(?:www\.)?discoveryplus\.com/it/video' + DPlayBaseIE
._PATH
_REGEX
880 'url': 'https://www.discoveryplus.com/it/video/i-signori-della-neve/stagione-2-episodio-1-i-preparativi',
881 'only_matching': True,
884 _PRODUCT
= 'dplus_us'
885 _DISCO_API_PARAMS
= {
886 'disco_host': 'eu1-prod-direct.discoveryplus.com',
892 class DiscoveryPlusItalyShowIE(DiscoveryPlusShowBaseIE
):
893 _VALID_URL
= r
'https?://(?:www\.)?discoveryplus\.it/programmi/(?P<show_name>[^/]+)/?(?:[?#]|$)'
895 'url': 'https://www.discoveryplus.it/programmi/deal-with-it-stai-al-gioco',
896 'playlist_mincount': 168,
898 'id': 'deal-with-it-stai-al-gioco',
902 _BASE_API
= 'https://disco-api.discoveryplus.it/'
903 _DOMAIN
= 'https://www.discoveryplus.it/'
904 _X_CLIENT
= 'WEB:UNKNOWN:dplay-client:2.6.0'
906 _SHOW_STR
= 'programmi'
911 class DiscoveryPlusIndiaShowIE(DiscoveryPlusShowBaseIE
):
912 _VALID_URL
= r
'https?://(?:www\.)?discoveryplus\.in/show/(?P<show_name>[^/]+)/?(?:[?#]|$)'
914 'url': 'https://www.discoveryplus.in/show/how-do-they-do-it',
915 'playlist_mincount': 140,
917 'id': 'how-do-they-do-it',
921 _BASE_API
= 'https://ap2-prod-direct.discoveryplus.in/'
922 _DOMAIN
= 'https://www.discoveryplus.in/'
923 _X_CLIENT
= 'WEB:UNKNOWN:dplus-india:prod'
924 _REALM
= 'dplusindia'
927 _VIDEO_IE
= DiscoveryPlusIndiaIE