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

Code before:
    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

    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 video info JSON')

        video_json = self._download_json(
            f'https://{ext_domain}/api/videofile.php', video_id, query={
                'video_id': extr_id,
                'lifetime': 8640000,
            }, note='Downloading video metadata 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': extr_id,
            'display_id': video_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}),
            })),
        }


Review comment (bug):
`info_json` can be non-fatal since it is only metadata, & I've tweaked the notes for both API calls
```suggestion
        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')
```

Code after:
            return base64.b64decode(encoded_url.translate(translation), validate=True).decode()
        except (binascii.Error, ValueError):
            return None

    def _real_extract(self, url):
        display_id = self._match_id(url)
        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}),
            })),
        }