about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDaniel Peukert <daniel@peukert.cc>2020-11-21 15:52:20 +0100
committerGitHub <noreply@github.com>2020-11-21 21:52:20 +0700
commit21292c0649e956afc46bd39d774ec811d568de2a (patch)
treecbbd2512697f7573391dac147f10bf1c9c474d52
parent46a265a2da26c663463244ecf9a4a699c2cd6efc (diff)
downloadyoutube-dl-21292c0649e956afc46bd39d774ec811d568de2a.tar.gz
youtube-dl-21292c0649e956afc46bd39d774ec811d568de2a.tar.xz
youtube-dl-21292c0649e956afc46bd39d774ec811d568de2a.zip
[youtube] Fix error reason extraction (#27081)
-rw-r--r--youtube_dl/extractor/youtube.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py
index fb4c31326..fb6d816cc 100644
--- a/youtube_dl/extractor/youtube.py
+++ b/youtube_dl/extractor/youtube.py
@@ -2024,6 +2024,21 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
             else:
                 error_message = extract_unavailable_message()
                 if not error_message:
+                    reason_list = try_get(
+                        player_response,
+                        lambda x: x['playabilityStatus']['errorScreen']['playerErrorMessageRenderer']['subreason']['runs'],
+                        list) or []
+                    for reason in reason_list:
+                        if not isinstance(reason, dict):
+                            continue
+                        reason_text = try_get(reason, lambda x: x['text'], compat_str)
+                        if reason_text:
+                            if not error_message:
+                                error_message = ''
+                            error_message += reason_text
+                    if error_message:
+                        error_message = clean_html(error_message)
+                if not error_message:
                     error_message = clean_html(try_get(
                         player_response, lambda x: x['playabilityStatus']['reason'],
                         compat_str))