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

Code before:

        subtitles = {}
        skipped_subs_clients = set()
        prs = traverse_obj(player_responses, (
            # Filter out initial_pr which does not have streamingData (smuggled client context)
            lambda _, v: v['streamingData'] and v['captions']['playerCaptionsTracklistRenderer']))

        pctrs = traverse_obj(prs, (..., 'captions', 'playerCaptionsTracklistRenderer', {dict}))
        translation_languages = {
            lang.get('languageCode'): self._get_text(lang.get('languageName'), max_runs=1)
            for lang in traverse_obj(pctrs, (..., 'translationLanguages', ..., {dict}))}
        # NB: Constructing the full subtitle dictionary is slow
        get_translated_subs = 'translated_subs' not in self._configuration_arg('skip') and (
            self.get_param('writeautomaticsub', False) or self.get_param('listsubtitles'))

        all_captions = traverse_obj(pctrs, (..., 'captionTracks', ..., {dict}))
        need_subs_langs = {get_lang_code(sub) for sub in all_captions if sub.get('kind') != 'asr'}
        need_caps_langs = {
            remove_start(get_lang_code(sub), 'a-')
            for sub in all_captions if sub.get('kind') == 'asr'}

        for pr in prs:
            pctr = pr['captions']['playerCaptionsTracklistRenderer']
            client_name = pr['streamingData'][STREAMING_DATA_CLIENT_NAME]
            innertube_client_name = traverse_obj(
                pr, ('streamingData', STREAMING_DATA_INNERTUBE_CONTEXT, 'client', 'clientName'))
            required_contexts = self._get_default_ytcfg(client_name)['PO_TOKEN_REQUIRED_CONTEXTS']
            fetch_subs_po_token_func = pr['streamingData'][STREAMING_DATA_FETCH_SUBS_PO_TOKEN]
            pot_params = {}

            for caption_track in traverse_obj(pctr, ('captionTracks', lambda _, v: v['baseUrl'])):
                base_url = caption_track['baseUrl']
                qs = parse_qs(base_url)
                lang_code = get_lang_code(caption_track)
                requires_pot = (
                    # We can detect the experiment for now
                    any(e in traverse_obj(qs, ('exp', ...)) for e in ('xpe', 'xpv'))
                    or _PoTokenContext.SUBS in required_contexts)

                subs_po_token = fetch_subs_po_token_func(required=requires_pot)
                if not subs_po_token and requires_pot:
                    skipped_subs_clients.add(client_name)
                    self._report_pot_subtitle_skipped(video_id, client_name)
                    break

                if not pot_params:
                    pot_params.update({
                        'pot': subs_po_token,
                        'potc': '1',
                        'c': innertube_client_name,
                    })

Review comment (suggestion):
can we be bold here
```suggestion
            innertube_client_name = pr['streamingData'][STREAMING_DATA_INNERTUBE_CONTEXT]['client']['clientName']
```

Code after:
            for fmt in self._SUBTITLE_FORMATS:
                query = {**query, 'fmt': fmt}
                lang_subs.append({
                    'ext': fmt,
                    'url': urljoin('https://www.youtube.com', update_url_query(base_url, query)),
                    'name': sub_name,
                    STREAMING_DATA_CLIENT_NAME: client_name,
                })

        subtitles = {}
        skipped_subs_clients = set()
        prs = traverse_obj(player_responses, (
            # Filter out initial_pr which does not have streamingData (smuggled client context)
            lambda _, v: v['streamingData'] and v['captions']['playerCaptionsTracklistRenderer']))

        pctrs = traverse_obj(prs, (..., 'captions', 'playerCaptionsTracklistRenderer', {dict}))
        translation_languages = {
            lang.get('languageCode'): self._get_text(lang.get('languageName'), max_runs=1)
            for lang in traverse_obj(pctrs, (..., 'translationLanguages', ..., {dict}))}
        # NB: Constructing the full subtitle dictionary is slow
        get_translated_subs = 'translated_subs' not in self._configuration_arg('skip') and (
            self.get_param('writeautomaticsub', False) or self.get_param('listsubtitles'))

        all_captions = traverse_obj(pctrs, (..., 'captionTracks', ..., {dict}))
        need_subs_langs = {get_lang_code(sub) for sub in all_captions if sub.get('kind') != 'asr'}
        need_caps_langs = {
            remove_start(get_lang_code(sub), 'a-')
            for sub in all_captions if sub.get('kind') == 'asr'}

        for pr in prs:
            pctr = pr['captions']['playerCaptionsTracklistRenderer']
            client_name = pr['streamingData'][STREAMING_DATA_CLIENT_NAME]
            innertube_client_name = pr['streamingData'][STREAMING_DATA_INNERTUBE_CONTEXT]['client']['clientName']
            required_contexts = self._get_default_ytcfg(client_name)['PO_TOKEN_REQUIRED_CONTEXTS']
            fetch_subs_po_token_func = pr['streamingData'][STREAMING_DATA_FETCH_SUBS_PO_TOKEN]

            pot_params = {}
            already_fetched_pot = False

            for caption_track in traverse_obj(pctr, ('captionTracks', lambda _, v: v['baseUrl'])):
                base_url = caption_track['baseUrl']
                qs = parse_qs(base_url)
                lang_code = get_lang_code(caption_track)
                requires_pot = (
                    # We can detect the experiment for now
                    any(e in traverse_obj(qs, ('exp', ...)) for e in ('xpe', 'xpv'))
                    or _PoTokenContext.SUBS in required_contexts)

                if not already_fetched_pot:
                    already_fetched_pot = True
                    if subs_po_token := fetch_subs_po_token_func(required=requires_pot):