aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcoletdjnz <colethedj@protonmail.com>2021-06-26 06:01:10 +1200
committerGitHub <noreply@github.com>2021-06-25 23:31:10 +0530
commit45261e063bc83516504261910b72c25daf86d4b8 (patch)
treeeeaa5acda9da7876579a7ce5af245353d97862f8
parent49c258e18deadee9db559aa8df1e947d72ba1557 (diff)
downloadhypervideo-pre-45261e063bc83516504261910b72c25daf86d4b8.tar.lz
hypervideo-pre-45261e063bc83516504261910b72c25daf86d4b8.tar.xz
hypervideo-pre-45261e063bc83516504261910b72c25daf86d4b8.zip
[youtube:comments] Fix error handling and add `itct` to params (#446)
Should close #439 (untested) Authored by: colethedj
-rw-r--r--yt_dlp/extractor/youtube.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py
index e27253e37..b2a9322d7 100644
--- a/yt_dlp/extractor/youtube.py
+++ b/yt_dlp/extractor/youtube.py
@@ -1731,6 +1731,8 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
'pbj': 1,
'type': 'next',
}
+ if 'itct' in continuation:
+ query['itct'] = continuation['itct']
if parent:
query['action_get_comment_replies'] = 1
else:
@@ -1776,19 +1778,27 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
response = try_get(browse,
(lambda x: x['response'],
- lambda x: x[1]['response'])) or {}
+ lambda x: x[1]['response']), dict) or {}
if response.get('continuationContents'):
break
# YouTube sometimes gives reload: now json if something went wrong (e.g. bad auth)
- if browse.get('reload'):
- raise ExtractorError('Invalid or missing params in continuation request', expected=False)
+ if isinstance(browse, dict):
+ if browse.get('reload'):
+ raise ExtractorError('Invalid or missing params in continuation request', expected=False)
+
+ # TODO: not tested, merged from old extractor
+ err_msg = browse.get('externalErrorMessage')
+ if err_msg:
+ last_error = err_msg
+ continue
- # TODO: not tested, merged from old extractor
- err_msg = browse.get('externalErrorMessage')
+ response_error = try_get(response, lambda x: x['responseContext']['errors']['error'][0], dict) or {}
+ err_msg = response_error.get('externalErrorMessage')
if err_msg:
- raise ExtractorError('YouTube said: %s' % err_msg, expected=False)
+ last_error = err_msg
+ continue
# Youtube sometimes sends incomplete data
# See: https://github.com/ytdl-org/youtube-dl/issues/28194