From a3e964211611ec60a3f84688ab9ff30e4c1504f6 Mon Sep 17 00:00:00 2001 From: coletdjnz Date: Sun, 7 Aug 2022 13:43:20 +0000 Subject: [PATCH] [extractor/youtube] Prevent redirect to unwanted videos (#4593) Example: https://www.youtube.com/watch?v=aQvGIIdgFDM Authored by: coletdjnz --- yt_dlp/extractor/youtube.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py index 4ad8cf900..1b4e47b5f 100644 --- a/yt_dlp/extractor/youtube.py +++ b/yt_dlp/extractor/youtube.py @@ -3133,7 +3133,14 @@ def append_client(*client_names): continue if pr: - prs.append(pr) + # YouTube may return a different video player response than expected. + # See: https://github.com/TeamNewPipe/NewPipe/issues/8713 + pr_video_id = traverse_obj(pr, ('videoDetails', 'videoId')) + if pr_video_id and pr_video_id != video_id: + self.report_warning( + f'{client} client returned a player response for "{pr_video_id}" instead of "{video_id}"' + bug_reports_message()) + else: + prs.append(pr) # creator clients can bypass AGE_VERIFICATION_REQUIRED if logged in if variant == 'embedded' and self._is_unplayable(pr) and self.is_authenticated: