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

Code before:
                    video_id, fatal=False, note='Downloading remix client config')

            ytm_cfg = self._extract_ytcfg(video_id, ytm_webpage) or {}
            ytm_client = 'WEB_REMIX'
            if not sts or force_mobile_client:
                # Android client already has signature descrambled
                # See: https://github.com/TeamNewPipe/NewPipeExtractor/issues/562
                if not sts:
                    self.report_warning('Falling back to mobile remix client for player API.')
                ytm_client = 'ANDROID_MUSIC'
                ytm_cfg = {}

            ytm_headers = self._generate_api_headers(
                ytm_cfg, identity_token, syncid,
                client=ytm_client)
            ytm_query = {'videoId': video_id}
            ytm_query.update(self._generate_player_context(sts))

            ytm_player_response = self._extract_response(
                item_id=video_id, ep='player', query=ytm_query,
                ytcfg=ytm_cfg, headers=ytm_headers, fatal=False,
                default_client=ytm_client,
                note='Downloading %sremix player API JSON' % ('mobile ' if force_mobile_client else ''))

            if isinstance(ytm_player_response, dict):
                ytm_streaming_data = ytm_player_response.get('streamingData') or {}
        player_response = None
        if webpage:
            player_response = self._extract_yt_initial_variable(
                webpage, self._YT_INITIAL_PLAYER_RESPONSE_RE,
                video_id, 'initial player response')

        if not player_response or force_mobile_client:
            sts = self._extract_signature_timestamp(video_id, player_url, ytcfg, fatal=False)
            yt_client = 'WEB'
            ytpcfg = ytcfg
            ytp_headers = headers
            if not sts or force_mobile_client:
                # Android client already has signature descrambled
                # See: https://github.com/TeamNewPipe/NewPipeExtractor/issues/562
                if not sts:
                    self.report_warning('Falling back to mobile client for player API.')
                yt_client = 'ANDROID'
                ytpcfg = {}
                ytp_headers = self._generate_api_headers(ytpcfg, identity_token, syncid, yt_client)

            yt_query = {'videoId': video_id}
            yt_query.update(self._generate_player_context(sts))
            player_response = self._extract_response(
                item_id=video_id, ep='player', query=yt_query,
                ytcfg=ytpcfg, headers=ytp_headers, fatal=False,

Review comment (refactor):
I hadn't thought about `ytm_player_response` not being a dict. In that case, you can just revert my changes and go back to:
```suggestion
            # ytm_player_response need not be a dict
            ytm_streaming_data = try_get(ytm_player_response, lambda x: x['streamingData']) or {}
```

but 
```py
            ytm_player_response = self._extract_response(...) or {}
            ytm_streaming_data = ytm_player_response.get('streamingData') or {}
```
is more clearer

Code after:
                return text
            runs = x.get('runs')
            if not isinstance(runs, list):
                return
            return ''.join([r['text'] for r in runs if isinstance(r.get('text'), compat_str)])

        ytm_streaming_data = {}
        if is_music_url:
            ytm_webpage = None
            sts = self._extract_signature_timestamp(video_id, player_url, ytcfg, fatal=False)
            if sts and not force_mobile_client and 'configs' not in player_skip:
                ytm_webpage = self._download_webpage(
                    'https://music.youtube.com',
                    video_id, fatal=False, note='Downloading remix client config')

            ytm_cfg = self._extract_ytcfg(video_id, ytm_webpage) or {}
            ytm_client = 'WEB_REMIX'
            if not sts or force_mobile_client:
                # Android client already has signature descrambled
                # See: https://github.com/TeamNewPipe/NewPipeExtractor/issues/562
                if not sts:
                    self.report_warning('Falling back to mobile remix client for player API.')
                ytm_client = 'ANDROID_MUSIC'
                ytm_cfg = {}

            ytm_headers = self._generate_api_headers(
                ytm_cfg, identity_token, syncid,
                client=ytm_client)
            ytm_query = {'videoId': video_id}
            ytm_query.update(self._generate_player_context(sts))

            ytm_player_response = self._extract_response(
                item_id=video_id, ep='player', query=ytm_query,
                ytcfg=ytm_cfg, headers=ytm_headers, fatal=False,
                default_client=ytm_client,
                note='Downloading %sremix player API JSON' % ('mobile ' if force_mobile_client else ''))
            ytm_streaming_data = try_get(ytm_player_response, lambda x: x['streamingData'], dict) or {}

        player_response = None
        if webpage:
            player_response = self._extract_yt_initial_variable(
                webpage, self._YT_INITIAL_PLAYER_RESPONSE_RE,
                video_id, 'initial player response')

        if not player_response or force_mobile_client:
            sts = self._extract_signature_timestamp(video_id, player_url, ytcfg, fatal=False)
            yt_client = 'WEB'
            ytpcfg = ytcfg
            ytp_headers = headers
            if not sts or force_mobile_client:
                # Android client already has signature descrambled