mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-10-02 07:11:24 +02:00
Compare commits
No commits in common. "44ff3a76a6fb069ade831893e4f6be8330b4cb49" and "3cec965e01dce56717d75d01aaff6c3f87ee65f1" have entirely different histories.
44ff3a76a6
...
3cec965e01
|
@ -605,26 +605,29 @@ class FacebookIE(InfoExtractor):
|
||||||
extract_dash_manifest(video, formats)
|
extract_dash_manifest(video, formats)
|
||||||
|
|
||||||
automatic_captions, subtitles = {}, {}
|
automatic_captions, subtitles = {}, {}
|
||||||
is_broadcast = traverse_obj(video, ('is_video_broadcast', {bool}))
|
is_video_broadcast = traverse_obj(video, ('is_video_broadcast', {bool}))
|
||||||
for caption in traverse_obj(video, (
|
captions = (traverse_obj(video,
|
||||||
'video_available_captions_locales',
|
('video_available_captions_locales', lambda _, v: 'captions_url' in v))
|
||||||
{lambda x: sorted(x, key=lambda c: c['locale'])},
|
or video.get('captions_url'))
|
||||||
lambda _, v: url_or_none(v['captions_url'])
|
if url_or_none(captions): # if video only had a 'captions_url'
|
||||||
)):
|
locale = self._html_search_meta(['og:locale', 'twitter:locale'], webpage, 'locale', default='en_US')
|
||||||
lang = caption.get('localized_language') or 'und'
|
auto_gen = (traverse_obj(video,
|
||||||
|
('video_available_captions_locales', ..., 'localized_creation_method'), get_all=False)
|
||||||
|
or is_video_broadcast)
|
||||||
|
(automatic_captions if auto_gen else subtitles)[locale] = [{'url': captions}]
|
||||||
|
# or else video had 'video_available_captions_locales', a list of dicts
|
||||||
|
for caption in traverse_obj(captions, (
|
||||||
|
{lambda x: sorted(x, key=lambda c: c['locale'])}, lambda _, v: v['captions_url'])
|
||||||
|
):
|
||||||
|
lang = caption.get('localized_language', '')
|
||||||
subs = {
|
subs = {
|
||||||
'url': caption['captions_url'],
|
'url': caption['captions_url'],
|
||||||
'name': format_field(caption, 'localized_country', f'{lang} (%s)', default=lang),
|
'name': format_field(caption, 'localized_country', f'{lang} (%s)', default=lang),
|
||||||
}
|
}
|
||||||
if caption.get('localized_creation_method') or is_broadcast:
|
if caption.get('localized_creation_method') or is_video_broadcast:
|
||||||
automatic_captions.setdefault(caption['locale'], []).append(subs)
|
automatic_captions.setdefault(caption['locale'], []).append(subs)
|
||||||
else:
|
else:
|
||||||
subtitles.setdefault(caption['locale'], []).append(subs)
|
subtitles.setdefault(caption['locale'], []).append(subs)
|
||||||
captions_url = traverse_obj(video, ('captions_url', {url_or_none}))
|
|
||||||
if captions_url and not automatic_captions and not subtitles:
|
|
||||||
locale = self._html_search_meta(
|
|
||||||
['og:locale', 'twitter:locale'], webpage, 'locale', default='en_US')
|
|
||||||
(automatic_captions if is_broadcast else subtitles)[locale] = [{'url': captions_url}]
|
|
||||||
|
|
||||||
info = {
|
info = {
|
||||||
'id': v_id,
|
'id': v_id,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user