From a51ef56c03e64c37fe6fe0337752515fc3b06354 Mon Sep 17 00:00:00 2001 From: gamer191 <83270075+gamer191@users.noreply.github.com> Date: Thu, 22 Oct 2026 07:08:55 +1100 Subject: [PATCH] [ie/youtube] Improve error messages (#17884) Authored by: gamer191 --- yt_dlp/extractor/youtube/_video.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/yt_dlp/extractor/youtube/_video.py b/yt_dlp/extractor/youtube/_video.py index 273f4628eb..bcfe41145a 100644 --- a/yt_dlp/extractor/youtube/_video.py +++ b/yt_dlp/extractor/youtube/_video.py @@ -4049,8 +4049,15 @@ class YoutubeIE(YoutubeBaseInfoExtractor): pemr = get_first( playability_statuses, ('errorScreen', 'playerErrorMessageRenderer'), expected_type=dict) or {} - reason = self._get_text(pemr, 'reason') or get_first(playability_statuses, 'reason') - subreason = clean_html(self._get_text(pemr, 'subreason') or '') + ivm = get_first( + playability_statuses, + ('errorScreen', 'playerInterstitialRenderer', 'content', 'interstitialViewModel', {dict})) or {} + reason = ( + self._get_text(pemr, 'reason') + or get_first(playability_statuses, 'reason') + or traverse_obj(ivm, ('title', 'content', {str})) + or '') + subreason = clean_html(self._get_text(pemr, 'subreason')) or traverse_obj(ivm, ('description', 'content', {clean_html})) if subreason: if subreason.startswith('The uploader has not made this video available in your country'): countries = get_first(microformats, 'availableCountries') @@ -4058,7 +4065,8 @@ class YoutubeIE(YoutubeBaseInfoExtractor): regions_allowed = search_meta('regionsAllowed') countries = regions_allowed.split(',') if regions_allowed else None self.raise_geo_restricted(subreason, countries, metadata_available=True) - reason += f'. {subreason}' + if subreason != reason: + reason += f'. {subreason}' if reason: if 'sign in' in reason.lower(): reason = remove_end(reason, 'This helps protect our community. Learn more')