From b05640d532c43a52c0a0da096bb2dbd51e105ec0 Mon Sep 17 00:00:00 2001 From: bashonly <88596187+bashonly@users.noreply.github.com> Date: Sat, 24 Feb 2024 17:11:28 -0600 Subject: [PATCH] [ie/swearnet] Raise for login required (#9281) Closes #9110 Authored by: bashonly --- yt_dlp/extractor/swearnet.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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]