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

Code before:
        'md5': '84feb80fd7e6ec07744726a9f01cda4d',
        'info_dict': {
            'id': '183522',
            'ext': 'm4a',
            'duration': 1823,
            'title': '#138 Nepilnīgā kompensējamo zāļu sistēma pat mēnešiem dzenā pacientus pa aptiekām',
            'thumbnail': 'https://pic.latvijasradio.lv/public/assets/media/9/d/large_fd4675ac.jpg',
            'upload_date': '20231102',
            'timestamp': 1698913860,
            'description': 'md5:7bac3b2dd41e44325032943251c357b1',
        },
    }, {
        'url': 'https://replay.lsm.lv/ru/skaties/statja/ltv/355067/v-kengaragse-nacalas-ukladka-relsov',
        'only_matching': True,
    }]

    def _fix_nuxt_data(self, webpage):
        return re.sub(r'Object\.create\(null(?:,(\{.+\}))?\)', lambda m: m.group(1) or 'null', webpage)

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)

        data = self._search_nuxt_data(
            self._fix_nuxt_data(webpage), video_id, context_name='__REPLAY__')
        playback_type = traverse_obj(data, ('playback', 'type'))

        if playback_type == 'playable_audio_lr':
            playback_data = {
                'formats': self._extract_m3u8_formats(
                    traverse_obj(data, ('playback', 'service', 'hls_url', {url_or_none})), video_id),
            }
        elif playback_type == 'embed':
            playback_data = {
                '_type': 'url_transparent',
                **traverse_obj(data, {
                    'url': ('playback', 'service', 'url', {url_or_none}),
                }),
            }
        else:
            raise ExtractorError(f'Unsupported playback type {playback_type!r}')

        return {
            'id': video_id,
            **playback_data,
            **traverse_obj(data, {
                'title': ('mediaItem', 'title'),
                'description': ('mediaItem', ('lead', 'body')),
                'duration': ('mediaItem', 'duration', {int_or_none}),
                'timestamp': ('mediaItem', 'aired_at', {parse_iso8601}),
                'thumbnail': ('mediaItem', 'largeThumbnail', {url_or_none}),

Review comment (suggestion):
this can and should be fatal imo
```suggestion
        playback_type = data['playback']['type']
```

Code after:
        'md5': '84feb80fd7e6ec07744726a9f01cda4d',
        'info_dict': {
            'id': '183522',
            'ext': 'm4a',
            'duration': 1823,
            'title': '#138 Nepilnīgā kompensējamo zāļu sistēma pat mēnešiem dzenā pacientus pa aptiekām',
            'thumbnail': 'https://pic.latvijasradio.lv/public/assets/media/9/d/large_fd4675ac.jpg',
            'upload_date': '20231102',
            'timestamp': 1698913860,
            'description': 'md5:7bac3b2dd41e44325032943251c357b1',
        },
    }, {
        'url': 'https://replay.lsm.lv/ru/skaties/statja/ltv/355067/v-kengaragse-nacalas-ukladka-relsov',
        'only_matching': True,
    }, {
        'url': 'https://replay.lsm.lv/lv/ieraksts/ltv/311130/4-studija-zolitudes-tragedija-un-incupes-stacija',
        'only_matching': True,
    }]

    def _fix_nuxt_data(self, webpage):
        return re.sub(r'Object\.create\(null(?:,(\{.+\}))?\)', lambda m: m.group(1) or 'null', webpage)

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)

        data = self._search_nuxt_data(
            self._fix_nuxt_data(webpage), video_id, context_name='__REPLAY__')
        playback_type = data['playback']['type']

        if playback_type == 'playable_audio_lr':
            playback_data = {
                'formats': self._extract_m3u8_formats(data['playback']['service']['hls_url'], video_id),
            }
        elif playback_type == 'embed':
            playback_data = {
                '_type': 'url_transparent',
                'url': data['playback']['service']['url'],
            }
        else:
            raise ExtractorError(f'Unsupported playback type "{playback_type}"')

        return {
            'id': video_id,
            **playback_data,
            **traverse_obj(data, {
                'title': ('mediaItem', 'title'),
                'description': ('mediaItem', ('lead', 'body')),
                'duration': ('mediaItem', 'duration', {int_or_none}),
                'timestamp': ('mediaItem', 'aired_at', {parse_iso8601}),
                'thumbnail': ('mediaItem', 'largeThumbnail', {url_or_none}),