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

Code before:
            for o in range(256):
                a = (a + r[o] + int_or_none(char_code_at(e, o % len(e)))) % 256
                r[o], r[a] = r[a], r[o]

            a, o = 0, 0
            for u in range(len(t)):
                o = (o + 1) % 256
                a = (a + r[o]) % 256
                r[o], r[a] = r[a], r[o]
                s += chr(t[u] ^ r[(r[o] + r[a]) % 256])

            return s

        def decrypt2(key: str, key2: list) -> str:
            n = []
            for r in range(len(key)):
                a = ord('a')
                if ord('a') <= ord(key[r]) <= ord('z'):
                    a = ord(key[r]) - 97
                else:
                    a = ord(key[r]) - 48 + 26

                for i in range(36):
                    if key2[i] == a:
                        a = i
                        break

                if a > 25:
                    n.append(chr(a - 26 + 48))
                else:
                    n.append(chr(a + 97))

            return ''.join(n)

        def decrypt3(s: str) -> list:
            t = 0
            n = 0
            r = 0
            s_len = len(s)
            i = []
            o = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
                 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
                 -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1,
                 -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
                 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30,
                 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
                 51, -1, -1, -1, -1, -1]

            while r < s_len:
                t = o[char_code_at(s, r) & 255]
                r += 1

Review comment (suggestion):
I'd probably use a different variable name and just do:
```suggestion
                i = key2.index(a)
```

Code after:

        audio_id = self._match_id(url)
        audio_info = self._download_json(
            f'{scheme}://m.ximalaya.com/tracks/{audio_id}.json', audio_id,
            'Downloading info json', 'Unable to download info file')

        formats = []
        # NOTE: VIP-restricted audio
        if audio_info.get('is_paid'):
            ts = int(time.time())
            vip_info = self._download_json(
                f'{scheme}://mpay.ximalaya.com/mobile/track/pay/{audio_id}/{ts}',
                audio_id, 'Downloading VIP info json', 'Unable to download VIP info file',
                query={'device': 'pc', 'isBackend': 'true', '_': ts})
            filename = self._decrypt_filename(vip_info['fileId'], vip_info['seed'])
            sign, token, timestamp = self._decrypt_url_params(vip_info['ep'])
            vip_url = update_url_query(
                f'{vip_info["domain"]}/download/{vip_info["apiVersion"]}{filename}', {
                    'sign': sign,
                    'token': token,
                    'timestamp': timestamp,
                    'buy_key': vip_info['buyKey'],
                    'duration': vip_info['duration'],
                })
            fmt = {
                'format_id': 'vip',
                'url': vip_url,
                'vcodec': 'none',
            }
            if '_preview_' in vip_url:
                self.report_warning(
                    f'This tracks requires a VIP account. Using a sample instead. {self._login_hint()}')
                fmt.update({
                    'format_note': 'Sample',
                    'preference': -10,
                    **traverse_obj(vip_info, {
                        'filesize': ('sampleLength', {int_or_none}),
                        'duration': ('sampleDuration', {int_or_none}),
                    }),
                })
            else:
                fmt.update(traverse_obj(vip_info, {
                    'filesize': ('totalLength', {int_or_none}),
                    'duration': ('duration', {int_or_none}),
                }))

            fmt['abr'] = try_call(lambda: fmt['filesize'] * 8 / fmt['duration'] / 1024)
            formats.append(fmt)

        formats.extend([{
            'format_id': f'{bps}k',