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

Code before:
        },
    }]

    _RESOLUTIONS = {
        '1080': '1920',
        '720': '1280',
        '540': '960',
        '360': '640',
        '234': '416',
    }

    def _real_extract(self, url):
        channel, video_id = self._match_valid_url(url).group('site', 'id')
        webpage = self._download_webpage(url, video_id)

        nbc_data = self._search_json(
            r'<script>var\s*nbc\s*=\s*', webpage, 'NBC JSON data', video_id)
        pdk_acct = nbc_data.get('pdkAcct') or 'Yh1nAC'
        fw_ssid = traverse_obj(nbc_data, ('video', 'fwSSID'))
        fw_network_id = traverse_obj(nbc_data, ('video', 'fwNetworkID'), default='382114')

        video_data = self._parse_json(self._html_search_regex(
            r'data-videos="([^"]*)"', webpage, 'video data', fatal=False, default='{}'), video_id)
        video_data = variadic(video_data)[0]
        video_data.update(self._parse_json(self._html_search_regex(
            r'data-meta="([^"]*)"', webpage, 'metadata', fatal=False, default='{}'), video_id))

        formats = []

        if video_data.get('mpx_is_livestream') == '1':
            live = True
            player_id = traverse_obj(
                video_data, 'mpx_m3upid', ('video', 'meta', 'mpx_m3upid'), 'mpx_pid',
                ('video', 'meta', 'mpx_pid'), 'pid_streaming_web_medium')
            query = {
                'mbr': 'true',
                'assetTypes': 'LegacyRelease',
                'fwsitesection': fw_ssid,
                'fwNetworkID': fw_network_id,
                'pprofile': 'ots_desktop_html',
                'sensitive': 'false',
                'w': '1920',
                'h': '1080',
                'rnd': '1660303',
                'mode': 'LIVE',
                'format': 'SMIL',
                'tracking': 'true',
                'formats': 'M3U+none,MPEG-DASH+none,MPEG4,MP3',
                'vpaid': 'script',
                'schema': '2.0',
                'SDK': 'PDK+6.1.3',

Review comment (suggestion):
```suggestion
            r'data-videos="([^"]*)"', webpage, 'video data', fdefault='{}'), video_id)
        video_data = variadic(video_data)[0]
        video_data.update(self._parse_json(self._html_search_regex(
            r'data-meta="([^"]*)"', webpage, 'metadata', default='{}'), video_id))
```
default implies non-fatal

Code after:
    }]

    _RESOLUTIONS = {
        '1080': '1920',
        '720': '1280',
        '540': '960',
        '360': '640',
        '234': '416',
    }

    def _real_extract(self, url):
        channel, video_id = self._match_valid_url(url).group('site', 'id')
        webpage = self._download_webpage(url, video_id)

        nbc_data = self._search_json(
            r'<script>var\s*nbc\s*=\s*', webpage, 'NBC JSON data', video_id)
        pdk_acct = nbc_data.get('pdkAcct') or 'Yh1nAC'
        fw_ssid = traverse_obj(nbc_data, ('video', 'fwSSID'))
        fw_network_id = traverse_obj(nbc_data, ('video', 'fwNetworkID'), default='382114')

        video_data = self._parse_json(self._html_search_regex(
            r'data-videos="([^"]*)"', webpage, 'video data', default='{}'), video_id)
        video_data = variadic(video_data)[0]
        video_data.update(self._parse_json(self._html_search_regex(
            r'data-meta="([^"]*)"', webpage, 'metadata', default='{}'), video_id))

        formats = []

        if video_data.get('mpx_is_livestream') == '1':
            live = True
            player_id = traverse_obj(
                video_data, 'mpx_m3upid', ('video', 'meta', 'mpx_m3upid'), 'mpx_pid',
                ('video', 'meta', 'mpx_pid'), 'pid_streaming_web_medium')
            query = {
                'mbr': 'true',
                'assetTypes': 'LegacyRelease',
                'fwsitesection': fw_ssid,
                'fwNetworkID': fw_network_id,
                'pprofile': 'ots_desktop_html',
                'sensitive': 'false',
                'w': '1920',
                'h': '1080',
                'rnd': '1660303',
                'mode': 'LIVE',
                'format': 'SMIL',
                'tracking': 'true',
                'formats': 'M3U+none,MPEG-DASH+none,MPEG4,MP3',
                'vpaid': 'script',
                'schema': '2.0',
                'SDK': 'PDK+6.1.3',
            }