[Youtube] Choose correct Live chat API for upcoming streams (#460)

Authored by: krichbanana
This commit is contained in:
krichbanana 2021-07-01 20:29:29 -04:00 committed by GitHub
parent 109dd3b237
commit f6745c4980
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -2604,6 +2604,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
or microformat.get('lengthSeconds')) \ or microformat.get('lengthSeconds')) \
or parse_duration(search_meta('duration')) or parse_duration(search_meta('duration'))
is_live = video_details.get('isLive') is_live = video_details.get('isLive')
is_upcoming = video_details.get('isUpcoming')
owner_profile_url = microformat.get('ownerProfileUrl') owner_profile_url = microformat.get('ownerProfileUrl')
info = { info = {
@ -2729,7 +2730,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
'url': 'https://www.youtube.com/watch?v=%s' % video_id, # url is needed to set cookies 'url': 'https://www.youtube.com/watch?v=%s' % video_id, # url is needed to set cookies
'video_id': video_id, 'video_id': video_id,
'ext': 'json', 'ext': 'json',
'protocol': 'youtube_live_chat' if is_live else 'youtube_live_chat_replay', 'protocol': 'youtube_live_chat' if is_live or is_upcoming else 'youtube_live_chat_replay',
}] }]
except (KeyError, IndexError, TypeError): except (KeyError, IndexError, TypeError):
pass pass