Compare commits

..

No commits in common. "23e2bc581b6f88d9b9490e0e5b30e46c01c29bc4" and "5a63b0ec715a7e6879ebe16bef6bdd0d87d7ec7a" have entirely different histories.

View File

@ -19,7 +19,6 @@ from ..utils import (
get_element_by_id,
get_first,
int_or_none,
join_nonempty,
js_to_json,
merge_dicts,
parse_count,
@ -422,25 +421,29 @@ class FacebookIE(InfoExtractor):
post = traverse_obj(post_data, (
..., 'require', ..., ..., ..., '__bbox', 'require', ..., ..., ..., '__bbox', 'result', 'data'), expected_type=dict) or []
snippet = 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')), expected_type=dict) or {}
locale = self._html_search_meta(['og:locale', 'twitter:locale'], webpage, 'locale', default='en_US')
captions = get_first(snippet, 'video_available_captions_locales', 'captions_url')
is_video_broadcast = get_first(snippet, 'is_video_broadcast', expected_type=bool)
useIsVideoBroadcast = get_first(snippet, ('is_video_broadcast')) or False
automatic_captions = {}
subtitles = {}
if url_or_none(captions): # snippet only had 'captions_url'
subtitles[locale] = [{'url': captions}]
else:
captions = sorted(captions, key=lambda c: c['locale'])
for caption in traverse_obj(captions, lambda _, v: v['captions_url'] and v['locale']):
subs = {
'url': caption['captions_url'],
'name': join_nonempty('localized_language', 'localized_country', from_dict=caption),
if isinstance(captions, str):
subtitles[locale] = [{'ext': determine_ext(captions, default_ext='srt'), 'url': captions}]
elif isinstance(captions, list):
if len(captions) > 1:
captions = sorted(captions, key=lambda c: (c['locale'] != locale, c['locale']))
for c in captions:
s = {
'ext': determine_ext(c['captions_url'], default_ext='srt'),
'url': c['captions_url'],
'name': (c['localized_language']
+ (' (' + c['localized_country'] + ')' if c['localized_country'] else '')
+ (' (' + c['localized_creation_method'] + ')' if c['localized_creation_method'] else '')),
}
if caption.get('localized_creation_method') or is_video_broadcast:
automatic_captions.setdefault(caption['locale'], []).append(subs)
if c['localized_creation_method'] or useIsVideoBroadcast:
automatic_captions.setdefault(c['locale'], []).append(s)
else:
subtitles.setdefault(caption['locale'], []).append(subs)
subtitles.setdefault(c['locale'], []).append(s)
media = traverse_obj(post, (..., 'attachments', ..., lambda k, v: (
k == 'media' and str(v['id']) == video_id and v['__typename'] == 'Video')), expected_type=dict)
title = get_first(media, ('title', 'text'))
@ -731,7 +734,6 @@ class FacebookIE(InfoExtractor):
video_data = video_data[0]
formats = []
subtitles = {}
for f in video_data:
format_id = f['stream_type']
if f and isinstance(f, dict):
@ -754,14 +756,10 @@ class FacebookIE(InfoExtractor):
'height': 720 if quality == 'hd' else None
})
extract_dash_manifest(f[0], formats)
subtitles_src = f[0].get('subtitles_src')
if subtitles_src:
subtitles.setdefault('en', []).append({'url': subtitles_src})
info_dict = {
'id': video_id,
'formats': formats,
'subtitles': subtitles,
}
process_formats(info_dict)
info_dict.update(extract_metadata(webpage))