mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-10-02 07:11:24 +02:00
Compare commits
4 Commits
3cec965e01
...
44ff3a76a6
Author | SHA1 | Date | |
---|---|---|---|
|
44ff3a76a6 | ||
|
0581aa7bde | ||
|
a44b51fe47 | ||
|
6d51a4d065 |
|
@ -605,29 +605,26 @@ class FacebookIE(InfoExtractor):
|
|||
extract_dash_manifest(video, formats)
|
||||
|
||||
automatic_captions, subtitles = {}, {}
|
||||
is_video_broadcast = traverse_obj(video, ('is_video_broadcast', {bool}))
|
||||
captions = (traverse_obj(video,
|
||||
('video_available_captions_locales', lambda _, v: 'captions_url' in v))
|
||||
or video.get('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')
|
||||
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', '')
|
||||
is_broadcast = traverse_obj(video, ('is_video_broadcast', {bool}))
|
||||
for caption in traverse_obj(video, (
|
||||
'video_available_captions_locales',
|
||||
{lambda x: sorted(x, key=lambda c: c['locale'])},
|
||||
lambda _, v: url_or_none(v['captions_url'])
|
||||
)):
|
||||
lang = caption.get('localized_language') or 'und'
|
||||
subs = {
|
||||
'url': caption['captions_url'],
|
||||
'name': format_field(caption, 'localized_country', f'{lang} (%s)', default=lang),
|
||||
}
|
||||
if caption.get('localized_creation_method') or is_video_broadcast:
|
||||
if caption.get('localized_creation_method') or is_broadcast:
|
||||
automatic_captions.setdefault(caption['locale'], []).append(subs)
|
||||
else:
|
||||
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 = {
|
||||
'id': v_id,
|
||||
|
|
Loading…
Reference in New Issue
Block a user