Repository: yt-dlp/yt-dlp

Issue:
[TwitCastingLive] Broken extractor; password protected livestreams incorrectly parsed as offline
### Checklist

- [X] I'm reporting a broken site
- [X] I've verified that I'm running yt-dlp version **2022.02.04**. ([update instructions](https://github.com/yt-dlp/yt-dlp#update))
- [X] I've checked that all provided URLs are alive and playable in a browser
- [X] I've checked that all URLs and arguments with special characters are [properly quoted or escaped](https://github.com/ytdl-org/youtube-dl#video-url-contains-an-ampersand-and-im-getting-some-strange-output-1-2839-or-v-is-not-recognized-as-an-internal-or-external-command)
- [X] I've searched the [bugtracker](https://github.com/yt-dlp/yt-dlp/issues?q=) for similar issues including closed ones. DO NOT post duplicates
- [X] I've read the [guidelines for opening an issue](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#opening-an-issue)
- [X] I've read about [sharing account credentials](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#are-you-willing-to-share-account-details-if-needed) and I'm willing to share it if required

### Region

Not applicable

### Description

"TwitCastingLive" extractor is broken for live streams that are protected by a secret word. Rather than prompt the user for the password the extractor fails and incorrectly reports that the stream is not live. Additionally attempting to pass the link using `--video-password` results in the same error.

Log is below but has been redacted. Since you need to test using a private stream you'll have to use your own account to make it easy to test against, there was no need to include my credentials.

### Verbose log

```shell
[debug] Command-line config: ['-vU', 'https://twitcasting.tv/REDACTED']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, err utf-8, pref UTF-8
[debug] yt-dlp version 2022.02.04 [c1653e9ef]
[debug] Python version 3.8.10 (CPython 64bit) - Linux-5.13.0-28-generic-x86_64-with-glibc2.29
[debug] exe versions: ffmpeg 4.3.1 (fdk)
[debug] Optional libraries: Cryptodome, secretstorage, mutagen, sqlite, websockets
[debug] Proxy map: {}
Latest version: 2022.02.04, Current version: 2022.02.04
yt-dlp is up to date (2022.02.04)
[debug] [TwitCastingLive] Extracting URL: https://twitcasting.tv/REDACTED
[TwitCastingLive] Downloading live video of user REDACTED. Pass "https://twitcasting.tv/REDACTED/show" to download the history
[TwitCastingLive] REDACTED: Downloading webpage
ERROR: [TwitCastingLive] REDACTED: The user is not currently live; please report this issue on  https://github.com/yt-dlp/yt-dlp , filling out the "Broken site" issue template properly. Confirm you are on the latest version using -U; please report this issue on  https://github.com/yt-dlp/yt-dlp , filling out the "Broken site" issue template properly. Confirm you are on the latest version using -U
  File "/home/REDACTED/.local/lib/python3.8/site-packages/yt_dlp/extractor/common.py", line 612, in extract
    ie_result = self._real_extract(url)
  File "/home/REDACTED/.local/lib/python3.8/site-packages/yt_dlp/extractor/twitcasting.py", line 217, in _real_extract
    raise ExtractorError('The user is not currently live')
```



Discussion:

Resolving patch:
diff --git a/yt_dlp/extractor/twitcasting.py b/yt_dlp/extractor/twitcasting.py
--- a/yt_dlp/extractor/twitcasting.py
+++ b/yt_dlp/extractor/twitcasting.py
@@ -220,6 +220,17 @@ def _real_extract(self, url):
             (r'data-type="movie" data-id="(\d+)">',
              r'tw-sound-flag-open-link" data-id="(\d+)" style=',),
             webpage, 'current live ID', default=None)
+        if not current_live:
+            # fetch unfiltered /show to find running livestreams; we can't get ID of the password-protected livestream above
+            webpage = self._download_webpage(
+                f'https://twitcasting.tv/{uploader_id}/show/', uploader_id,
+                note='Downloading live history')
+            is_live = self._search_regex(r'(?s)(<span\s*class="tw-movie-thumbnail-badge"\s*data-status="live">\s*LIVE)', webpage, 'is live?', default=None)
+            if is_live:
+                # get the first live; running live is always at the first
+                current_live = self._search_regex(
+                    r'(?s)<a\s+class="tw-movie-thumbnail"\s*href="/[^/]+/movie/(?P<video_id>\d+)"\s*>.+?</a>',
+                    webpage, 'current live ID 2', default=None, group='video_id')
         if not current_live:
             raise ExtractorError('The user is not currently live')
         return self.url_result('https://twitcasting.tv/%s/movie/%s' % (uploader_id, current_live))


Test patch: