[discoverygo] detect when video needs authentication(closes #10425)
[youtube-dl] / youtube_dl / extractor / discoverygo.py
index adb68b96c4033a3ef5cf8dcf3357fa64ed73acb8..e86d16d367a9c3e4780f8fb07ff03b0ee5c3b21a 100644 (file)
@@ -7,11 +7,22 @@ from ..utils import (
     int_or_none,
     parse_age_limit,
     unescapeHTML,
+    ExtractorError,
 )
 
 
 class DiscoveryGoIE(InfoExtractor):
-    _VALID_URL = r'https?://(?:www\.)?discoverygo\.com/(?:[^/]+/)*(?P<id>[^/?#&]+)'
+    _VALID_URL = r'''(?x)https?://(?:www\.)?(?:
+            discovery|
+            investigationdiscovery|
+            discoverylife|
+            animalplanet|
+            ahctv|
+            destinationamerica|
+            sciencechannel|
+            tlc|
+            velocitychannel
+        )go\.com/(?:[^/]+/)*(?P<id>[^/?#&]+)'''
     _TEST = {
         'url': 'https://www.discoverygo.com/love-at-first-kiss/kiss-first-ask-questions-later/',
         'info_dict': {
@@ -43,7 +54,13 @@ class DiscoveryGoIE(InfoExtractor):
 
         title = video['name']
 
-        stream = video['stream']
+        stream = video.get('stream')
+        if not stream:
+            raise ExtractorError(
+                'This video is only available via cable service provider subscription that'
+                ' is not currently supported. You may want to use --cookies.'
+                if video.get('authenticated') is True else 'Unable to find stream',
+                expected=True)
         STREAM_URL_SUFFIX = 'streamUrl'
         formats = []
         for stream_kind in ('', 'hds'):