mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-09-20 01:11:23 +02:00
Compare commits
No commits in common. "1d43d1f47900977e14e4365060948377cb3379ea" and "ef0c79214a49d5547ab5d44e6a243f125b8e9eb7" have entirely different histories.
1d43d1f479
...
ef0c79214a
|
@ -422,30 +422,25 @@ class FacebookIE(InfoExtractor):
|
|||
..., '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')), expected_type=dict) or {}
|
||||
locale = self._html_search_meta(['og:locale', 'twitter:locale'], webpage, 'locale', default='en_US')
|
||||
locale = self._html_search_regex((self._meta_regex('og:locale'), self._meta_regex('twitter:locale')), webpage, 'locale', group='content')
|
||||
captions = get_first(snippet, ('video_available_captions_locales')) or get_first(snippet, ('captions_url')) or None
|
||||
automatic_captions = {}
|
||||
subtitles = {}
|
||||
if isinstance(captions, str):
|
||||
subtitles[locale] = [{'ext': self._search_regex(r'\.(\w{3,})\?', captions, 'captions_ext', default='srt'), 'url': captions}]
|
||||
elif isinstance(captions, list):
|
||||
if len(captions) > 1:
|
||||
captions = sorted(captions, key=lambda c: (c['locale'] != locale, c['locale']))
|
||||
subtitles[locale] = [{'ext': 'srt', 'url': captions}]
|
||||
elif captions:
|
||||
for c in captions:
|
||||
s = {
|
||||
'ext': self._search_regex(r'\.(\w{3,})\?', c['captions_url'], 'captions_ext', default='srt'),
|
||||
subtitles[c['locale']] = [{
|
||||
'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 '')),
|
||||
}
|
||||
# observed 'localized_creation_method' value: null, "Auto-generated"(translated into diff lang)
|
||||
# if a 3rd method exists, captions created by such method will be categorized into automatic_captions
|
||||
# TODO: better way to distinguish auto-generated captions from other captions
|
||||
if c['localized_creation_method']:
|
||||
automatic_captions.setdefault(c['locale'], []).append(s)
|
||||
else:
|
||||
subtitles.setdefault(c['locale'], []).append(s)
|
||||
}]
|
||||
lang = list(subtitles.keys())
|
||||
lang.sort()
|
||||
if lang.index(locale):
|
||||
lang.insert(0, lang.pop(lang.index(locale)))
|
||||
subtitles = {i: subtitles[i] for i in lang}
|
||||
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'))
|
||||
|
@ -489,7 +484,6 @@ class FacebookIE(InfoExtractor):
|
|||
webpage, 'view count', default=None)),
|
||||
'concurrent_view_count': get_first(post, (
|
||||
('video', (..., ..., 'attachments', ..., 'media')), 'liveViewerCount', {int_or_none})),
|
||||
'automatic_captions': automatic_captions,
|
||||
'subtitles': subtitles,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user