]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/twitcasting.py
[cleanup, docs] Minor fixes
[yt-dlp.git] / yt_dlp / extractor / twitcasting.py
index 16584e940b85cf0e734506b9ea71dad735cb669b..c3e058709d6a696267640616a0c2b8b01ba8a853 100644 (file)
@@ -14,6 +14,7 @@
     parse_duration,
     qualities,
     str_to_int,
+    traverse_obj,
     try_get,
     unified_timestamp,
     urlencode_postdata,
@@ -63,7 +64,7 @@ class TwitCastingIE(InfoExtractor):
     }]
 
     def _real_extract(self, url):
-        uploader_id, video_id = re.match(self._VALID_URL, url).groups()
+        uploader_id, video_id = self._match_valid_url(url).groups()
 
         video_password = self.get_param('videopassword')
         request_data = None
@@ -96,12 +97,17 @@ def _real_extract(self, url):
             'Downloading live info', fatal=False)
 
         is_live = 'data-status="online"' in webpage
+
+        if not traverse_obj(stream_server_data, 'llfmp4') and is_live:
+            self.raise_login_required(method='cookies')
+
         formats = []
         if is_live and not m3u8_url:
             m3u8_url = 'https://twitcasting.tv/%s/metastream.m3u8' % uploader_id
         if is_live and has_websockets and stream_server_data:
             qq = qualities(['base', 'mobilesource', 'main'])
-            for mode, ws_url in stream_server_data['llfmp4']['streams'].items():
+            streams = traverse_obj(stream_server_data, ('llfmp4', 'streams')) or {}
+            for mode, ws_url in streams.items():
                 formats.append({
                     'url': ws_url,
                     'format_id': 'ws-%s' % mode,