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

Code before:
        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': ['JP']}),
                'ie_key': 'BrightcoveNew',
            }

        project_id = traverse_obj(video_info, ('streaks', 'projectID', {str}, {require('project ID')}))
        key_idx = dt.datetime.now(tz=dt.timezone.utc).month % 6 or 6

        return {
            **self._extract_from_streaks_api(video_info['streaks']['projectID'], 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}'],
            }),
            **metadata,
            'id': video_id,
            '_old_archive_ids': [make_archive_id('BrightcoveNew', brightcove_id)] if brightcove_id else None,
        }


Review comment (refactor):
```suggestion
            **self._extract_from_streaks_api(project_id, streaks_id, {
```

Code after:
        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': ['JP']}),
                '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

        return {
            **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}'],
            }),
            **metadata,
            'id': video_id,
            '_old_archive_ids': [make_archive_id('BrightcoveNew', brightcove_id)] if brightcove_id else None,
        }