mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-12 14:26:49 +01:00
check live chat replay existence
This commit is contained in:
parent
a78e3a5795
commit
321bf820c5
@ -1838,10 +1838,11 @@ def dl(name, info):
|
|||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
# TODO does this transfer session...?
|
|
||||||
# TODO exceptions
|
|
||||||
dl(sub_filename, sub_info)
|
dl(sub_filename, sub_info)
|
||||||
except (ExtractorError, IOError, OSError, ValueError) as err:
|
except (
|
||||||
|
ExtractorError, IOError, OSError, ValueError,
|
||||||
|
compat_urllib_error.URLError,
|
||||||
|
compat_http_client.HTTPException, socket.error) as err:
|
||||||
self.report_warning('Unable to download subtitle for "%s": %s' %
|
self.report_warning('Unable to download subtitle for "%s": %s' %
|
||||||
(sub_lang, error_to_compat_str(err)))
|
(sub_lang, error_to_compat_str(err)))
|
||||||
continue
|
continue
|
||||||
|
@ -1435,7 +1435,7 @@ def _decrypt_signature(self, s, video_id, player_url, age_gate=False):
|
|||||||
raise ExtractorError(
|
raise ExtractorError(
|
||||||
'Signature extraction failed: ' + tb, cause=e)
|
'Signature extraction failed: ' + tb, cause=e)
|
||||||
|
|
||||||
def _get_subtitles(self, video_id, webpage):
|
def _get_subtitles(self, video_id, webpage, is_live_content):
|
||||||
try:
|
try:
|
||||||
subs_doc = self._download_xml(
|
subs_doc = self._download_xml(
|
||||||
'https://video.google.com/timedtext?hl=en&type=list&v=%s' % video_id,
|
'https://video.google.com/timedtext?hl=en&type=list&v=%s' % video_id,
|
||||||
@ -1462,14 +1462,14 @@ def _get_subtitles(self, video_id, webpage):
|
|||||||
'ext': ext,
|
'ext': ext,
|
||||||
})
|
})
|
||||||
sub_lang_list[lang] = sub_formats
|
sub_lang_list[lang] = sub_formats
|
||||||
# TODO check that live chat replay actually exists
|
if is_live_content:
|
||||||
sub_lang_list['live_chat'] = [
|
sub_lang_list['live_chat'] = [
|
||||||
{
|
{
|
||||||
'video_id': video_id,
|
'video_id': video_id,
|
||||||
'ext': 'json',
|
'ext': 'json',
|
||||||
'protocol': 'youtube_live_chat_replay',
|
'protocol': 'youtube_live_chat_replay',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
if not sub_lang_list:
|
if not sub_lang_list:
|
||||||
self._downloader.report_warning('video doesn\'t have subtitles')
|
self._downloader.report_warning('video doesn\'t have subtitles')
|
||||||
return {}
|
return {}
|
||||||
@ -1493,6 +1493,14 @@ def _get_ytplayer_config(self, video_id, webpage):
|
|||||||
return self._parse_json(
|
return self._parse_json(
|
||||||
uppercase_escape(config), video_id, fatal=False)
|
uppercase_escape(config), video_id, fatal=False)
|
||||||
|
|
||||||
|
def _get_yt_initial_data(self, video_id, webpage):
|
||||||
|
config = self._search_regex(
|
||||||
|
r'window\["ytInitialData"\]\s*=\s*(.*);',
|
||||||
|
webpage, 'ytInitialData', default=None)
|
||||||
|
if config:
|
||||||
|
return self._parse_json(
|
||||||
|
uppercase_escape(config), video_id, fatal=False)
|
||||||
|
|
||||||
def _get_automatic_captions(self, video_id, webpage):
|
def _get_automatic_captions(self, video_id, webpage):
|
||||||
"""We need the webpage for getting the captions url, pass it as an
|
"""We need the webpage for getting the captions url, pass it as an
|
||||||
argument to speed up the process."""
|
argument to speed up the process."""
|
||||||
@ -1992,6 +2000,16 @@ def feed_entry(name):
|
|||||||
if is_live is None:
|
if is_live is None:
|
||||||
is_live = bool_or_none(video_details.get('isLive'))
|
is_live = bool_or_none(video_details.get('isLive'))
|
||||||
|
|
||||||
|
has_live_chat_replay = False
|
||||||
|
is_live_content = bool_or_none(video_details.get('isLiveContent'))
|
||||||
|
if not is_live and is_live_content:
|
||||||
|
yt_initial_data = self._get_yt_initial_data(video_id, video_webpage)
|
||||||
|
try:
|
||||||
|
yt_initial_data['contents']['twoColumnWatchNextResults']['conversationBar']['liveChatRenderer']['continuations'][0]['reloadContinuationData']['continuation']
|
||||||
|
has_live_chat_replay = True
|
||||||
|
except (KeyError, IndexError):
|
||||||
|
pass
|
||||||
|
|
||||||
# Check for "rental" videos
|
# Check for "rental" videos
|
||||||
if 'ypc_video_rental_bar_text' in video_info and 'author' not in video_info:
|
if 'ypc_video_rental_bar_text' in video_info and 'author' not in video_info:
|
||||||
raise ExtractorError('"rental" videos not supported. See https://github.com/ytdl-org/youtube-dl/issues/359 for more information.', expected=True)
|
raise ExtractorError('"rental" videos not supported. See https://github.com/ytdl-org/youtube-dl/issues/359 for more information.', expected=True)
|
||||||
@ -2399,7 +2417,8 @@ def _extract_count(count_name):
|
|||||||
or try_get(video_info, lambda x: float_or_none(x['avg_rating'][0])))
|
or try_get(video_info, lambda x: float_or_none(x['avg_rating'][0])))
|
||||||
|
|
||||||
# subtitles
|
# subtitles
|
||||||
video_subtitles = self.extract_subtitles(video_id, video_webpage)
|
video_subtitles = self.extract_subtitles(
|
||||||
|
video_id, video_webpage, has_live_chat_replay)
|
||||||
automatic_captions = self.extract_automatic_captions(video_id, video_webpage)
|
automatic_captions = self.extract_automatic_captions(video_id, video_webpage)
|
||||||
|
|
||||||
video_duration = try_get(
|
video_duration = try_get(
|
||||||
|
Loading…
Reference in New Issue
Block a user