Repository: yt-dlp/yt-dlp

Issue:
swearnet.com needs appropriate error for subscription content w/o cookies
### DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

- [X] I understand that I will be **blocked** if I *intentionally* remove or skip any mandatory\* field

### Checklist

- [X] I'm reporting that yt-dlp is broken on a **supported** site
- [X] I've verified that I have **updated yt-dlp to nightly or master** ([update instructions](https://github.com/yt-dlp/yt-dlp#update-channels))
- [X] I've checked that all provided URLs are playable in a browser with the same IP and same login details
- [X] I've checked that all URLs and arguments with special characters are [properly quoted or escaped](https://github.com/yt-dlp/yt-dlp/wiki/FAQ#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 [known issues](https://github.com/yt-dlp/yt-dlp/issues/3766) and 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

everywhere

### Provide a description that is worded well enough to be understood

Was trying to grab episodes from a show on Swearnet
this spessifically: https://www.swearnet.com/shows/park-after-dark/seasons/1/episodes/2
episode one works just fine, same with 5.
but a huge majority just ends up throwing that error :)
( the entire first season ) 
some of the videos do work. but a huge majority of them just ends up saying: 
ERROR: [SwearnetEpisode] park-after-dark: Unable to extract externalid; please report this issue on https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using yt-dlp -U

### Provide verbose output that clearly demonstrates the problem

- [X] Run **your** yt-dlp command with **-vU** flag added (`yt-dlp -vU <your command line>`)
- [ ] If using API, add `'verbose': True` to `YoutubeDL` params instead
- [X] Copy the WHOLE output (starting with `[debug] Command-line config`) and insert it below

### Complete Verbose Output

```shell
.stacher/youtube-dl -f bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best --no-warnings --restrict-filenames --embed-metadata --write-sub --all-subs --embed-subs --no-check-certificate -N 10 --verbose -o D:\downloads\usenet\complete\%(title)s.%(ext)s https://www.swearnet.com/shows/park-after-dark/seasons/1/episodes/3
[debug] Command-line config: ['-f', 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best', '--no-warnings', '--restrict-filenames', '--embed-metadata', '--write-sub', '--all-subs', '--embed-subs', '--no-check-certificate', '-N', '10', '--verbose', '-o', 'D:\\downloads\\usenet\\complete\\%(title)s.%(ext)s', 'https://www.swearnet.com/shows/park-after-dark/seasons/1/episodes/3', '--progress-template', '%(progress._percent_str)s,%(progress._speed_str)s,%(progress._eta_str)s,%(progress._total_bytes_str)s,%(progress.status)s,%(progress._elapsed_str)s,%(progress.filename)s']
[debug] Encodings: locale cp1252, fs utf-8, pref cp1252, out cp1252 (No VT), error cp1252 (No VT), screen cp1252 (No VT) [debug] yt-dlp version nightly@2024.01.29.232706 from yt-dlp/yt-dlp-nightly-builds [67bb70cd7] (win_exe)
[debug] Python 3.8.10 (CPython AMD64 64bit) - Windows-10-10.0.22631-SP0 (OpenSSL 1.1.1k 25 Mar 2021)
[debug] exe versions: ffmpeg N-113445-ge0da916b8f-20240128 (setts), ffprobe N-113445-ge0da916b8f-20240128 [debug] Optional libraries: Cryptodome-3.20.0, brotli-1.1.0, certifi-2023.11.17, mutagen-1.47.0, requests-2.31.0, sqlite3-3.35.5, urllib3-2.1.0, websockets-12.0 [debug] Proxy map: {} [debug] Request Handlers: urllib, requests, websockets
[debug] Loaded 1826 extractors
[SwearnetEpisode] Extracting URL: https://www.swearnet.com/shows/park-after-dark/seasons/1/episodes/3 [SwearnetEpisode] park-after-dark: Downloading webpage
ERROR: [SwearnetEpisode] park-after-dark: Unable to extract externalid; please report this issue on https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using yt-dlp -U File "yt_dlp\extractor\common.py", line 718, in extract File "yt_dlp\extractor\swearnet.py", line 54, in _real_extract File "yt_dlp\extractor\common.py", line 1266, in _search_regex
```



Discussion:
Do the episodes that aren't working require a subscription? You're not [passing cookies to yt-dlp](https://github.com/yt-dlp/yt-dlp/wiki/FAQ#how-do-i-pass-cookies-to-yt-dlp). Try that.

Though if this was the problem, we should fix the extractor so that it raises for login required instead of a search regex error
> Do the episodes that aren't working require a subscription? You're not [passing cookies to yt-dlp](https://github.com/yt-dlp/yt-dlp/wiki/FAQ#how-do-i-pass-cookies-to-yt-dlp). Try that.
> 
> Though if this was the problem, we should fix the extractor so that it raises for login required instead of a search regex error

hey. that might be the issue indeed. i used a different downloader and logged in to the site via that downloader, and all downloads worked.

```diff
diff --git a/yt_dlp/extractor/swearnet.py b/yt_dlp/extractor/swearnet.py
index 6e216a2a5..aeaff28f2 100644
--- a/yt_dlp/extractor/swearnet.py
+++ b/yt_dlp/extractor/swearnet.py
@@ -1,5 +1,5 @@
 from .common import InfoExtractor
-from ..utils import int_or_none, traverse_obj
+from ..utils import ExtractorError, int_or_none, traverse_obj
 
 
 class SwearnetEpisodeIE(InfoExtractor):
@@ -51,7 +51,13 @@ def _real_extract(self, url):
         display_id, season_number, episode_number = self._match_valid_url(url).group('id', 'season_num', 'episode_num')
         webpage = self._download_webpage(url, display_id)
 
-        external_id = self._search_regex(r'externalid\s*=\s*"([^"]+)', webpage, 'externalid')
+        try:
+            external_id = self._search_regex(r'externalid\s*=\s*"([^"]+)', webpage, 'externalid')
+        except ExtractorError:
+            if 'Upgrade Now' in webpage:
+                self.raise_login_required()
+            raise
+
         json_data = self._download_json(
             f'https://play.vidyard.com/player/{external_id}.json', display_id)['payload']['chapters'][0]
```

Resolving patch:
diff --git a/yt_dlp/extractor/swearnet.py b/yt_dlp/extractor/swearnet.py
--- a/yt_dlp/extractor/swearnet.py
+++ b/yt_dlp/extractor/swearnet.py
@@ -1,5 +1,5 @@
 from .common import InfoExtractor
-from ..utils import int_or_none, traverse_obj
+from ..utils import ExtractorError, int_or_none, traverse_obj
 
 
 class SwearnetEpisodeIE(InfoExtractor):
@@ -51,7 +51,13 @@ def _real_extract(self, url):
         display_id, season_number, episode_number = self._match_valid_url(url).group('id', 'season_num', 'episode_num')
         webpage = self._download_webpage(url, display_id)
 
-        external_id = self._search_regex(r'externalid\s*=\s*"([^"]+)', webpage, 'externalid')
+        try:
+            external_id = self._search_regex(r'externalid\s*=\s*"([^"]+)', webpage, 'externalid')
+        except ExtractorError:
+            if 'Upgrade Now' in webpage:
+                self.raise_login_required()
+            raise
+
         json_data = self._download_json(
             f'https://play.vidyard.com/player/{external_id}.json', display_id)['payload']['chapters'][0]
 


Test patch: