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

Code before:
        return info_dict

    def _extract_live(self, channel_name):
        cid = self._extract_cid(channel_name, channel_name)
        formats, subtitles = self._extract_formats(cid, cid, is_live=True)
        return {
            'id': channel_name,
            'title': channel_name,
            'is_live': True,
            'format': formats,
            'subtitles': subtitles
        }

    def _extract_record(self, record_id):
        video_id = self._extract_video_id_from_recording(record_id)
        cid, info_dict = self._extract_cid_and_video_info(video_id)
        info_dict['formats'], info_dict['subtitles'] = self._extract_formats(cid, video_id, record_id=record_id)
        return info_dict

    def _extract_ondemand(self, ondemand_id):
        ondemand_termtoken, ondemand_type, info_dict = self._extract_ondemand_info(ondemand_id)
        formats, subtitles = self._extract_formats(
            None, ondemand_id, ondemand_id=ondemand_id,
            ondemand_termtoken=ondemand_termtoken, ondemand_type=ondemand_type)
        info_dict['formats'] = formats
        info_dict['subtitles'] = subtitles
        return info_dict


def _make_valid_url(host):
    return rf'https?://(?:www\.)?{re.escape(host)}/watch/[^/]+?/(?P<id>[0-9]+)[^/]+(?:/(?P<recid>[0-9]+))?'


class ZattooIE(ZattooPlatformBaseIE):
    _NETRC_MACHINE = 'zattoo'
    _HOST = 'zattoo.com'
    _VALID_URL = r'''(?x)
        https?://(?:www\.)?zattoo.com/(?:
            (?:
                (?:program|watch)/[^/]+/(?P<vidid>\d+)|
                vod/movies/(?P<vodid>[A-Za-z0-9]+)|
                live/(?P<liveid>[^/]+)
            )|
            [^?#]+\?
        )'''

    _TESTS = [{
        'url': 'https://zattoo.com/program/zdf/250380873',
        'info_dict': {
            'id': '250380873',
            'ext': 'mp4',

Review comment (refactor):
```suggestion
        info_dict['formats'], info_dict['subtitles'] = self._extract_formats(
            None, ondemand_id, ondemand_id=ondemand_id,
            ondemand_termtoken=ondemand_termtoken, ondemand_type=ondemand_type)
```

Code after:

    def _extract_live(self, channel_name):
        cid = self._extract_cid(channel_name, channel_name)
        formats, subtitles = self._extract_formats(cid, cid, is_live=True)
        return {
            'id': channel_name,
            'title': channel_name,
            'is_live': True,
            'format': formats,
            'subtitles': subtitles
        }

    def _extract_record(self, record_id):
        video_id = self._extract_video_id_from_recording(record_id)
        cid, info_dict = self._extract_cid_and_video_info(video_id)
        info_dict['formats'], info_dict['subtitles'] = self._extract_formats(cid, video_id, record_id=record_id)
        return info_dict

    def _extract_ondemand(self, ondemand_id):
        ondemand_termtoken, ondemand_type, info_dict = self._extract_ondemand_info(ondemand_id)
        info_dict['formats'], info_dict['subtitles'] = self._extract_formats(
            None, ondemand_id, ondemand_id=ondemand_id,
            ondemand_termtoken=ondemand_termtoken, ondemand_type=ondemand_type)
        return info_dict


def _make_valid_url(host):
    return rf'https?://(?:www\.)?{re.escape(host)}/watch/[^/]+?/(?P<id>[0-9]+)[^/]+(?:/(?P<recid>[0-9]+))?'


class ZattooBaseIE(ZattooPlatformBaseIE):
    _NETRC_MACHINE = 'zattoo'
    _HOST = 'zattoo.com'

    @staticmethod
    def _create_valid_url(match, qs, base_re=None):
        match_base = fr'|{base_re}/(?P<vid1>{match})' if base_re else '(?P<vid1>)'
        return rf'''(?x)https?://(?:www\.)?zattoo\.com/(?:
            [^?#]+\?(?:[^#]+&)?{qs}=(?P<vid2>{match})
            {match_base}
        )'''

    def _real_extract(self, url):
        vid1, vid2 = self._match_valid_url(url).group('vid1', 'vid2')
        return getattr(self, f'_extract_{self._TYPE}')(vid1 or vid2)


class ZattooIE(ZattooBaseIE):
    _VALID_URL = ZattooBaseIE._create_valid_url(r'\d+', 'program', '(?:program|watch)/[^/]+')
    _TYPE = 'video'
    _TESTS = [{