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

Code before:
        '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}),
            }, get_all=False),
        }


Review comment (refactor):
```suggestion
            raise ExtractorError(f'Unsupported playback type "{playback_type}"')
```

Code after:
        '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}),
            }, get_all=False),
        }