We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN 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
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `yt_dlp/extractor/swearnet.py`
Content:
```
1 from .common import InfoExtractor
2 from ..utils import int_or_none, traverse_obj
3 
4 
5 class SwearnetEpisodeIE(InfoExtractor):
6     _VALID_URL = r'https?://www\.swearnet\.com/shows/(?P<id>[\w-]+)/seasons/(?P<season_num>\d+)/episodes/(?P<episode_num>\d+)'
7     _TESTS = [{
8         'url': 'https://www.swearnet.com/shows/gettin-learnt-with-ricky/seasons/1/episodes/1',
9         'info_dict': {
10             'id': '232819',
11             'ext': 'mp4',
12             'episode_number': 1,
13             'episode': 'Episode 1',
14             'duration': 719,
15             'description': 'md5:c48ef71440ce466284c07085cd7bd761',
16             'season': 'Season 1',
17             'title': 'Episode 1 - Grilled Cheese Sammich',
18             'season_number': 1,
19             'thumbnail': 'https://cdn.vidyard.com/thumbnails/232819/_RX04IKIq60a2V6rIRqq_Q_small.jpg',
20         }
21     }]
22 
23     def _get_formats_and_subtitle(self, video_source, video_id):
24         video_source = video_source or {}
25         formats, subtitles = [], {}
26         for key, value in video_source.items():
27             if key == 'hls':
28                 for video_hls in value:
29                     fmts, subs = self._extract_m3u8_formats_and_subtitles(video_hls.get('url'), video_id)
30                     formats.extend(fmts)
31                     self._merge_subtitles(subs, target=subtitles)
32             else:
33                 formats.extend({
34                     'url': video_mp4.get('url'),
35                     'ext': 'mp4'
36                 } for video_mp4 in value)
37 
38         return formats, subtitles
39 
40     def _get_direct_subtitle(self, caption_json):
41         subs = {}
42         for caption in caption_json:
43             subs.setdefault(caption.get('language') or 'und', []).append({
44                 'url': caption.get('vttUrl'),
45                 'name': caption.get('name')
46             })
47 
48         return subs
49 
50     def _real_extract(self, url):
51         display_id, season_number, episode_number = self._match_valid_url(url).group('id', 'season_num', 'episode_num')
52         webpage = self._download_webpage(url, display_id)
53 
54         external_id = self._search_regex(r'externalid\s*=\s*"([^"]+)', webpage, 'externalid')
55         json_data = self._download_json(
56             f'https://play.vidyard.com/player/{external_id}.json', display_id)['payload']['chapters'][0]
57 
58         formats, subtitles = self._get_formats_and_subtitle(json_data['sources'], display_id)
59         self._merge_subtitles(self._get_direct_subtitle(json_data.get('captions')), target=subtitles)
60 
61         return {
62             'id': str(json_data['videoId']),
63             'title': json_data.get('name') or self._html_search_meta(['og:title', 'twitter:title'], webpage),
64             'description': (json_data.get('description')
65                             or self._html_search_meta(['og:description', 'twitter:description'], webpage)),
66             'duration': int_or_none(json_data.get('seconds')),
67             'formats': formats,
68             'subtitles': subtitles,
69             'season_number': int_or_none(season_number),
70             'episode_number': int_or_none(episode_number),
71             'thumbnails': [{'url': thumbnail_url}
72                            for thumbnail_url in traverse_obj(json_data, ('thumbnailUrls', ...))]
73         }
74
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

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 @@
         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]

{"golden_diff": "diff --git a/yt_dlp/extractor/swearnet.py b/yt_dlp/extractor/swearnet.py\n--- a/yt_dlp/extractor/swearnet.py\n+++ b/yt_dlp/extractor/swearnet.py\n@@ -1,5 +1,5 @@\n from .common import InfoExtractor\n-from ..utils import int_or_none, traverse_obj\n+from ..utils import ExtractorError, int_or_none, traverse_obj\n \n \n class SwearnetEpisodeIE(InfoExtractor):\n@@ -51,7 +51,13 @@\n         display_id, season_number, episode_number = self._match_valid_url(url).group('id', 'season_num', 'episode_num')\n         webpage = self._download_webpage(url, display_id)\n \n-        external_id = self._search_regex(r'externalid\\s*=\\s*\"([^\"]+)', webpage, 'externalid')\n+        try:\n+            external_id = self._search_regex(r'externalid\\s*=\\s*\"([^\"]+)', webpage, 'externalid')\n+        except ExtractorError:\n+            if 'Upgrade Now' in webpage:\n+                self.raise_login_required()\n+            raise\n+\n         json_data = self._download_json(\n             f'https://play.vidyard.com/player/{external_id}.json', display_id)['payload']['chapters'][0]\n", "issue": "swearnet.com needs appropriate error for subscription content w/o cookies\n### DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE\n\n- [X] I understand that I will be **blocked** if I *intentionally* remove or skip any mandatory\\* field\n\n### Checklist\n\n- [X] I'm reporting that yt-dlp is broken on a **supported** site\n- [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))\n- [X] I've checked that all provided URLs are playable in a browser with the same IP and same login details\n- [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)\n- [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\n- [X] I've read the [guidelines for opening an issue](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#opening-an-issue)\n- [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\n\n### Region\n\neverywhere\n\n### Provide a description that is worded well enough to be understood\n\nWas trying to grab episodes from a show on Swearnet\r\nthis spessifically: https://www.swearnet.com/shows/park-after-dark/seasons/1/episodes/2\r\nepisode one works just fine, same with 5.\r\nbut a huge majority just ends up throwing that error :)\r\n( the entire first season ) \r\nsome of the videos do work. but a huge majority of them just ends up saying: \r\nERROR: [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\n\n### Provide verbose output that clearly demonstrates the problem\n\n- [X] Run **your** yt-dlp command with **-vU** flag added (`yt-dlp -vU <your command line>`)\n- [ ] If using API, add `'verbose': True` to `YoutubeDL` params instead\n- [X] Copy the WHOLE output (starting with `[debug] Command-line config`) and insert it below\n\n### Complete Verbose Output\n\n```shell\n.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\r\n[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']\r\n[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)\r\n[debug] Python 3.8.10 (CPython AMD64 64bit) - Windows-10-10.0.22631-SP0 (OpenSSL 1.1.1k 25 Mar 2021)\r\n[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\r\n[debug] Loaded 1826 extractors\r\n[SwearnetEpisode] Extracting URL: https://www.swearnet.com/shows/park-after-dark/seasons/1/episodes/3 [SwearnetEpisode] park-after-dark: Downloading webpage\r\nERROR: [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\n```\n\n", "before_files": [{"content": "from .common import InfoExtractor\nfrom ..utils import int_or_none, traverse_obj\n\n\nclass SwearnetEpisodeIE(InfoExtractor):\n    _VALID_URL = r'https?://www\\.swearnet\\.com/shows/(?P<id>[\\w-]+)/seasons/(?P<season_num>\\d+)/episodes/(?P<episode_num>\\d+)'\n    _TESTS = [{\n        'url': 'https://www.swearnet.com/shows/gettin-learnt-with-ricky/seasons/1/episodes/1',\n        'info_dict': {\n            'id': '232819',\n            'ext': 'mp4',\n            'episode_number': 1,\n            'episode': 'Episode 1',\n            'duration': 719,\n            'description': 'md5:c48ef71440ce466284c07085cd7bd761',\n            'season': 'Season 1',\n            'title': 'Episode 1 - Grilled Cheese Sammich',\n            'season_number': 1,\n            'thumbnail': 'https://cdn.vidyard.com/thumbnails/232819/_RX04IKIq60a2V6rIRqq_Q_small.jpg',\n        }\n    }]\n\n    def _get_formats_and_subtitle(self, video_source, video_id):\n        video_source = video_source or {}\n        formats, subtitles = [], {}\n        for key, value in video_source.items():\n            if key == 'hls':\n                for video_hls in value:\n                    fmts, subs = self._extract_m3u8_formats_and_subtitles(video_hls.get('url'), video_id)\n                    formats.extend(fmts)\n                    self._merge_subtitles(subs, target=subtitles)\n            else:\n                formats.extend({\n                    'url': video_mp4.get('url'),\n                    'ext': 'mp4'\n                } for video_mp4 in value)\n\n        return formats, subtitles\n\n    def _get_direct_subtitle(self, caption_json):\n        subs = {}\n        for caption in caption_json:\n            subs.setdefault(caption.get('language') or 'und', []).append({\n                'url': caption.get('vttUrl'),\n                'name': caption.get('name')\n            })\n\n        return subs\n\n    def _real_extract(self, url):\n        display_id, season_number, episode_number = self._match_valid_url(url).group('id', 'season_num', 'episode_num')\n        webpage = self._download_webpage(url, display_id)\n\n        external_id = self._search_regex(r'externalid\\s*=\\s*\"([^\"]+)', webpage, 'externalid')\n        json_data = self._download_json(\n            f'https://play.vidyard.com/player/{external_id}.json', display_id)['payload']['chapters'][0]\n\n        formats, subtitles = self._get_formats_and_subtitle(json_data['sources'], display_id)\n        self._merge_subtitles(self._get_direct_subtitle(json_data.get('captions')), target=subtitles)\n\n        return {\n            'id': str(json_data['videoId']),\n            'title': json_data.get('name') or self._html_search_meta(['og:title', 'twitter:title'], webpage),\n            'description': (json_data.get('description')\n                            or self._html_search_meta(['og:description', 'twitter:description'], webpage)),\n            'duration': int_or_none(json_data.get('seconds')),\n            'formats': formats,\n            'subtitles': subtitles,\n            'season_number': int_or_none(season_number),\n            'episode_number': int_or_none(episode_number),\n            'thumbnails': [{'url': thumbnail_url}\n                           for thumbnail_url in traverse_obj(json_data, ('thumbnailUrls', ...))]\n        }\n", "path": "yt_dlp/extractor/swearnet.py"}], "after_files": [{"content": "from .common import InfoExtractor\nfrom ..utils import ExtractorError, int_or_none, traverse_obj\n\n\nclass SwearnetEpisodeIE(InfoExtractor):\n    _VALID_URL = r'https?://www\\.swearnet\\.com/shows/(?P<id>[\\w-]+)/seasons/(?P<season_num>\\d+)/episodes/(?P<episode_num>\\d+)'\n    _TESTS = [{\n        'url': 'https://www.swearnet.com/shows/gettin-learnt-with-ricky/seasons/1/episodes/1',\n        'info_dict': {\n            'id': '232819',\n            'ext': 'mp4',\n            'episode_number': 1,\n            'episode': 'Episode 1',\n            'duration': 719,\n            'description': 'md5:c48ef71440ce466284c07085cd7bd761',\n            'season': 'Season 1',\n            'title': 'Episode 1 - Grilled Cheese Sammich',\n            'season_number': 1,\n            'thumbnail': 'https://cdn.vidyard.com/thumbnails/232819/_RX04IKIq60a2V6rIRqq_Q_small.jpg',\n        }\n    }]\n\n    def _get_formats_and_subtitle(self, video_source, video_id):\n        video_source = video_source or {}\n        formats, subtitles = [], {}\n        for key, value in video_source.items():\n            if key == 'hls':\n                for video_hls in value:\n                    fmts, subs = self._extract_m3u8_formats_and_subtitles(video_hls.get('url'), video_id)\n                    formats.extend(fmts)\n                    self._merge_subtitles(subs, target=subtitles)\n            else:\n                formats.extend({\n                    'url': video_mp4.get('url'),\n                    'ext': 'mp4'\n                } for video_mp4 in value)\n\n        return formats, subtitles\n\n    def _get_direct_subtitle(self, caption_json):\n        subs = {}\n        for caption in caption_json:\n            subs.setdefault(caption.get('language') or 'und', []).append({\n                'url': caption.get('vttUrl'),\n                'name': caption.get('name')\n            })\n\n        return subs\n\n    def _real_extract(self, url):\n        display_id, season_number, episode_number = self._match_valid_url(url).group('id', 'season_num', 'episode_num')\n        webpage = self._download_webpage(url, display_id)\n\n        try:\n            external_id = self._search_regex(r'externalid\\s*=\\s*\"([^\"]+)', webpage, 'externalid')\n        except ExtractorError:\n            if 'Upgrade Now' in webpage:\n                self.raise_login_required()\n            raise\n\n        json_data = self._download_json(\n            f'https://play.vidyard.com/player/{external_id}.json', display_id)['payload']['chapters'][0]\n\n        formats, subtitles = self._get_formats_and_subtitle(json_data['sources'], display_id)\n        self._merge_subtitles(self._get_direct_subtitle(json_data.get('captions')), target=subtitles)\n\n        return {\n            'id': str(json_data['videoId']),\n            'title': json_data.get('name') or self._html_search_meta(['og:title', 'twitter:title'], webpage),\n            'description': (json_data.get('description')\n                            or self._html_search_meta(['og:description', 'twitter:description'], webpage)),\n            'duration': int_or_none(json_data.get('seconds')),\n            'formats': formats,\n            'subtitles': subtitles,\n            'season_number': int_or_none(season_number),\n            'episode_number': int_or_none(episode_number),\n            'thumbnails': [{'url': thumbnail_url}\n                           for thumbnail_url in traverse_obj(json_data, ('thumbnailUrls', ...))]\n        }\n", "path": "yt_dlp/extractor/swearnet.py"}]}