Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/facebook.py (Python)

Code before:
                        if determine_ext(playable_url) == 'mpd':
                            formats.extend(self._extract_mpd_formats(playable_url, video_id))
                        else:
                            formats.append({
                                'format_id': format_id,
                                # sd, hd formats w/o resolution info should be deprioritized below DASH
                                'quality': q(format_id) - 3,
                                'url': playable_url,
                            })
                    extract_dash_manifest(video, formats)

                    automatic_captions, subtitles = {}, {}
                    is_video_broadcast = get_first([video], 'is_video_broadcast', expected_type=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', '')
                        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:
                            automatic_captions.setdefault(caption['locale'], []).append(subs)
                        else:
                            subtitles.setdefault(caption['locale'], []).append(subs)

                    info = {
                        'id': v_id,
                        'formats': formats,
                        'thumbnail': traverse_obj(
                            video, ('thumbnailImage', 'uri'), ('preferred_thumbnail', 'image', 'uri')),
                        'uploader_id': traverse_obj(video, ('owner', 'id', {str_or_none})),
                        'timestamp': traverse_obj(video, 'publish_time', 'creation_time', expected_type=int_or_none),
                        'duration': (float_or_none(video.get('playable_duration_in_ms'), 1000)
                                     or float_or_none(video.get('length_in_second'))),
                        'automatic_captions': automatic_captions,
                        'subtitles': subtitles,
                    }
                    process_formats(info)
                    description = try_get(video, lambda x: x['savable_description']['text'])
                    title = video.get('name')

Review comment (suggestion):
we don't have use the same var for the single `captions_url` and the `captions` list anymore
```suggestion
                    if captions_url := traverse_obj(video, ('captions_url', {url_or_none})):
                        locale = self._html_search_meta(
                            ['og:locale', 'twitter:locale'], webpage, 'locale', default='en_US')
                        auto_gen = is_video_broadcast or traverse_obj(video, (
                            'video_available_captions_locales', ..., 'localized_creation_method'))
                        (automatic_captions if auto_gen else subtitles)[locale] = [{'url': captions_url}]
                    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'])
                    )):
```

Code after:
                        if determine_ext(playable_url) == 'mpd':
                            formats.extend(self._extract_mpd_formats(playable_url, video_id))
                        else:
                            formats.append({
                                'format_id': format_id,
                                # sd, hd formats w/o resolution info should be deprioritized below DASH
                                'quality': q(format_id) - 3,
                                'url': playable_url,
                            })
                    extract_dash_manifest(video, formats)

                    automatic_captions, subtitles = {}, {}
                    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_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,
                        'formats': formats,
                        'thumbnail': traverse_obj(
                            video, ('thumbnailImage', 'uri'), ('preferred_thumbnail', 'image', 'uri')),
                        'uploader_id': traverse_obj(video, ('owner', 'id', {str_or_none})),
                        'timestamp': traverse_obj(video, 'publish_time', 'creation_time', expected_type=int_or_none),
                        'duration': (float_or_none(video.get('playable_duration_in_ms'), 1000)
                                     or float_or_none(video.get('length_in_second'))),
                        'automatic_captions': automatic_captions,
                        'subtitles': subtitles,
                    }
                    process_formats(info)
                    description = try_get(video, lambda x: x['savable_description']['text'])
                    title = video.get('name')
                    if title:
                        info.update({
                            'title': title,