[cleanup] Misc cleanup and refactor (#2173)

This commit is contained in:
pukkandan 2022-04-18 02:28:28 +05:30
parent b6dc37fe2a
commit 19a0394044
No known key found for this signature in database
GPG key ID: 7EEE9E1E817D0A39
31 changed files with 263 additions and 345 deletions

View file

@ -3586,17 +3586,17 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
headers=self.generate_api_headers(ytcfg=master_ytcfg),
note='Downloading initial data API JSON')
try:
# This will error if there is no livechat
try: # This will error if there is no livechat
initial_data['contents']['twoColumnWatchNextResults']['conversationBar']['liveChatRenderer']['continuations'][0]['reloadContinuationData']['continuation']
except (KeyError, IndexError, TypeError):
pass
else:
info.setdefault('subtitles', {})['live_chat'] = [{
'url': 'https://www.youtube.com/watch?v=%s' % video_id, # url is needed to set cookies
'url': f'https://www.youtube.com/watch?v={video_id}', # url is needed to set cookies
'video_id': video_id,
'ext': 'json',
'protocol': 'youtube_live_chat' if is_live or is_upcoming else 'youtube_live_chat_replay',
}]
except (KeyError, IndexError, TypeError):
pass
if initial_data:
info['chapters'] = (