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

Code before:
            'description': '',
            'series': '',
            'timestamp': 1611532800,
            'upload_date': '20210125',
            'release_timestamp': 1710728222,
            'release_date': '20240318',
            'release_year': 2021,
        },
        'params': {'skip_download': 'm3u8'},
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        data = self._download_json(
            f'https://arhiiv.err.ee/api/v1/content/video/{video_id}', video_id)

        formats, subtitles = [], {}
        media_data = traverse_obj(data, ('media', 'src'), {url_or_none})
        if 'hls' in media_data:
            fmts, subs = self._extract_m3u8_formats_and_subtitles(
                media_data['hls'], video_id, 'mp4', m3u8_id='hls', fatal=False)
            formats.extend(fmts)
            self._merge_subtitles(subs, target=subtitles)
        if 'dash' in media_data:
            fmts, subs = self._extract_mpd_formats_and_subtitles(
                media_data['dash'], video_id, mpd_id='dash', fatal=False)
            formats.extend(fmts)
            self._merge_subtitles(subs, target=subtitles)

        return {
            'id': video_id,
            'formats': formats,
            'subtitles': subtitles,
            **traverse_obj(data['info'], {
                'title': ('title', {str}),
                'series': ('seriesTitle', {str}),
                'series_id': ('seriesId', {str}),
                'episode_id': ('episode', {int_or_none}),
                'description': ('synopsis', {str}),
                'timestamp': ('date', {parse_iso8601}),
                'modified_timestamp': ('dateModified', {parse_iso8601}),
                'release_timestamp': ('uploadDate', {parse_iso8601}),
                'release_year': ('year', {int_or_none}),
            }, get_all=False),
        }


Review comment (refactor):
The `{url_or_none}` isn't doing anything here; it's in its own path, so it's a fallback that's never reached. Let's just traverse twice instead:
```suggestion
        if hls_url := traverse_obj(data, ('media', 'src', 'hls', {url_or_none})):
            fmts, subs = self._extract_m3u8_formats_and_subtitles(
                hls_url, video_id, 'mp4', m3u8_id='hls', fatal=False)
            formats.extend(fmts)
            self._merge_subtitles(subs, target=subtitles)
        if dash_url := traverse_obj(data, ('media', 'src', 'dash', {url_or_none})):
            fmts, subs = self._extract_mpd_formats_and_subtitles(
                dash_url, video_id, mpd_id='dash', fatal=False)
```

Code after:
            'timestamp': 1710728222,
            'upload_date': '20240318',
            'release_timestamp': 1611532800,
            'release_date': '20210125',
        },
        'params': {'skip_download': 'm3u8'},
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        data = self._download_json(
            f'https://arhiiv.err.ee/api/v1/content/video/{video_id}', video_id)

        formats, subtitles = [], {}
        if hls_url := traverse_obj(data, ('media', 'src', 'hls', {url_or_none})):
            fmts, subs = self._extract_m3u8_formats_and_subtitles(
                hls_url, video_id, 'mp4', m3u8_id='hls', fatal=False)
            formats.extend(fmts)
            self._merge_subtitles(subs, target=subtitles)
        if dash_url := traverse_obj(data, ('media', 'src', 'dash', {url_or_none})):
            fmts, subs = self._extract_mpd_formats_and_subtitles(
                dash_url, video_id, mpd_id='dash', fatal=False)
            formats.extend(fmts)
            self._merge_subtitles(subs, target=subtitles)

        return {
            'id': video_id,
            'formats': formats,
            'subtitles': subtitles,
            **traverse_obj(data, ('info', {
                'title': ('title', {str}),
                'series': ('seriesTitle', {str}, filter),
                'series_id': ('seriesId', {str}, filter),
                'episode_id': ('episode', {int_or_none}),
                'description': ('synopsis', {str}, filter),
                'timestamp': ('uploadDate', {parse_iso8601}),
                'modified_timestamp': ('dateModified', {parse_iso8601}),
                'release_timestamp': ('date', {parse_iso8601}),
                'release_year': ('year', {int_or_none}),
            })),
        }