4 from .common
import InfoExtractor
5 from ..networking
.exceptions
import 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
.response
.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 country
= self
.get_param('geo_bypass_country') or country
69 geo_countries
= [country
.upper()]
70 self
._initialize
_geo
_bypass
({
71 'countries': geo_countries
,
73 disco_base
= f
'https://{disco_host}/'
77 self
._update
_disco
_api
_headers
(headers
, disco_base
, display_id
, realm
)
79 video
= self
._download
_json
(
80 disco_base
+ 'content/videos/' + display_id
, display_id
,
81 headers
=headers
, query
={
82 'fields[channel]': 'name',
83 'fields[image]': 'height,src,width',
84 'fields[show]': 'name',
85 'fields[tag]': 'name',
86 'fields[video]': 'description,episodeNumber,name,publishStart,seasonNumber,videoDuration',
87 'include': 'images,primaryChannel,show,tags',
89 except ExtractorError
as e
:
90 if isinstance(e
.cause
, HTTPError
) and e
.cause
.status
== 400:
91 self
._process
_errors
(e
, geo_countries
)
93 video_id
= video
['data']['id']
94 info
= video
['data']['attributes']
95 title
= info
['name'].strip()
99 streaming
= self
._download
_video
_playback
_info
(
100 disco_base
, video_id
, headers
)
101 except ExtractorError
as e
:
102 if isinstance(e
.cause
, HTTPError
) and e
.cause
.status
== 403:
103 self
._process
_errors
(e
, geo_countries
)
105 for format_dict
in streaming
:
106 if not isinstance(format_dict
, dict):
108 format_url
= format_dict
.get('url')
111 format_id
= format_dict
.get('type')
112 ext
= determine_ext(format_url
)
113 if format_id
== 'dash' or ext
== 'mpd':
114 dash_fmts
, dash_subs
= self
._extract
_mpd
_formats
_and
_subtitles
(
115 format_url
, display_id
, mpd_id
='dash', fatal
=False)
116 formats
.extend(dash_fmts
)
117 subtitles
= self
._merge
_subtitles
(subtitles
, dash_subs
)
118 elif format_id
== 'hls' or ext
== 'm3u8':
119 m3u8_fmts
, m3u8_subs
= self
._extract
_m
3u8_formats
_and
_subtitles
(
120 format_url
, display_id
, 'mp4',
121 entry_protocol
='m3u8_native', m3u8_id
='hls',
123 formats
.extend(m3u8_fmts
)
124 subtitles
= self
._merge
_subtitles
(subtitles
, m3u8_subs
)
128 'format_id': format_id
,
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 """Subclasses must set _PRODUCT, _DISCO_API_PARAMS"""
351 _DISCO_CLIENT_VER
= '27.43.0'
353 def _update_disco_api_headers(self
, headers
, disco_base
, display_id
, realm
):
355 'x-disco-params': f
'realm={realm},siteLookupKey={self._PRODUCT}',
356 'x-disco-client': f
'WEB:UNKNOWN:{self._PRODUCT}:{self._DISCO_CLIENT_VER}',
357 'Authorization': self
._get
_auth
(disco_base
, display_id
, realm
),
360 def _download_video_playback_info(self
, disco_base
, video_id
, headers
):
361 return self
._download
_json
(
362 disco_base
+ 'playback/v3/videoPlaybackInfo',
363 video_id
, headers
=headers
, data
=json
.dumps({
366 'drmSupported': False,
369 'wisteriaProperties': {},
370 }).encode())['data']['attributes']['streaming']
372 def _real_extract(self
, url
):
373 return self
._get
_disco
_api
_info
(url
, self
._match
_id
(url
), **self
._DISCO
_API
_PARAMS
)
376 class GoDiscoveryIE(DiscoveryPlusBaseIE
):
377 _VALID_URL
= r
'https?://(?:go\.)?discovery\.com/video' + DPlayBaseIE
._PATH
_REGEX
379 'url': 'https://go.discovery.com/video/in-the-eye-of-the-storm-discovery-atve-us/trapped-in-a-twister',
382 'display_id': 'in-the-eye-of-the-storm-discovery-atve-us/trapped-in-a-twister',
384 'title': 'Trapped in a Twister',
385 'description': 'Twisters destroy Midwest towns, trapping spotters in the eye of the storm.',
387 'episode': 'Episode 1',
389 'season': 'Season 1',
390 'series': 'In The Eye Of The Storm',
391 'duration': 2490.237,
392 'upload_date': '20240715',
393 'timestamp': 1721008800,
395 'creators': ['Discovery'],
396 'thumbnail': 'https://us1-prod-images.disco-api.com/2024/07/10/5e39637d-cabf-3ab3-8e9a-f4e9d37bc036.jpeg',
399 'url': 'https://go.discovery.com/video/dirty-jobs-discovery-atve-us/rodbuster-galvanizer',
402 'display_id': 'dirty-jobs-discovery-atve-us/rodbuster-galvanizer',
404 'title': 'Rodbuster / Galvanizer',
405 'description': 'Mike installs rebar with a team of rodbusters, then he galvanizes steel.',
409 'skip': 'Available for Premium users',
411 'url': 'https://discovery.com/video/dirty-jobs-discovery-atve-us/rodbuster-galvanizer',
412 'only_matching': True,
416 _DISCO_API_PARAMS
= {
417 'disco_host': 'us1-prod-direct.go.discovery.com',
423 class TravelChannelIE(DiscoveryPlusBaseIE
):
424 _VALID_URL
= r
'https?://(?:watch\.)?travelchannel\.com/video' + DPlayBaseIE
._PATH
_REGEX
426 'url': 'https://watch.travelchannel.com/video/the-dead-files-travel-channel/protect-the-children',
429 'display_id': 'the-dead-files-travel-channel/protect-the-children',
431 'title': 'Protect the Children',
432 'description': 'An evil presence threatens an Ohio woman\'s children and marriage.',
434 'season': 'Season 14',
435 'episode_number': 10,
436 'episode': 'Episode 10',
437 'series': 'The Dead Files',
438 'duration': 2550.481,
439 'timestamp': 1664510400,
440 'upload_date': '20220930',
442 'creators': ['Travel Channel'],
443 'thumbnail': 'https://us1-prod-images.disco-api.com/2022/03/17/5e45eace-de5d-343a-9293-f400a2aa77d5.jpeg',
446 'url': 'https://watch.travelchannel.com/video/ghost-adventures-travel-channel/ghost-train-of-ely',
449 'display_id': 'ghost-adventures-travel-channel/ghost-train-of-ely',
451 'title': 'Ghost Train of Ely',
452 'description': 'The crew investigates the dark history of the Nevada Northern Railway.',
456 'skip': 'Available for Premium users',
458 'url': 'https://watch.travelchannel.com/video/ghost-adventures-travel-channel/ghost-train-of-ely',
459 'only_matching': True,
463 _DISCO_API_PARAMS
= {
464 'disco_host': 'us1-prod-direct.watch.travelchannel.com',
470 class CookingChannelIE(DiscoveryPlusBaseIE
):
471 _VALID_URL
= r
'https?://(?:watch\.)?cookingchanneltv\.com/video' + DPlayBaseIE
._PATH
_REGEX
473 'url': 'https://watch.cookingchanneltv.com/video/bobbys-triple-threat-food-network-atve-us/titans-vs-marcus-samuelsson',
477 'display_id': 'bobbys-triple-threat-food-network-atve-us/titans-vs-marcus-samuelsson',
478 'title': 'Titans vs Marcus Samuelsson',
479 'description': 'Marcus Samuelsson throws his legendary global tricks at the Titans.',
481 'episode': 'Episode 1',
483 'season': 'Season 3',
484 'series': 'Bobby\'s Triple Threat',
485 'duration': 2520.851,
486 'upload_date': '20240710',
487 'timestamp': 1720573200,
489 'creators': ['Food Network'],
490 'thumbnail': 'https://us1-prod-images.disco-api.com/2024/07/04/529cd095-27ec-35c5-84e9-90ebd3e5d2da.jpeg',
493 'url': 'https://watch.cookingchanneltv.com/video/carnival-eats-cooking-channel/the-postman-always-brings-rice-2348634',
496 'display_id': 'carnival-eats-cooking-channel/the-postman-always-brings-rice-2348634',
498 'title': 'The Postman Always Brings Rice',
499 'description': 'Noah visits the Maui Fair and the Aurora Winter Festival in Vancouver.',
503 'skip': 'Available for Premium users',
505 'url': 'https://watch.cookingchanneltv.com/video/carnival-eats-cooking-channel/the-postman-always-brings-rice-2348634',
506 'only_matching': True,
510 _DISCO_API_PARAMS
= {
511 'disco_host': 'us1-prod-direct.watch.cookingchanneltv.com',
517 class HGTVUsaIE(DiscoveryPlusBaseIE
):
518 _VALID_URL
= r
'https?://(?:watch\.)?hgtv\.com/video' + DPlayBaseIE
._PATH
_REGEX
520 'url': 'https://watch.hgtv.com/video/flip-or-flop-the-final-flip-hgtv-atve-us/flip-or-flop-the-final-flip',
523 'display_id': 'flip-or-flop-the-final-flip-hgtv-atve-us/flip-or-flop-the-final-flip',
525 'title': 'Flip or Flop: The Final Flip',
526 'description': 'Tarek and Christina are going their separate ways after one last flip!',
527 'series': 'Flip or Flop: The Final Flip',
528 'duration': 2580.644,
529 'upload_date': '20231101',
530 'timestamp': 1698811200,
532 'creators': ['HGTV'],
533 'thumbnail': 'https://us1-prod-images.disco-api.com/2022/11/27/455caa6c-1462-3f14-b63d-a026d7a5e6d3.jpeg',
536 'url': 'https://watch.hgtv.com/video/home-inspector-joe-hgtv-atve-us/this-mold-house',
539 'display_id': 'home-inspector-joe-hgtv-atve-us/this-mold-house',
541 'title': 'This Mold House',
542 'description': 'Joe and Noel help take a familys dream home from hazardous to fabulous.',
546 'skip': 'Available for Premium users',
548 'url': 'https://watch.hgtv.com/video/home-inspector-joe-hgtv-atve-us/this-mold-house',
549 'only_matching': True,
553 _DISCO_API_PARAMS
= {
554 'disco_host': 'us1-prod-direct.watch.hgtv.com',
560 class FoodNetworkIE(DiscoveryPlusBaseIE
):
561 _VALID_URL
= r
'https?://(?:watch\.)?foodnetwork\.com/video' + DPlayBaseIE
._PATH
_REGEX
563 'url': 'https://watch.foodnetwork.com/video/guys-grocery-games-food-network/wild-in-the-aisles',
566 'display_id': 'guys-grocery-games-food-network/wild-in-the-aisles',
568 'title': 'Wild in the Aisles',
569 'description': 'The chefs make spaghetti and meatballs with "Out of Stock" ingredients.',
571 'season': 'Season 1',
573 'episode': 'Episode 1',
574 'series': 'Guy\'s Grocery Games',
576 'creators': ['Food Network'],
577 'duration': 2520.651,
578 'upload_date': '20230623',
579 'timestamp': 1687492800,
580 'thumbnail': 'https://us1-prod-images.disco-api.com/2022/06/15/37fb5333-cad2-3dbb-af7c-c20ec77c89c6.jpeg',
583 'url': 'https://watch.foodnetwork.com/video/kids-baking-championship-food-network/float-like-a-butterfly',
586 'display_id': 'kids-baking-championship-food-network/float-like-a-butterfly',
588 'title': 'Float Like a Butterfly',
589 'description': 'The 12 kid bakers create colorful carved butterfly cakes.',
593 'skip': 'Available for Premium users',
595 'url': 'https://watch.foodnetwork.com/video/kids-baking-championship-food-network/float-like-a-butterfly',
596 'only_matching': True,
600 _DISCO_API_PARAMS
= {
601 'disco_host': 'us1-prod-direct.watch.foodnetwork.com',
607 class DestinationAmericaIE(DiscoveryPlusBaseIE
):
608 _VALID_URL
= r
'https?://(?:www\.)?destinationamerica\.com/video' + DPlayBaseIE
._PATH
_REGEX
610 'url': 'https://www.destinationamerica.com/video/bbq-pit-wars-destination-america/smoke-on-the-water',
613 'display_id': 'bbq-pit-wars-destination-america/smoke-on-the-water',
615 'title': 'Smoke on the Water',
616 'description': 'The pitmasters head to Georgia for the Smoke on the Water BBQ Festival.',
618 'season': 'Season 2',
620 'episode': 'Episode 1',
621 'series': 'BBQ Pit Wars',
623 'creators': ['Destination America'],
624 'duration': 2614.878,
625 'upload_date': '20230623',
626 'timestamp': 1687492800,
627 'thumbnail': 'https://us1-prod-images.disco-api.com/2020/05/11/c0f8e85d-9a10-3e6f-8e43-f6faafa81ba2.jpeg',
630 'url': 'https://www.destinationamerica.com/video/alaska-monsters-destination-america-atve-us/central-alaskas-bigfoot',
633 'display_id': 'alaska-monsters-destination-america-atve-us/central-alaskas-bigfoot',
635 'title': 'Central Alaskas Bigfoot',
636 'description': 'A team heads to central Alaska to investigate an aggressive Bigfoot.',
640 'skip': 'Available for Premium users',
642 'url': 'https://www.destinationamerica.com/video/alaska-monsters-destination-america-atve-us/central-alaskas-bigfoot',
643 'only_matching': True,
647 _DISCO_API_PARAMS
= {
648 'disco_host': 'us1-prod-direct.destinationamerica.com',
654 class InvestigationDiscoveryIE(DiscoveryPlusBaseIE
):
655 _VALID_URL
= r
'https?://(?:www\.)?investigationdiscovery\.com/video' + DPlayBaseIE
._PATH
_REGEX
657 'url': 'https://www.investigationdiscovery.com/video/deadly-influence-the-social-media-murders-investigation-discovery-atve-us/rip-bianca',
660 'display_id': 'deadly-influence-the-social-media-murders-investigation-discovery-atve-us/rip-bianca',
662 'title': 'RIP Bianca',
663 'description': 'A teenage influencer discovers an online world of threat, harm and danger.',
665 'season': 'Season 1',
667 'episode': 'Episode 3',
668 'series': 'Deadly Influence: The Social Media Murders',
669 'creators': ['Investigation Discovery'],
671 'duration': 2490.888,
672 'upload_date': '20240618',
673 'timestamp': 1718672400,
674 'thumbnail': 'https://us1-prod-images.disco-api.com/2024/06/15/b567c774-9e44-3c6c-b0ba-db860a73e812.jpeg',
677 'url': 'https://www.investigationdiscovery.com/video/unmasked-investigation-discovery/the-killer-clown',
680 'display_id': 'unmasked-investigation-discovery/the-killer-clown',
682 'title': 'The Killer Clown',
683 'description': 'A wealthy Florida woman is fatally shot in the face by a clown at her door.',
687 'skip': 'Available for Premium users',
689 'url': 'https://www.investigationdiscovery.com/video/unmasked-investigation-discovery/the-killer-clown',
690 'only_matching': True,
694 _DISCO_API_PARAMS
= {
695 'disco_host': 'us1-prod-direct.investigationdiscovery.com',
701 class AmHistoryChannelIE(DiscoveryPlusBaseIE
):
702 _VALID_URL
= r
'https?://(?:www\.)?ahctv\.com/video' + DPlayBaseIE
._PATH
_REGEX
704 'url': 'https://www.ahctv.com/video/blood-and-fury-americas-civil-war-ahc/battle-of-bull-run',
707 'display_id': 'blood-and-fury-americas-civil-war-ahc/battle-of-bull-run',
709 'title': 'Battle of Bull Run',
710 'description': 'Two untested armies clash in the first real battle of the Civil War.',
712 'season': 'Season 1',
714 'episode': 'Episode 1',
715 'series': 'Blood and Fury: America\'s Civil War',
716 'duration': 2612.509,
717 'upload_date': '20220923',
718 'timestamp': 1663905600,
721 'thumbnail': 'https://us1-prod-images.disco-api.com/2020/05/11/4af61bd7-d705-3108-82c4-1a6e541e20fa.jpeg',
724 'url': 'https://www.ahctv.com/video/modern-sniper-ahc/army',
727 'display_id': 'modern-sniper-ahc/army',
730 'description': 'Snipers today face challenges their predecessors couldve only dreamed of.',
734 'skip': 'Available for Premium users',
736 'url': 'https://www.ahctv.com/video/modern-sniper-ahc/army',
737 'only_matching': True,
741 _DISCO_API_PARAMS
= {
742 'disco_host': 'us1-prod-direct.ahctv.com',
748 class ScienceChannelIE(DiscoveryPlusBaseIE
):
749 _VALID_URL
= r
'https?://(?:www\.)?sciencechannel\.com/video' + DPlayBaseIE
._PATH
_REGEX
751 'url': 'https://www.sciencechannel.com/video/spaces-deepest-secrets-science-atve-us/mystery-of-the-dead-planets',
754 'display_id': 'spaces-deepest-secrets-science-atve-us/mystery-of-the-dead-planets',
756 'title': 'Mystery of the Dead Planets',
757 'description': 'Astronomers unmask the truly destructive nature of the cosmos.',
759 'season': 'Season 7',
761 'episode': 'Episode 1',
762 'series': 'Space\'s Deepest Secrets',
763 'duration': 2524.989,
764 'upload_date': '20230128',
765 'timestamp': 1674882000,
766 'creators': ['Science'],
768 'thumbnail': 'https://us1-prod-images.disco-api.com/2021/03/30/3796829d-aead-3f9a-bd8d-e49048b3cdca.jpeg',
771 'url': 'https://www.sciencechannel.com/video/strangest-things-science-atve-us/nazi-mystery-machine',
774 'display_id': 'strangest-things-science-atve-us/nazi-mystery-machine',
776 'title': 'Nazi Mystery Machine',
777 'description': 'Experts investigate the secrets of a revolutionary encryption machine.',
781 'skip': 'Available for Premium users',
783 'url': 'https://www.sciencechannel.com/video/strangest-things-science-atve-us/nazi-mystery-machine',
784 'only_matching': True,
788 _DISCO_API_PARAMS
= {
789 'disco_host': 'us1-prod-direct.sciencechannel.com',
795 class DiscoveryLifeIE(DiscoveryPlusBaseIE
):
796 _VALID_URL
= r
'https?://(?:www\.)?discoverylife\.com/video' + DPlayBaseIE
._PATH
_REGEX
798 'url': 'https://www.discoverylife.com/video/er-files-discovery-life-atve-us/sweet-charity',
801 'display_id': 'er-files-discovery-life-atve-us/sweet-charity',
803 'title': 'Sweet Charity',
804 'description': 'The staff at Charity Hospital treat a serious foot infection.',
806 'season': 'Season 1',
808 'episode': 'Episode 1',
809 'series': 'ER Files',
810 'duration': 2364.261,
811 'upload_date': '20230721',
812 'timestamp': 1689912000,
813 'creators': ['Discovery Life'],
815 'thumbnail': 'https://us1-prod-images.disco-api.com/2021/03/16/4b6f0124-360b-3546-b6a4-5552db886b86.jpeg',
818 'url': 'https://www.discoverylife.com/video/surviving-death-discovery-life-atve-us/bodily-trauma',
821 'display_id': 'surviving-death-discovery-life-atve-us/bodily-trauma',
823 'title': 'Bodily Trauma',
824 'description': 'Meet three people who tested the limits of the human body.',
828 'skip': 'Available for Premium users',
830 'url': 'https://www.discoverylife.com/video/surviving-death-discovery-life-atve-us/bodily-trauma',
831 'only_matching': True,
835 _DISCO_API_PARAMS
= {
836 'disco_host': 'us1-prod-direct.discoverylife.com',
842 class AnimalPlanetIE(DiscoveryPlusBaseIE
):
843 _VALID_URL
= r
'https?://(?:www\.)?animalplanet\.com/video' + DPlayBaseIE
._PATH
_REGEX
845 'url': 'https://www.animalplanet.com/video/mysterious-creatures-with-forrest-galante-animal-planet-atve-us/the-demon-of-peru',
848 'display_id': 'mysterious-creatures-with-forrest-galante-animal-planet-atve-us/the-demon-of-peru',
850 'title': 'The Demon of Peru',
851 'description': 'In Peru, a farming village is being terrorized by a “man-like beast.”',
853 'season': 'Season 1',
855 'episode': 'Episode 4',
856 'series': 'Mysterious Creatures with Forrest Galante',
857 'duration': 2490.488,
858 'upload_date': '20230111',
859 'timestamp': 1673413200,
860 'creators': ['Animal Planet'],
862 'thumbnail': 'https://us1-prod-images.disco-api.com/2022/03/01/6dbaa833-9a2e-3fee-9381-c19eddf67c0c.jpeg',
865 'url': 'https://www.animalplanet.com/video/north-woods-law-animal-planet/squirrel-showdown',
868 'display_id': 'north-woods-law-animal-planet/squirrel-showdown',
870 'title': 'Squirrel Showdown',
871 'description': 'A woman is suspected of being in possession of flying squirrel kits.',
873 'episode_number': 11,
875 'skip': 'Available for Premium users',
877 'url': 'https://www.animalplanet.com/video/north-woods-law-animal-planet/squirrel-showdown',
878 'only_matching': True,
882 _DISCO_API_PARAMS
= {
883 'disco_host': 'us1-prod-direct.animalplanet.com',
889 class TLCIE(DiscoveryPlusBaseIE
):
890 _VALID_URL
= r
'https?://(?:go\.)?tlc\.com/video' + DPlayBaseIE
._PATH
_REGEX
892 'url': 'https://go.tlc.com/video/90-day-the-last-resort-tlc-atve-us/the-last-chance',
895 'display_id': '90-day-the-last-resort-tlc-atve-us/the-last-chance',
897 'title': 'The Last Chance',
898 'description': 'Infidelity shakes Kalani and Asuelu\'s world, and Angela threatens divorce.',
900 'season': 'Season 1',
902 'episode': 'Episode 1',
903 'series': '90 Day: The Last Resort',
905 'upload_date': '20230815',
906 'timestamp': 1692061200,
909 'thumbnail': 'https://us1-prod-images.disco-api.com/2023/08/08/0ee367e2-ac76-334d-bf23-dbf796696a24.jpeg',
912 'url': 'https://go.tlc.com/video/my-600-lb-life-tlc/melissas-story-part-1',
915 'display_id': 'my-600-lb-life-tlc/melissas-story-part-1',
917 'title': 'Melissas Story (Part 1)',
918 'description': 'At 650 lbs, Melissa is ready to begin her seven-year weight loss journey.',
922 'skip': 'Available for Premium users',
924 'url': 'https://go.tlc.com/video/my-600-lb-life-tlc/melissas-story-part-1',
925 'only_matching': True,
929 _DISCO_API_PARAMS
= {
930 'disco_host': 'us1-prod-direct.tlc.com',
936 class DiscoveryPlusIE(DiscoveryPlusBaseIE
):
937 _VALID_URL
= r
'https?://(?:www\.)?discoveryplus\.com/(?!it/)(?:(?P<country>[a-z]{2})/)?video(?:/sport)?' + DPlayBaseIE
._PATH
_REGEX
939 'url': 'https://www.discoveryplus.com/video/property-brothers-forever-home/food-and-family',
942 'display_id': 'property-brothers-forever-home/food-and-family',
944 'title': 'Food and Family',
945 'description': 'The brothers help a Richmond family expand their single-level home.',
946 'duration': 2583.113,
947 'timestamp': 1609304400,
948 'upload_date': '20201230',
950 'series': 'Property Brothers: Forever Home',
954 'skip': 'Available for Premium users',
956 'url': 'https://discoveryplus.com/ca/video/bering-sea-gold-discovery-ca/goldslingers',
957 'only_matching': True,
959 'url': 'https://www.discoveryplus.com/gb/video/sport/eurosport-1-british-eurosport-1-british-sport/6-hours-of-spa-review',
960 'only_matching': True,
964 _DISCO_API_PARAMS
= None
966 def _update_disco_api_headers(self
, headers
, disco_base
, display_id
, realm
):
968 'x-disco-params': f
'realm={realm},siteLookupKey={self._PRODUCT}',
969 'x-disco-client': f
'WEB:UNKNOWN:dplus_us:{self._DISCO_CLIENT_VER}',
970 'Authorization': self
._get
_auth
(disco_base
, display_id
, realm
),
973 def _real_extract(self
, url
):
974 video_id
, country
= self
._match
_valid
_url
(url
).group('id', 'country')
978 self
._PRODUCT
= f
'dplus_{country}'
980 if country
in ('br', 'ca', 'us'):
981 self
._DISCO
_API
_PARAMS
= {
982 'disco_host': 'us1-prod-direct.discoveryplus.com',
987 self
._DISCO
_API
_PARAMS
= {
988 'disco_host': 'eu1-prod-direct.discoveryplus.com',
993 return self
._get
_disco
_api
_info
(url
, video_id
, **self
._DISCO
_API
_PARAMS
)
996 class DiscoveryPlusIndiaIE(DiscoveryPlusBaseIE
):
997 _VALID_URL
= r
'https?://(?:www\.)?discoveryplus\.in/videos?' + DPlayBaseIE
._PATH
_REGEX
999 'url': 'https://www.discoveryplus.in/videos/how-do-they-do-it/fugu-and-more?seasonId=8&type=EPISODE',
1003 'display_id': 'how-do-they-do-it/fugu-and-more',
1004 'title': 'Fugu and More',
1005 'description': 'The Japanese catch, prepare and eat the deadliest fish on the planet.',
1006 'duration': 1319.32,
1007 'timestamp': 1582309800,
1008 'upload_date': '20200221',
1009 'series': 'How Do They Do It?',
1011 'episode_number': 2,
1012 'creator': 'Discovery Channel',
1013 'thumbnail': r
're:https://.+\.jpeg',
1014 'episode': 'Episode 2',
1015 'season': 'Season 8',
1019 'skip_download': True,
1023 _PRODUCT
= 'dplus-india'
1024 _DISCO_API_PARAMS
= {
1025 'disco_host': 'ap2-prod-direct.discoveryplus.in',
1026 'realm': 'dplusindia',
1028 'domain': 'https://www.discoveryplus.in/',
1031 def _update_disco_api_headers(self
, headers
, disco_base
, display_id
, realm
):
1033 'x-disco-params': f
'realm={realm}',
1034 'x-disco-client': f
'WEB:UNKNOWN:{self._PRODUCT}:17.0.0',
1035 'Authorization': self
._get
_auth
(disco_base
, display_id
, realm
),
1039 class DiscoveryNetworksDeIE(DiscoveryPlusBaseIE
):
1040 _VALID_URL
= r
'https?://(?:www\.)?(?P<domain>(?:tlc|dmax)\.de|dplay\.co\.uk)/(?:programme|show|sendungen)/(?P<programme>[^/]+)/(?:video/)?(?P<alternate_id>[^/]+)'
1043 'url': 'https://dmax.de/sendungen/goldrausch-in-australien/german-gold',
1047 'title': 'German Gold',
1048 'description': 'md5:f3073306553a8d9b40e6ac4cdbf09fc6',
1049 'display_id': 'goldrausch-in-australien/german-gold',
1050 'episode': 'Episode 1',
1051 'episode_number': 1,
1052 'season': 'Season 5',
1054 'series': 'Goldrausch in Australien',
1056 'upload_date': '20230517',
1057 'timestamp': 1684357500,
1058 'creators': ['DMAX'],
1059 'thumbnail': 'https://eu1-prod-images.disco-api.com/2023/05/09/f72fb510-7992-3b12-af7f-f16a2c22d1e3.jpeg',
1060 'tags': ['schatzsucher', 'schatz', 'nugget', 'bodenschätze', 'down under', 'australien', 'goldrausch'],
1062 'params': {'skip_download': 'm3u8'},
1064 'url': 'https://www.tlc.de/programme/breaking-amish/video/die-welt-da-drauen/DCB331270001100',
1068 'title': 'Die Welt da draußen',
1069 'description': 'md5:61033c12b73286e409d99a41742ef608',
1070 'timestamp': 1554069600,
1071 'upload_date': '20190331',
1073 'season': 'Season 1',
1074 'series': 'Breaking Amish',
1075 'episode_number': 1,
1076 'tags': ['new york', 'großstadt', 'amische', 'landleben', 'modern', 'infos', 'tradition', 'herausforderung'],
1077 'display_id': 'breaking-amish/die-welt-da-drauen',
1078 'episode': 'Episode 1',
1079 'duration': 2625.024,
1081 'thumbnail': r
're:https://.+\.jpg',
1083 'skip': '404 Not Found',
1085 'url': 'https://www.dmax.de/programme/dmax-highlights/video/tuning-star-sidney-hoffmann-exklusiv-bei-dmax/191023082312316',
1086 'only_matching': True,
1088 'url': 'https://www.dplay.co.uk/show/ghost-adventures/video/hotel-leger-103620/EHD_280313B',
1089 'only_matching': True,
1091 'url': 'https://tlc.de/sendungen/breaking-amish/die-welt-da-drauen/',
1092 'only_matching': True,
1095 def _real_extract(self
, url
):
1096 domain
, programme
, alternate_id
= self
._match
_valid
_url
(url
).groups()
1097 country
= 'GB' if domain
== 'dplay.co.uk' else 'DE'
1098 realm
= 'questuk' if country
== 'GB' else domain
.replace('.', '')
1099 return self
._get
_disco
_api
_info
(
1100 url
, f
'{programme}/{alternate_id}', 'eu1-prod.disco-api.com', realm
, country
)
1102 def _update_disco_api_headers(self
, headers
, disco_base
, display_id
, realm
):
1104 'x-disco-params': f
'realm={realm}',
1105 'x-disco-client': 'Alps:HyogaPlayer:0.0.0',
1106 'Authorization': self
._get
_auth
(disco_base
, display_id
, realm
),
1110 class DiscoveryPlusShowBaseIE(DPlayBaseIE
):
1112 def _entries(self
, show_name
):
1114 'x-disco-client': self
._X
_CLIENT
,
1115 'x-disco-params': f
'realm={self._REALM}',
1116 'referer': self
._DOMAIN
,
1117 'Authentication': self
._get
_auth
(self
._BASE
_API
, None, self
._REALM
),
1119 show_json
= self
._download
_json
(
1120 f
'{self._BASE_API}cms/routes/{self._SHOW_STR}/{show_name}?include=default',
1121 video_id
=show_name
, headers
=headers
)['included'][self
._INDEX
]['attributes']['component']
1122 show_id
= show_json
['mandatoryParams'].split('=')[-1]
1123 season_url
= self
._BASE
_API
+ 'content/videos?sort=episodeNumber&filter[seasonNumber]={}&filter[show.id]={}&page[size]=100&page[number]={}'
1124 for season
in show_json
['filters'][0]['options']:
1125 season_id
= season
['id']
1126 total_pages
, page_num
= 1, 0
1127 while page_num
< total_pages
:
1128 season_json
= self
._download
_json
(
1129 season_url
.format(season_id
, show_id
, str(page_num
+ 1)), show_name
, headers
=headers
,
1130 note
='Downloading season {} JSON metadata{}'.format(season_id
, f
' page {page_num}' if page_num
else ''))
1132 total_pages
= try_get(season_json
, lambda x
: x
['meta']['totalPages'], int) or 1
1133 episodes_json
= season_json
['data']
1134 for episode
in episodes_json
:
1135 video_path
= episode
['attributes']['path']
1136 yield self
.url_result(
1137 f
'{self._DOMAIN}videos/{video_path}',
1138 ie
=self
._VIDEO
_IE
.ie_key(), video_id
=episode
.get('id') or video_path
)
1141 def _real_extract(self
, url
):
1142 show_name
= self
._match
_valid
_url
(url
).group('show_name')
1143 return self
.playlist_result(self
._entries
(show_name
), playlist_id
=show_name
)
1146 class DiscoveryPlusItalyIE(DiscoveryPlusBaseIE
):
1147 _VALID_URL
= r
'https?://(?:www\.)?discoveryplus\.com/it/video' + DPlayBaseIE
._PATH
_REGEX
1149 'url': 'https://www.discoveryplus.com/it/video/i-signori-della-neve/stagione-2-episodio-1-i-preparativi',
1150 'only_matching': True,
1152 'url': 'https://www.discoveryplus.com/it/video/super-benny/trailer',
1153 'only_matching': True,
1156 _PRODUCT
= 'dplus_it'
1157 _DISCO_API_PARAMS
= {
1158 'disco_host': 'eu1-prod-direct.discoveryplus.com',
1163 def _update_disco_api_headers(self
, headers
, disco_base
, display_id
, realm
):
1165 'x-disco-params': f
'realm={realm},siteLookupKey={self._PRODUCT}',
1166 'x-disco-client': f
'WEB:UNKNOWN:dplus_us:{self._DISCO_CLIENT_VER}',
1167 'Authorization': self
._get
_auth
(disco_base
, display_id
, realm
),
1171 class DiscoveryPlusItalyShowIE(DiscoveryPlusShowBaseIE
):
1172 _VALID_URL
= r
'https?://(?:www\.)?discoveryplus\.it/programmi/(?P<show_name>[^/]+)/?(?:[?#]|$)'
1174 'url': 'https://www.discoveryplus.it/programmi/deal-with-it-stai-al-gioco',
1175 'playlist_mincount': 168,
1177 'id': 'deal-with-it-stai-al-gioco',
1181 _BASE_API
= 'https://disco-api.discoveryplus.it/'
1182 _DOMAIN
= 'https://www.discoveryplus.it/'
1183 _X_CLIENT
= 'WEB:UNKNOWN:dplay-client:2.6.0'
1185 _SHOW_STR
= 'programmi'
1190 class DiscoveryPlusIndiaShowIE(DiscoveryPlusShowBaseIE
):
1191 _VALID_URL
= r
'https?://(?:www\.)?discoveryplus\.in/show/(?P<show_name>[^/]+)/?(?:[?#]|$)'
1193 'url': 'https://www.discoveryplus.in/show/how-do-they-do-it',
1194 'playlist_mincount': 140,
1196 'id': 'how-do-they-do-it',
1200 _BASE_API
= 'https://ap2-prod-direct.discoveryplus.in/'
1201 _DOMAIN
= 'https://www.discoveryplus.in/'
1202 _X_CLIENT
= 'WEB:UNKNOWN:dplus-india:prod'
1203 _REALM
= 'dplusindia'
1206 _VIDEO_IE
= DiscoveryPlusIndiaIE