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

Code before:
    }, {
        'url': 'https://www.9news.com.au/national/outrage-as-parents-banned-from-giving-gifts-to-kindergarten-teachers/e19b49d4-a1a4-4533-9089-6e10e2d9386a',
        'info_dict': {
            'id': '6343716797112',
            'ext': 'mp4',
            'title': 'Outrage as parents banned from giving gifts to kindergarten teachers',
            'description': 'md5:7a8b0ed2f9e08875fd9a3e86e462bc46',
            'thumbnail': 'md5:5ee4d66717bdd0dee9fc9a705ef041b8',
            'duration': 91.307,
            'timestamp': 1703229584,
            'upload_date': '20231222',
            'uploader_id': '664969388001',
            'tags': ['networkclip', 'aunews_aunationalninenews', 'presents', 'teachers', 'kindergarten', 'au_news'],
        },
    }]

    def _real_extract(self, url):
        article_id = self._match_id(url)
        webpage = self._download_webpage(url, article_id)
        initial_state = self._search_json(
            r'var\s+__INITIAL_STATE__\s*=', webpage, 'initial state', article_id)
        video_id = traverse_obj(
            initial_state, ('videoIndex', 'currentVideo', 'brightcoveId'),
            ('article', ..., 'media', lambda _, v: v['type'] == 'video', 'urn'), get_all=False)
        account = traverse_obj(initial_state, (
            'videoIndex', 'config', (None, 'video'), 'account'), get_all=False)

        if not video_id or not account:
            raise ExtractorError('Unable to get the required video data')

        return self.url_result(
            f'https://players.brightcove.net/{account}/default_default/index.html?videoId={video_id}',
            ie=BrightcoveNewIE, video_id=video_id)


Review comment (suggestion):
```suggestion
        video_id = traverse_obj(
            initial_state, ('videoIndex', 'currentVideo', 'brightcoveId', {str}),
            ('article', ..., 'media', lambda _, v: v['type'] == 'video', 'urn', {str}), get_all=False)
        account = traverse_obj(initial_state, (
            'videoIndex', 'config', (None, 'video'), 'account', {str}), get_all=False)
```

Code after:
    }, {
        'url': 'https://www.9news.com.au/national/outrage-as-parents-banned-from-giving-gifts-to-kindergarten-teachers/e19b49d4-a1a4-4533-9089-6e10e2d9386a',
        'info_dict': {
            'id': '6343716797112',
            'ext': 'mp4',
            'title': 'Outrage as parents banned from giving gifts to kindergarten teachers',
            'description': 'md5:7a8b0ed2f9e08875fd9a3e86e462bc46',
            'thumbnail': 'md5:5ee4d66717bdd0dee9fc9a705ef041b8',
            'duration': 91.307,
            'timestamp': 1703229584,
            'upload_date': '20231222',
            'uploader_id': '664969388001',
            'tags': ['networkclip', 'aunews_aunationalninenews', 'presents', 'teachers', 'kindergarten', 'au_news'],
        },
    }]

    def _real_extract(self, url):
        article_id = self._match_id(url)
        webpage = self._download_webpage(url, article_id)
        initial_state = self._search_json(
            r'var\s+__INITIAL_STATE__\s*=', webpage, 'initial state', article_id)
        video_id = traverse_obj(
            initial_state, ('videoIndex', 'currentVideo', 'brightcoveId', {str}),
            ('article', ..., 'media', lambda _, v: v['type'] == 'video', 'urn', {str}), get_all=False)
        account = traverse_obj(initial_state, (
            'videoIndex', 'config', (None, 'video'), 'account', {str}), get_all=False)

        if not video_id or not account:
            raise ExtractorError('Unable to get the required video data')

        return self.url_result(
            f'https://players.brightcove.net/{account}/default_default/index.html?videoId={video_id}',
            BrightcoveNewIE, video_id)