]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/dplay.py
[dplay] Add `ScienceChannelIE` (#567)
[yt-dlp.git] / yt_dlp / extractor / dplay.py
index e8da71dd6aa9ae0a6640cf09d650cf8590bb15ba..38b08d28052c17ce450e112d4b94402ece60794a 100644 (file)
@@ -296,49 +296,33 @@ def _real_extract(self, url):
             url, display_id, host, 'dplay' + country, country)
 
 
-class DiscoveryPlusIndiaIE(DPlayIE):
-    _VALID_URL = r'https?://(?:www\.)?discoveryplus\.in/videos?' + DPlayIE._PATH_REGEX
+class HGTVDeIE(DPlayIE):
+    _VALID_URL = r'https?://de\.hgtv\.com/sendungen' + DPlayIE._PATH_REGEX
     _TESTS = [{
-        'url': 'https://www.discoveryplus.in/videos/how-do-they-do-it/fugu-and-more?seasonId=8&type=EPISODE',
+        'url': 'https://de.hgtv.com/sendungen/tiny-house-klein-aber-oho/wer-braucht-schon-eine-toilette/',
         'info_dict': {
-            'id': '27104',
+            'id': '151205',
+            'display_id': 'tiny-house-klein-aber-oho/wer-braucht-schon-eine-toilette',
             'ext': 'mp4',
-            'display_id': 'how-do-they-do-it/fugu-and-more',
-            'title': 'Fugu and More',
-            'description': 'The Japanese catch, prepare and eat the deadliest fish on the planet.',
-            'duration': 1319,
-            'timestamp': 1582309800,
-            'upload_date': '20200221',
-            'series': 'How Do They Do It?',
-            'season_number': 8,
-            'episode_number': 2,
-            'creator': 'Discovery Channel',
+            'title': 'Wer braucht schon eine Toilette',
+            'description': 'md5:05b40a27e7aed2c9172de34d459134e2',
+            'duration': 1177.024,
+            'timestamp': 1595705400,
+            'upload_date': '20200725',
+            'creator': 'HGTV',
+            'series': 'Tiny House - klein, aber oho',
+            'season_number': 3,
+            'episode_number': 3,
         },
         'params': {
             'format': 'bestvideo',
-            'skip_download': True,
         },
-        'skip': 'Cookies (not necessarily logged in) are needed'
     }]
 
-    def _update_disco_api_headers(self, headers, disco_base, display_id, realm):
-        headers['x-disco-params'] = 'realm=%s' % realm
-        headers['x-disco-client'] = 'WEB:UNKNOWN:dplus-india:17.0.0'
-
-    def _download_video_playback_info(self, disco_base, video_id, headers):
-        return self._download_json(
-            disco_base + 'playback/v3/videoPlaybackInfo',
-            video_id, headers=headers, data=json.dumps({
-                'deviceInfo': {
-                    'adBlocker': False,
-                },
-                'videoId': video_id,
-            }).encode('utf-8'))['data']['attributes']['streaming']
-
     def _real_extract(self, url):
         display_id = self._match_id(url)
         return self._get_disco_api_info(
-            url, display_id, 'ap2-prod-direct.discoveryplus.in', 'dplusindia', 'in')
+            url, display_id, 'eu1-prod.disco-api.com', 'hgtv', 'de')
 
 
 class DiscoveryPlusIE(DPlayIE):
@@ -362,8 +346,11 @@ class DiscoveryPlusIE(DPlayIE):
         'skip': 'Available for Premium users',
     }]
 
+    _PRODUCT = 'dplus_us'
+    _API_URL = 'us1-prod-direct.discoveryplus.com'
+
     def _update_disco_api_headers(self, headers, disco_base, display_id, realm):
-        headers['x-disco-client'] = 'WEB:UNKNOWN:dplus_us:15.0.0'
+        headers['x-disco-client'] = f'WEB:UNKNOWN:{self._PRODUCT}:15.0.0'
 
     def _download_video_playback_info(self, disco_base, video_id, headers):
         return self._download_json(
@@ -375,40 +362,31 @@ def _download_video_playback_info(self, disco_base, video_id, headers):
                 'videoId': video_id,
                 'wisteriaProperties': {
                     'platform': 'desktop',
-                    'product': 'dplus_us',
+                    'product': self._PRODUCT,
                 },
             }).encode('utf-8'))['data']['attributes']['streaming']
 
     def _real_extract(self, url):
         display_id = self._match_id(url)
         return self._get_disco_api_info(
-            url, display_id, 'us1-prod-direct.discoveryplus.com', 'go', 'us')
+            url, display_id, self._API_URL, 'go', 'us')
 
 
-class HGTVDeIE(DPlayIE):
-    _VALID_URL = r'https?://de\.hgtv\.com/sendungen' + DPlayIE._PATH_REGEX
+class ScienceChannelIE(DiscoveryPlusIE):
+    _VALID_URL = r'https?://(?:www\.)?sciencechannel\.com/video' + DPlayIE._PATH_REGEX
     _TESTS = [{
-        'url': 'https://de.hgtv.com/sendungen/tiny-house-klein-aber-oho/wer-braucht-schon-eine-toilette/',
+        'url': 'https://www.sciencechannel.com/video/strangest-things-science-atve-us/nazi-mystery-machine',
         'info_dict': {
-            'id': '151205',
-            'display_id': 'tiny-house-klein-aber-oho/wer-braucht-schon-eine-toilette',
+            'id': '2842849',
+            'display_id': 'strangest-things-science-atve-us/nazi-mystery-machine',
             'ext': 'mp4',
-            'title': 'Wer braucht schon eine Toilette',
-            'description': 'md5:05b40a27e7aed2c9172de34d459134e2',
-            'duration': 1177.024,
-            'timestamp': 1595705400,
-            'upload_date': '20200725',
-            'creator': 'HGTV',
-            'series': 'Tiny House - klein, aber oho',
-            'season_number': 3,
-            'episode_number': 3,
-        },
-        'params': {
-            'format': 'bestvideo',
+            'title': 'Nazi Mystery Machine',
+            'description': 'Experts investigate the secrets of a revolutionary encryption machine.',
+            'season_number': 1,
+            'episode_number': 1,
         },
+        'skip': 'Available for Premium users',
     }]
 
-    def _real_extract(self, url):
-        display_id = self._match_id(url)
-        return self._get_disco_api_info(
-            url, display_id, 'eu1-prod.disco-api.com', 'hgtv', 'de')
+    _PRODUCT = 'sci'
+    _API_URL = 'us1-prod-direct.sciencechannel.com'