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

Code before:
        streaks_id = traverse_obj(video_info, ('streaks', 'videoRefID', {str}))
        if streaks_id and not streaks_id.startswith('ref:'):
            streaks_id = f'ref:{streaks_id}'

        # Deprecated Brightcove extraction reachable w/extractor-arg or fallback; errors are expected
        if backend == 'brightcove' or not streaks_id:
            if backend != 'brightcove':
                self.report_warning(
                    'No STREAKS ID found; falling back to Brightcove extraction', video_id=video_id)
            if not brightcove_id:
                raise ExtractorError('Unable to extract brightcove reference ID', expected=True)
            account_id = traverse_obj(video_info, (
                'video', 'accountID', {str}, {require('brightcove account ID', expected=True)}))
            return {
                **metadata,
                '_type': 'url_transparent',
                'url': smuggle_url(
                    self.BRIGHTCOVE_URL_TEMPLATE % (account_id, brightcove_id),
                    {'geo_countries': self._GEO_COUNTRIES}),
                'ie_key': 'BrightcoveNew',
            }

        return {
            **self._extract_from_streaks_api(video_info['streaks']['projectID'], streaks_id, {
                'Origin': 'https://tver.jp',
                'Referer': 'https://tver.jp/',
            }, metadata_available=True),
            **metadata,
            'id': video_id,
            'geo_countries': self._GEO_COUNTRIES,
            '_old_archive_ids': [make_archive_id('BrightcoveNew', brightcove_id)] if brightcove_id else None,
        }


Review comment (refactor):
I think I'd prefer to keep the change confined to the TVer extractor only (and revert the changes to `streaks.py`)
```suggestion
        try:
            streaks_info = self._extract_from_streaks_api(video_info['streaks']['projectID'], streaks_id, {
                'Origin': 'https://tver.jp',
                'Referer': 'https://tver.jp/',
            })
        except GeoRestrictedError as e:
            # Catch and re-raise with metadata_available to support --ignore-no-formats-error
            self.raise_geo_restricted(e.orig_msg, countries=self._GEO_COUNTRIES, metadata_available=True)
            streaks_info = {}

        return {
```

Code after:
                'episode_number': ('no', {int_or_none}),
            }),
        }

        brightcove_id = traverse_obj(video_info, ('video', ('videoRefID', 'videoID'), {str}, any))
        if brightcove_id and not brightcove_id.isdecimal():
            brightcove_id = f'ref:{brightcove_id}'

        streaks_id = traverse_obj(video_info, ('streaks', 'videoRefID', {str}))
        if streaks_id and not streaks_id.startswith('ref:'):
            streaks_id = f'ref:{streaks_id}'

        # Deprecated Brightcove extraction reachable w/extractor-arg or fallback; errors are expected
        if backend == 'brightcove' or not streaks_id:
            if backend != 'brightcove':
                self.report_warning(
                    'No STREAKS ID found; falling back to Brightcove extraction', video_id=video_id)
            if not brightcove_id:
                raise ExtractorError('Unable to extract brightcove reference ID', expected=True)
            account_id = traverse_obj(video_info, (
                'video', 'accountID', {str}, {require('brightcove account ID', expected=True)}))
            return {
                **metadata,
                '_type': 'url_transparent',
                'url': smuggle_url(
                    self.BRIGHTCOVE_URL_TEMPLATE % (account_id, brightcove_id),
                    {'geo_countries': self._GEO_COUNTRIES}),
                'ie_key': 'BrightcoveNew',
            }

        project_id = video_info['streaks']['projectID']
        key_idx = dt.datetime.fromtimestamp(time_seconds(hours=9), dt.timezone.utc).month % 6 or 6

        try:
            streaks_info = self._extract_from_streaks_api(project_id, streaks_id, {
                'Origin': 'https://tver.jp',
                'Referer': 'https://tver.jp/',
                'X-Streaks-Api-Key': self._STREAKS_API_INFO[project_id]['api_key'][f'key0{key_idx}'],
            })
        except GeoRestrictedError as e:
            # Catch and re-raise with metadata_available to support --ignore-no-formats-error
            self.raise_geo_restricted(e.orig_msg, countries=self._GEO_COUNTRIES, metadata_available=True)
            streaks_info = {}

        return {
            **streaks_info,
            **metadata,
            'id': video_id,
            '_old_archive_ids': [make_archive_id('BrightcoveNew', brightcove_id)] if brightcove_id else None,
        }