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

Code before:
        # Check for characters not in the custom character set and handle errors
        if any(char not in cust_char_set for char in encoded_url):
            return None

        # Filter out characters not in the custom character set
        encoded_url = ''.join(char for char in encoded_url if char in cust_char_set)

        while cur_pos < len(encoded_url):
            o = cust_char_set.index(encoded_url[cur_pos])
            i = cust_char_set.index(encoded_url[cur_pos + 1])
            s = cust_char_set.index(encoded_url[cur_pos + 2])
            a = cust_char_set.index(encoded_url[cur_pos + 3])

            o = (o << 2) | (i >> 4)
            i = ((i & 15) << 4) | (s >> 2)
            l = ((s & 3) << 6) | a

            decoded_url += chr(o)
            if s != 64:
                decoded_url += chr(i)
            if a != 64:
                decoded_url += chr(l)

            cur_pos += 4

        return f'https://{ext_domain}{decoded_url}'

    def _real_extract(self, url):

        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)

        ext_domain, extr_id = self._search_regex(
            r'https:\/\/(?P<ext_domain>[\w.-]+\.\w{3})\/embed\/(?P<extr_id>\d+)\/',
            webpage, 'embed_info', group=('ext_domain', 'extr_id'))

        info_json = self._download_json(self._gen_info_url(ext_domain, extr_id),
                                        video_id, note="Downloading JSON metadata for the video info.")
        if not info_json:
            raise ExtractorError('Unable to retrieve the video info.')

        video_json = self._download_json(f'https://{ext_domain}/api/videofile.php?video_id={extr_id}&lifetime=8640000',
                                         video_id, note="Downloading JSON metadata for the video location.")
        if not video_json:
            raise ExtractorError('Unable to retrieve the the video location.')

        encoded_url = video_json[0].get('video_url')
        if not encoded_url:
            raise ExtractorError('Unable to retrieve the `encoded_url` value.')

        download_url = self._decode_video_url(ext_domain, encoded_url)

Review comment (bug):
This whole function is basically a b64 decode, so we can implement it as such (import `base64` and `binascii`):
```suggestion
    @staticmethod
    def _decode_video_url(encoded_url):
        """ This function is a reverse engineering from the website javascript """
        # Replace lookalike characters and standardize map
        translation = str.maketrans('АВСЕМ.,~', 'ABCEM+/=')
        try:
            return base64.b64decode(encoded_url.translate(translation), validate=True).decode()
        except (binascii.Error, ValueError):
            return None
```
While this is not 100% equivalent, it would rely on padding overflow which I deem highly unlikely

Code after:
        webpage = self._download_webpage(url, display_id)

        ext_domain, video_id = self._search_regex(
            r'https://(?P<ext_domain>[\w.-]+\.\w{3})/embed/(?P<extr_id>\d+)/',
            webpage, 'embed info', group=('ext_domain', 'extr_id'))

        info_json = self._download_json(
            self._gen_info_url(ext_domain, video_id), video_id, fatal=False)

        video_json = self._download_json(
            f'https://{ext_domain}/api/videofile.php', video_id, query={
                'video_id': video_id,
                'lifetime': 8640000,
            }, note='Downloading video file JSON', errnote='Failed to download video file JSON')

        decoded_url = self._decode_video_url(video_json[0]['video_url'])
        if not decoded_url:
            raise ExtractorError('Unable to decode the video url')

        return {
            'id': video_id,
            'display_id': display_id,
            'ext': traverse_obj(video_json, (0, 'format', {determine_ext})),
            'url': f'https://{ext_domain}{decoded_url}',
            'age_limit': 18,
            **traverse_obj(info_json, ('video', {
                'title': ('title', {str}),
                'description': ('description', {str}),
                'thumbnail': ('thumb', {url_or_none}),
                'upload_date': ('post_date', {unified_strdate}),
                'uploader': ('user', 'username', {str}),
            })),
        }