diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-02-23 03:07:47 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-02-23 04:25:55 +0530 |
commit | 1108613f021eea0f6d4c5786c94db98641af6d59 (patch) | |
tree | 037e0e36518fbe662622b6cbe06875da3f6f5972 | |
parent | a30a6ed3e49a0e037af6d5e26ecef3f3eba67d33 (diff) | |
download | hypervideo-pre-1108613f021eea0f6d4c5786c94db98641af6d59.tar.lz hypervideo-pre-1108613f021eea0f6d4c5786c94db98641af6d59.tar.xz hypervideo-pre-1108613f021eea0f6d4c5786c94db98641af6d59.zip |
[youtube:tab] Reject webpage data if redirected to home page
Closes #2660
-rw-r--r-- | yt_dlp/extractor/youtube.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py index fbf9581c6..636bf42b6 100644 --- a/yt_dlp/extractor/youtube.py +++ b/yt_dlp/extractor/youtube.py @@ -4244,6 +4244,16 @@ class YoutubeTabBaseInfoExtractor(YoutubeBaseInfoExtractor): if 'webpage' not in self._configuration_arg('skip'): webpage, data = self._extract_webpage(url, item_id, fatal=webpage_fatal) ytcfg = ytcfg or self.extract_ytcfg(item_id, webpage) + # Reject webpage data if redirected to home page without explicitly requesting + selected_tab = self._extract_selected_tab(traverse_obj( + data, ('contents', 'twoColumnBrowseResultsRenderer', 'tabs'), expected_type=list, default=[])) or {} + if (url != 'https://www.youtube.com/feed/recommended' + and selected_tab.get('tabIdentifier') == 'FEwhat_to_watch' # Home page + and 'no-youtube-channel-redirect' not in self.get_param('compat_opts', [])): + msg = 'The channel/playlist does not exist and the URL redirected to youtube.com home page' + if fatal: + raise ExtractorError(msg, expected=True) + self.report_warning(msg, only_once=True) if not data: if not ytcfg and self.is_authenticated: msg = 'Playlists that require authentication may not extract correctly without a successful webpage download.' |