mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-24 08:11:31 +01:00
Compare commits
4 Commits
ef4737ea7a
...
573cdcfe20
Author | SHA1 | Date | |
---|---|---|---|
|
573cdcfe20 | ||
|
a9a48d451b | ||
|
f592d4d2f4 | ||
|
67d79a6f80 |
|
@ -16,10 +16,10 @@ from ..utils import (
|
||||||
determine_ext,
|
determine_ext,
|
||||||
error_to_compat_str,
|
error_to_compat_str,
|
||||||
float_or_none,
|
float_or_none,
|
||||||
|
format_field,
|
||||||
get_element_by_id,
|
get_element_by_id,
|
||||||
get_first,
|
get_first,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
join_nonempty,
|
|
||||||
js_to_json,
|
js_to_json,
|
||||||
merge_dicts,
|
merge_dicts,
|
||||||
parse_count,
|
parse_count,
|
||||||
|
@ -421,26 +421,29 @@ class FacebookIE(InfoExtractor):
|
||||||
r'data-sjs>({.*?ScheduledServerJS.*?})</script>', webpage)]
|
r'data-sjs>({.*?ScheduledServerJS.*?})</script>', webpage)]
|
||||||
post = traverse_obj(post_data, (
|
post = traverse_obj(post_data, (
|
||||||
..., 'require', ..., ..., ..., '__bbox', 'require', ..., ..., ..., '__bbox', 'result', 'data'), expected_type=dict) or []
|
..., 'require', ..., ..., ..., '__bbox', 'require', ..., ..., ..., '__bbox', 'result', 'data'), expected_type=dict) or []
|
||||||
snippet = traverse_obj(post, (..., 'video', ..., 'attachments', ..., lambda k, v: (
|
|
||||||
|
automatic_captions, subtitles = {}, {}
|
||||||
|
subs_data = traverse_obj(post, (..., 'video', ..., 'attachments', ..., lambda k, v: (
|
||||||
k == 'media' and str(v['id']) == video_id and v['__typename'] == 'Video')))
|
k == 'media' and str(v['id']) == video_id and v['__typename'] == 'Video')))
|
||||||
locale = self._html_search_meta(['og:locale', 'twitter:locale'], webpage, 'locale', default='en_US')
|
is_video_broadcast = get_first(subs_data, 'is_video_broadcast', expected_type=bool)
|
||||||
captions = get_first(snippet, 'video_available_captions_locales', 'captions_url')
|
captions = get_first(subs_data, 'video_available_captions_locales', 'captions_url')
|
||||||
is_video_broadcast = get_first(snippet, 'is_video_broadcast', expected_type=bool)
|
if url_or_none(captions): # if subs_data only had a 'captions_url'
|
||||||
automatic_captions = {}
|
locale = self._html_search_meta(['og:locale', 'twitter:locale'], webpage, 'locale', default='en_US')
|
||||||
subtitles = {}
|
|
||||||
if url_or_none(captions): # snippet only had 'captions_url'
|
|
||||||
subtitles[locale] = [{'url': captions}]
|
subtitles[locale] = [{'url': captions}]
|
||||||
|
# or else subs_data had 'video_available_captions_locales', a list of dicts
|
||||||
for caption in traverse_obj(captions, (
|
for caption in traverse_obj(captions, (
|
||||||
{lambda x: sorted(x, key=lambda c: c['locale'])}, lambda _, v: v['captions_url'])
|
{lambda x: sorted(x, key=lambda c: c['locale'])}, lambda _, v: v['captions_url'])
|
||||||
):
|
):
|
||||||
|
lang = caption.get('localized_language') or ''
|
||||||
subs = {
|
subs = {
|
||||||
'url': caption['captions_url'],
|
'url': caption['captions_url'],
|
||||||
'name': join_nonempty('localized_language', 'localized_country', from_dict=caption),
|
'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_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)
|
||||||
|
|
||||||
media = traverse_obj(post, (..., 'attachments', ..., lambda k, v: (
|
media = traverse_obj(post, (..., 'attachments', ..., lambda k, v: (
|
||||||
k == 'media' and str(v['id']) == video_id and v['__typename'] == 'Video')), expected_type=dict)
|
k == 'media' and str(v['id']) == video_id and v['__typename'] == 'Video')), expected_type=dict)
|
||||||
title = get_first(media, ('title', 'text'))
|
title = get_first(media, ('title', 'text'))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user