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

Code before:
                        video, ('creation_story', 'short_form_video_context', 'playback_video', {dict}))
                    if reel_info:
                        video = video['creation_story']
                        video['owner'] = traverse_obj(video, ('short_form_video_context', 'video_owner'))
                        video.update(reel_info)
                    formats = []
                    q = qualities(['sd', 'hd'])
                    for key, format_id in (('playable_url', 'sd'), ('playable_url_quality_hd', 'hd'),
                                           ('playable_url_dash', ''), ('browser_native_hd_url', 'hd'),
                                           ('browser_native_sd_url', 'sd')):
                        playable_url = video.get(key)
                        if not playable_url:
                            continue
                        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,

Review comment (suggestion):
`get_first(x, y)` is just `traverse_obj(x, (..., y), get_all=False)`
```suggestion
                    is_video_broadcast = traverse_obj(video, ('is_video_broadcast', {bool}))
```

Code after:
                        video, ('creation_story', 'short_form_video_context', 'playback_video', {dict}))
                    if reel_info:
                        video = video['creation_story']
                        video['owner'] = traverse_obj(video, ('short_form_video_context', 'video_owner'))
                        video.update(reel_info)
                    formats = []
                    q = qualities(['sd', 'hd'])
                    for key, format_id in (('playable_url', 'sd'), ('playable_url_quality_hd', 'hd'),
                                           ('playable_url_dash', ''), ('browser_native_hd_url', 'hd'),
                                           ('browser_native_sd_url', 'sd')):
                        playable_url = video.get(key)
                        if not playable_url:
                            continue
                        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')),