mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-09-24 03:11:24 +02:00
Compare commits
5 Commits
5a63b0ec71
...
23e2bc581b
Author | SHA1 | Date | |
---|---|---|---|
|
23e2bc581b | ||
|
98ee02d751 | ||
|
1e973dfe62 | ||
|
31e28ccfd6 | ||
|
c7a1cb0d3b |
|
@ -19,6 +19,7 @@ from ..utils import (
|
||||||
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,29 +422,25 @@ class FacebookIE(InfoExtractor):
|
||||||
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: (
|
snippet = traverse_obj(post, (..., 'video', ..., 'attachments', ..., lambda k, v: (
|
||||||
k == 'media' and str(v['id']) == video_id and v['__typename'] == 'Video')), expected_type=dict) or {}
|
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')
|
locale = self._html_search_meta(['og:locale', 'twitter:locale'], webpage, 'locale', default='en_US')
|
||||||
captions = get_first(snippet, 'video_available_captions_locales', 'captions_url')
|
captions = get_first(snippet, 'video_available_captions_locales', 'captions_url')
|
||||||
useIsVideoBroadcast = get_first(snippet, ('is_video_broadcast')) or False
|
is_video_broadcast = get_first(snippet, 'is_video_broadcast', expected_type=bool)
|
||||||
automatic_captions = {}
|
automatic_captions = {}
|
||||||
subtitles = {}
|
subtitles = {}
|
||||||
if isinstance(captions, str):
|
if url_or_none(captions): # snippet only had 'captions_url'
|
||||||
subtitles[locale] = [{'ext': determine_ext(captions, default_ext='srt'), 'url': captions}]
|
subtitles[locale] = [{'url': captions}]
|
||||||
elif isinstance(captions, list):
|
else:
|
||||||
if len(captions) > 1:
|
captions = sorted(captions, key=lambda c: c['locale'])
|
||||||
captions = sorted(captions, key=lambda c: (c['locale'] != locale, c['locale']))
|
for caption in traverse_obj(captions, lambda _, v: v['captions_url'] and v['locale']):
|
||||||
for c in captions:
|
subs = {
|
||||||
s = {
|
'url': caption['captions_url'],
|
||||||
'ext': determine_ext(c['captions_url'], default_ext='srt'),
|
'name': join_nonempty('localized_language', 'localized_country', from_dict=caption),
|
||||||
'url': c['captions_url'],
|
}
|
||||||
'name': (c['localized_language']
|
if caption.get('localized_creation_method') or is_video_broadcast:
|
||||||
+ (' (' + c['localized_country'] + ')' if c['localized_country'] else '')
|
automatic_captions.setdefault(caption['locale'], []).append(subs)
|
||||||
+ (' (' + c['localized_creation_method'] + ')' if c['localized_creation_method'] else '')),
|
else:
|
||||||
}
|
subtitles.setdefault(caption['locale'], []).append(subs)
|
||||||
if c['localized_creation_method'] or useIsVideoBroadcast:
|
|
||||||
automatic_captions.setdefault(c['locale'], []).append(s)
|
|
||||||
else:
|
|
||||||
subtitles.setdefault(c['locale'], []).append(s)
|
|
||||||
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'))
|
||||||
|
@ -734,6 +731,7 @@ class FacebookIE(InfoExtractor):
|
||||||
video_data = video_data[0]
|
video_data = video_data[0]
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
|
subtitles = {}
|
||||||
for f in video_data:
|
for f in video_data:
|
||||||
format_id = f['stream_type']
|
format_id = f['stream_type']
|
||||||
if f and isinstance(f, dict):
|
if f and isinstance(f, dict):
|
||||||
|
@ -756,10 +754,14 @@ class FacebookIE(InfoExtractor):
|
||||||
'height': 720 if quality == 'hd' else None
|
'height': 720 if quality == 'hd' else None
|
||||||
})
|
})
|
||||||
extract_dash_manifest(f[0], formats)
|
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 = {
|
info_dict = {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
|
'subtitles': subtitles,
|
||||||
}
|
}
|
||||||
process_formats(info_dict)
|
process_formats(info_dict)
|
||||||
info_dict.update(extract_metadata(webpage))
|
info_dict.update(extract_metadata(webpage))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user