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

Code before:
            'modified_date': '20230608',
            'release_timestamp': 1686308700,
            'timestamp': 1685145600,
            'modified_timestamp': 1686252600,
            'release_year': 2023,
            'episode': 'Episode 0',
            'episode_id': '1608990335',
            'episode_number': 0,
            'season': 'Season 0',
            'season_number': 0,
            'series': 'Лесные истории | Аисты',
            'series_id': '1037497',
        },
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        data = try_call(lambda: self._download_json(
            'https://services.err.ee/api/v2/vodContent/getContentPageData', video_id,
            query={'contentId': video_id})['data']['mainContent'])
        if not data:
            raise ExtractorError('Failed to get video data', expected=True)

        media_data = traverse_obj(data, ('medias', ..., {dict}), get_all=False)
        if traverse_obj(media_data, ('restrictions', 'drm', {bool})):
            self.raise_no_formats('This video is DRM protected', expected=True)

        formats, subtitles = [], {}
        for url in set(traverse_obj(media_data, ('src', ('hls', 'hls2', 'hlsNew'), {url_or_none}))):
            fmts, subs = self._extract_m3u8_formats_and_subtitles(
                url, video_id, 'mp4', m3u8_id='hls', fatal=False)
            formats.extend(fmts)
            self._merge_subtitles(subs, target=subtitles)
        for url in set(traverse_obj(media_data, ('src', ('dash', 'dashNew'), {url_or_none}))):
            fmts, subs = self._extract_mpd_formats_and_subtitles(
                url, video_id, mpd_id='dash', fatal=False)
            formats.extend(fmts)
            self._merge_subtitles(subs, target=subtitles)
        if url := traverse_obj(media_data, ('src', 'file', {url_or_none})):
            formats.append({
                'url': url,
                'format_id': 'http',
            })

        return {
            'id': video_id,
            'formats': formats,
            'subtitles': subtitles,
            **traverse_obj(data, {
                'title': ('heading', {str}),
                'alt_title': ('subHeading', {str}),

Review comment (suggestion):
Oh this should have just been:
```suggestion
            self.report_drm(video_id)
```

Code after:
            'timestamp': 1685145600,
            'modified_timestamp': 1686252600,
            'release_year': 2023,
            'episode': 'Episode 0',
            'episode_id': '1608990335',
            'episode_number': 0,
            'season': 'Season 0',
            'season_number': 0,
            'series': 'Лесные истории | Аисты',
            'series_id': '1037497',
        },
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        data = self._download_json(
            'https://services.err.ee/api/v2/vodContent/getContentPageData', video_id,
            query={'contentId': video_id})['data']['mainContent']

        media_data = traverse_obj(data, ('medias', ..., {dict}), get_all=False)
        if traverse_obj(media_data, ('restrictions', 'drm', {bool})):
            self.report_drm(video_id)

        formats, subtitles = [], {}
        for format_url in set(traverse_obj(media_data, ('src', ('hls', 'hls2', 'hlsNew'), {url_or_none}))):
            fmts, subs = self._extract_m3u8_formats_and_subtitles(
                format_url, video_id, 'mp4', m3u8_id='hls', fatal=False)
            formats.extend(fmts)
            self._merge_subtitles(subs, target=subtitles)
        for format_url in set(traverse_obj(media_data, ('src', ('dash', 'dashNew'), {url_or_none}))):
            fmts, subs = self._extract_mpd_formats_and_subtitles(
                format_url, video_id, mpd_id='dash', fatal=False)
            formats.extend(fmts)
            self._merge_subtitles(subs, target=subtitles)
        if format_url := traverse_obj(media_data, ('src', 'file', {url_or_none})):
            formats.append({
                'url': format_url,
                'format_id': 'http',
            })

        return {
            'id': video_id,
            'formats': formats,
            'subtitles': subtitles,
            **traverse_obj(data, {
                'title': ('heading', {str}),
                'alt_title': ('subHeading', {str}),
                'description': (('lead', 'body'), {clean_html}, {lambda x: x or None}),
                'timestamp': ('created', {int_or_none}),
                'modified_timestamp': ('updated', {int_or_none}),
                'release_timestamp': (('scheduleStart', 'publicStart'), {int_or_none}),