mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-03-09 12:50:23 -05:00
Merge 370347c3f8
into 05c8023a27
This commit is contained in:
commit
b59a2212a3
1 changed files with 31 additions and 1 deletions
|
@ -5,7 +5,9 @@
|
|||
from .common import InfoExtractor
|
||||
from ..utils import (
|
||||
ExtractorError,
|
||||
determine_ext,
|
||||
float_or_none,
|
||||
join_nonempty,
|
||||
mimetype2ext,
|
||||
smuggle_url,
|
||||
str_or_none,
|
||||
|
@ -268,7 +270,33 @@ def _real_extract(self, url):
|
|||
formats.extend(stream_formats)
|
||||
|
||||
# XXX: Presentation['Presenters']
|
||||
# XXX: Presentation['Transcript']
|
||||
transcripts = presentation.get('Transcripts', [])
|
||||
captions, subtitles = {}, {}
|
||||
for transcript in transcripts:
|
||||
lang_code = traverse_obj(
|
||||
transcript, (('DetailedLanguageCode', 'LanguageCode'), {str}), get_all=False) or 'und'
|
||||
lang_name = transcript.get('Language')
|
||||
t = {
|
||||
'url': transcript.get('CaptionsUrl'),
|
||||
'name': lang_name,
|
||||
}
|
||||
if 'Auto-Generated' in lang_name:
|
||||
captions.setdefault(lang_code, []).append(t)
|
||||
else:
|
||||
subtitles.setdefault(lang_code, []).append(t)
|
||||
if transcript_url := url_or_none(presentation.get('TranscriptUrl')):
|
||||
if 'playbackTicket=' not in transcript_url:
|
||||
transcript_url = join_nonempty(
|
||||
transcript_url, traverse_obj(presentation, ('Streams', 0, 'SlidePlaybackTicketId', {str})),
|
||||
delim='?playbackTicket=')
|
||||
if determine_ext(transcript_url) != 'txt':
|
||||
if len(transcripts) == 1:
|
||||
(captions or subtitles)[lang_code].insert(0, {
|
||||
'url': transcript_url,
|
||||
'name': lang_name,
|
||||
})
|
||||
else:
|
||||
subtitles.setdefault('und', []).insert(0, {'url': transcript_url})
|
||||
|
||||
return {
|
||||
'id': resource_id,
|
||||
|
@ -277,6 +305,8 @@ def _real_extract(self, url):
|
|||
'duration': float_or_none(presentation.get('Duration'), 1000),
|
||||
'timestamp': float_or_none(presentation.get('UnixTime'), 1000),
|
||||
'formats': formats,
|
||||
'automatic_captions': captions,
|
||||
'subtitles': subtitles,
|
||||
'thumbnails': thumbnails,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue