From ab9a9785c0dbc229a0cc359d0062ceb232780862 Mon Sep 17 00:00:00 2001 From: Mort Yao Date: Mon, 28 Oct 2024 17:29:05 +0100 Subject: [PATCH] [youtube] fix reason --- src/you_get/extractors/youtube.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/you_get/extractors/youtube.py b/src/you_get/extractors/youtube.py index 23112b2dea..fe43dfa64c 100644 --- a/src/you_get/extractors/youtube.py +++ b/src/you_get/extractors/youtube.py @@ -188,10 +188,17 @@ def check_playability_response(self, ytInitialPlayerResponse): playerResponseStatus = ytInitialPlayerResponse["playabilityStatus"]["status"] if playerResponseStatus != STATUS_OK: - reason = ytInitialPlayerResponse["playabilityStatus"].get("reason", "") - raise AssertionError( - f"Server refused to provide video details. Returned status: {playerResponseStatus}, reason: {reason}." - ) + try: + reason = ytInitialPlayerResponse["playabilityStatus"]['errorScreen']\ + ['playerErrorMessageRenderer']['reason']['runs'][0]['text'] + reason += ' ' + ytInitialPlayerResponse["playabilityStatus"]['errorScreen']\ + ['playerErrorMessageRenderer']['subreason']['runs'][0]['text'] + except: + reason = ytInitialPlayerResponse["playabilityStatus"].get("reason", "") + if reason: + log.wtf(f'Server refused to provide video details. Returned status: {playerResponseStatus}. Reason: {reason}') + else: + log.wtf(f'Server refused to provide video details. Returned status: {playerResponseStatus}.') def prepare(self, **kwargs): self.ua = 'Mozilla/5.0 (Linux; Android 15) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.73 Mobile Safari/537.36'