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

Code before:
        'PG': 15,
        'M': 15,
        'MA': 15,
        'MA15+': 15,
        'R': 18,
        'X': 18,
    }

    def _real_extract(self, url):
        content_id = self._match_id(url)
        data = self._download_json(
            'https://10.com.au/api/v1/videos/' + content_id, content_id)

        video_data = self._download_json(
            f'https://vod.ten.com.au/api/videos/bcquery?command=find_videos_by_id&video_id={data["altId"]}',
            content_id, 'Downloading video JSON')
        # Convert DASH to HLS using update_url_query
        m3u8_url = self._request_webpage(
            HEADRequest(update_url_query(video_data['items'][0]['dashManifestUrl'], {
                'manifest': 'm3u',
            })),
            content_id, 'Checking stream URL').url
        if '10play-not-in-oz' in m3u8_url:
            self.raise_geo_restricted(countries=['AU'])
        if '10play_unsupported' in m3u8_url:
            raise ExtractorError('Unable to extract stream (10Play says "unsupported")')
        # Attempt to get a higher quality stream
        formats = self._extract_m3u8_formats(
            m3u8_url.replace(',150,75,55,0000', ',500,300,150,75,55,0000'),
            content_id, 'mp4', fatal=False)
        if not formats:
            formats = self._extract_m3u8_formats(m3u8_url, content_id, 'mp4')

        return {
            'id': content_id,
            'formats': formats,
            'subtitles': {'en': [{'url': data['captionUrl']}]} if url_or_none(data.get('captionUrl')) else None,
            'uploader': 'Channel 10',
            'uploader_id': '2199827728001',
            **traverse_obj(data, {
                'id': ('altId', {str}),
                'duration': ('duration', {int_or_none}),
                'title': ('subtitle', {str}),
                'alt_title': ('title', {str}),
                'description': ('description', {str}),
                'age_limit': ('classification', {self._AUS_AGES.get}),
                'series': ('tvShow', {str}),
                'season_number': ('season', {int_or_none}),
                'episode_number': ('episode', {int_or_none}),
                'timestamp': ('published', {int_or_none}),
                'thumbnail': ('imageUrl', {url_or_none}),

Review comment (refactor):
```suggestion
            raise ExtractorError('Unable to extract stream')
```

Code after:
        'url': 'https://10play.com.au/how-to-stay-married/web-extras/season-1/terrys-talks-ep-1-embracing-change/tpv190915ylupc',
        'only_matching': True,
    }]
    _GEO_BYPASS = False

    _AUS_AGES = {
        'G': 0,
        'PG': 15,
        'M': 15,
        'MA': 15,
        'MA15+': 15,
        'R': 18,
        'X': 18,
    }

    def _real_extract(self, url):
        content_id = self._match_id(url)
        data = self._download_json(
            'https://10.com.au/api/v1/videos/' + content_id, content_id)

        video_data = self._download_json(
            f'https://vod.ten.com.au/api/videos/bcquery?command=find_videos_by_id&video_id={data["altId"]}',
            content_id, 'Downloading video JSON')
        # Dash URL 403s, changing the m3u8 format works
        m3u8_url = self._request_webpage(
            HEADRequest(update_url_query(video_data['items'][0]['dashManifestUrl'], {
                'manifest': 'm3u',
            })),
            content_id, 'Checking stream URL').url
        if '10play-not-in-oz' in m3u8_url:
            self.raise_geo_restricted(countries=['AU'])
        if '10play_unsupported' in m3u8_url:
            raise ExtractorError('Unable to extract stream')
        # Attempt to get a higher quality stream
        formats = self._extract_m3u8_formats(
            m3u8_url.replace(',150,75,55,0000', ',500,300,150,75,55,0000'),
            content_id, 'mp4', fatal=False)
        if not formats:
            formats = self._extract_m3u8_formats(m3u8_url, content_id, 'mp4')

        return {
            'id': content_id,
            'formats': formats,
            'subtitles': {'en': [{'url': data['captionUrl']}]} if url_or_none(data.get('captionUrl')) else None,
            'uploader': 'Channel 10',
            'uploader_id': '2199827728001',
            **traverse_obj(data, {
                'id': ('altId', {str}),
                'duration': ('duration', {int_or_none}),
                'title': ('subtitle', {str}),
                'alt_title': ('title', {str}),