mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-04 04:06:56 +01:00
[youtube:comments] Fix error handling and add itct
to params (#446)
Should close #439 (untested) Authored by: colethedj
This commit is contained in:
parent
49c258e18d
commit
45261e063b
@ -1731,6 +1731,8 @@ def extract_thread(parent_renderer):
|
|||||||
'pbj': 1,
|
'pbj': 1,
|
||||||
'type': 'next',
|
'type': 'next',
|
||||||
}
|
}
|
||||||
|
if 'itct' in continuation:
|
||||||
|
query['itct'] = continuation['itct']
|
||||||
if parent:
|
if parent:
|
||||||
query['action_get_comment_replies'] = 1
|
query['action_get_comment_replies'] = 1
|
||||||
else:
|
else:
|
||||||
@ -1776,19 +1778,27 @@ def extract_thread(parent_renderer):
|
|||||||
|
|
||||||
response = try_get(browse,
|
response = try_get(browse,
|
||||||
(lambda x: x['response'],
|
(lambda x: x['response'],
|
||||||
lambda x: x[1]['response'])) or {}
|
lambda x: x[1]['response']), dict) or {}
|
||||||
|
|
||||||
if response.get('continuationContents'):
|
if response.get('continuationContents'):
|
||||||
break
|
break
|
||||||
|
|
||||||
# YouTube sometimes gives reload: now json if something went wrong (e.g. bad auth)
|
# YouTube sometimes gives reload: now json if something went wrong (e.g. bad auth)
|
||||||
|
if isinstance(browse, dict):
|
||||||
if browse.get('reload'):
|
if browse.get('reload'):
|
||||||
raise ExtractorError('Invalid or missing params in continuation request', expected=False)
|
raise ExtractorError('Invalid or missing params in continuation request', expected=False)
|
||||||
|
|
||||||
# TODO: not tested, merged from old extractor
|
# TODO: not tested, merged from old extractor
|
||||||
err_msg = browse.get('externalErrorMessage')
|
err_msg = browse.get('externalErrorMessage')
|
||||||
if err_msg:
|
if err_msg:
|
||||||
raise ExtractorError('YouTube said: %s' % err_msg, expected=False)
|
last_error = err_msg
|
||||||
|
continue
|
||||||
|
|
||||||
|
response_error = try_get(response, lambda x: x['responseContext']['errors']['error'][0], dict) or {}
|
||||||
|
err_msg = response_error.get('externalErrorMessage')
|
||||||
|
if err_msg:
|
||||||
|
last_error = err_msg
|
||||||
|
continue
|
||||||
|
|
||||||
# Youtube sometimes sends incomplete data
|
# Youtube sometimes sends incomplete data
|
||||||
# See: https://github.com/ytdl-org/youtube-dl/issues/28194
|
# See: https://github.com/ytdl-org/youtube-dl/issues/28194
|
||||||
|
Loading…
Reference in New Issue
Block a user