mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-06-28 17:38:35 +00:00
twitch chat: review changes part 2
This commit is contained in:
parent
206ca4092b
commit
0aa41b8e84
@ -21,7 +21,6 @@
|
|||||||
parse_iso8601,
|
parse_iso8601,
|
||||||
parse_qs,
|
parse_qs,
|
||||||
qualities,
|
qualities,
|
||||||
RetryManager,
|
|
||||||
str_or_none,
|
str_or_none,
|
||||||
try_get,
|
try_get,
|
||||||
unified_timestamp,
|
unified_timestamp,
|
||||||
@ -561,8 +560,6 @@ def _get_subtitles(self, vod_id):
|
|||||||
|
|
||||||
for retry in self.RetryManager():
|
for retry in self.RetryManager():
|
||||||
response = self._download_gql(vod_id, gql_ops, 'Downloading chat fragment page %d' % pagenum, fatal=False)
|
response = self._download_gql(vod_id, gql_ops, 'Downloading chat fragment page %d' % pagenum, fatal=False)
|
||||||
# response = False
|
|
||||||
# TODO: delete the direct False, uncomment _download_gql
|
|
||||||
|
|
||||||
if response is False:
|
if response is False:
|
||||||
retry.error = ExtractorError("f'Unable to fetch next chat history fragment.'", video_id=vod_id, ie=self)
|
retry.error = ExtractorError("f'Unable to fetch next chat history fragment.'", video_id=vod_id, ie=self)
|
||||||
@ -570,8 +567,6 @@ def _get_subtitles(self, vod_id):
|
|||||||
# TODO: when this happens, should I forget a partial chat history, or is it better to keep it?
|
# TODO: when this happens, should I forget a partial chat history, or is it better to keep it?
|
||||||
# I think if I keep it, it might be better to persist a warning that it is incomplete
|
# I think if I keep it, it might be better to persist a warning that it is incomplete
|
||||||
|
|
||||||
# time.sleep(5)
|
|
||||||
|
|
||||||
response_errors = traverse_obj(response, (..., 'errors'))
|
response_errors = traverse_obj(response, (..., 'errors'))
|
||||||
if response_errors:
|
if response_errors:
|
||||||
self.report_warning(f"Error response recevied for fetching next chat history fragment: {response_errors}")
|
self.report_warning(f"Error response recevied for fetching next chat history fragment: {response_errors}")
|
||||||
@ -600,8 +595,8 @@ def _get_subtitles(self, vod_id):
|
|||||||
|
|
||||||
if not chat_history:
|
if not chat_history:
|
||||||
return
|
return
|
||||||
|
else:
|
||||||
self.to_screen('Extracted %d chat messages' % len(chat_history))
|
self.write_debug(f'Extracted {len(chat_history)} chat messages')
|
||||||
|
|
||||||
return {'rechat': [{
|
return {'rechat': [{
|
||||||
'data': json.dumps(chat_history),
|
'data': json.dumps(chat_history),
|
||||||
@ -628,7 +623,12 @@ def _real_extract(self, url):
|
|||||||
info['start_time'] = parse_duration(query['t'][0])
|
info['start_time'] = parse_duration(query['t'][0])
|
||||||
|
|
||||||
if info.get('timestamp'):
|
if info.get('timestamp'):
|
||||||
info['subtitles'] = self.extract_subtitles(vod_id)
|
info['subtitles'] = {'rechat': [{
|
||||||
|
'url': update_url_query(f'https://api.twitch.tv/v5/videos/{vod_id}/comments',
|
||||||
|
{'client_id': self._CLIENT_ID}),
|
||||||
|
'ext': 'json',
|
||||||
|
}]},
|
||||||
|
info['__post_extractor'] = lambda: {'subtitles': self.extract_subtitles(vod_id)}
|
||||||
|
|
||||||
return info
|
return info
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user