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

Code before:
                        'description': strip_or_none(item_desc),
                    })
            for resp in (initial_data.get('data') or {}).values():
                name = resp.get('name')
                if name == 'media-experience':
                    parse_media(try_get(resp, lambda x: x['data']['initialItem']['mediaItem'], dict))
                elif name == 'article':
                    for block in (try_get(resp,
                                          (lambda x: x['data']['blocks'],
                                           lambda x: x['data']['content']['model']['blocks'],),
                                          list) or []):
                        if block.get('type') not in ['media', 'video']:
                            continue
                        parse_media(block.get('model'))
            return self.playlist_result(
                entries, playlist_id, playlist_title, playlist_description)

        def extract_all(pattern):
            return list(filter(None, map(
                lambda s: self._parse_json(s, playlist_id, fatal=False),
                re.findall(pattern, webpage))))

        # US accessed article with single embedded video (e.g.
        # https://www.bbc.com/news/uk-68546268)
        next_data = traverse_obj(self._search_nextjs_data(webpage, playlist_id), (
            'props', 'pageProps', 'page'), get_all=False)
        video_data = traverse_obj(next_data, (
            ..., 'contents', lambda _, v: v['type'] == 'video'), get_all=False)
        if video_data:
            model = traverse_obj(video_data, (
                'model', 'blocks', lambda _, v: v['type'] == 'media',
                'model', 'blocks', lambda _, v: v['type'] == 'mediaMetadata',
                'model'), get_all=False)
            if model:
                timestamp = traverse_obj(next_data, (
                    ..., 'contents', lambda _, v: v['type'] == 'timestamp',
                    'model', 'timestamp', {int_or_none}, any))
                item_id = traverse_obj(model, ('versions', 0, 'versionId', {str}))
                formats, subtitles = self._download_media_selector(item_id)
                entries.append({
                    'id': item_id,
                    'formats': formats,
                    'subtitles': subtitles,
                    'timestamp': timestamp,
                    **traverse_obj(model, {
                        'title': ('title', {str}),
                        'thumbnail': ('imageUrl', {url_or_none}),
                        'description': (
                            'synopses', ('long', 'medium', 'short'), {str}, any),
                    })
                })

Review comment (suggestion):
`_search_nextjs_data` is still fatal. needs a `default`. `get_all=False` is unnecessary

```suggestion
        next_data = traverse_obj(
            self._search_nextjs_data(webpage, playlist_id, default='{}'),
            ('props', 'pageProps', 'page', {dict}))
```

Code after:
                    'duration': parse_duration(clip.get('duration')),
                    'formats': formats,
                    'subtitles': subtitles,
                }
            bbc3_playlist = try_get(
                payload, lambda x: x['content']['bbcMedia']['playlist'],
                dict)
            if bbc3_playlist:
                playlist_title = bbc3_playlist.get('title') or playlist_title
                thumbnail = bbc3_playlist.get('holdingImageURL')
                entries = []
                for bbc3_item in bbc3_playlist['items']:
                    programme_id = bbc3_item.get('versionID')
                    if not programme_id:
                        continue
                    formats, subtitles = self._download_media_selector(programme_id)
                    entries.append({
                        'id': programme_id,
                        'title': playlist_title,
                        'thumbnail': thumbnail,
                        'timestamp': timestamp,
                        'formats': formats,
                        'subtitles': subtitles,
                    })
                return self.playlist_result(
                    entries, playlist_id, playlist_title, playlist_description)

        def parse_model(model):
            """Extract single video from model structure"""
            item_id = traverse_obj(model, ('versions', 0, 'versionId', {str}))
            if not item_id:
                return
            formats, subtitles = self._download_media_selector(item_id)
            return {
                'id': item_id,
                'formats': formats,
                'subtitles': subtitles,
                **traverse_obj(model, {
                    'title': ('title', {str}),
                    'thumbnail': ('imageUrl', {lambda u: urljoin(url, u.replace('$recipe', 'raw'))}),
                    'description': ('synopses', ('long', 'medium', 'short'), {str}, {lambda x: x or None}, any),
                    'duration': ('versions', 0, 'duration', {int}),
                    'timestamp': ('versions', 0, 'availableFrom', {functools.partial(int_or_none, scale=1000)}),
                })
            }

        def is_type(*types):
            return lambda _, v: v['type'] in types

        initial_data = self._search_regex(
            r'window\.__INITIAL_DATA__\s*=\s*("{.+?}")\s*;', webpage,