{"record":{"id":"501c8d120733439b","repo":"ytdl-org/youtube-dl","slug":"clean-html-payload-0-1-1","errorCode":null,"errorMessage":"clean_html(payload[0][1:-1])","messagePattern":"clean_html\\(payload\\[0\\]\\[1:-1\\]\\)","errorType":"exception","errorClass":"ExtractorError","httpStatus":null,"severity":"error","filePath":"youtube_dl/extractor/vk.py","lineNumber":74,"sourceCode":"            data=urlencode_postdata(login_form))\n\n        if re.search(r'onLoginFailed', login_page):\n            raise ExtractorError(\n                'Unable to login, incorrect username and/or password', expected=True)\n\n    def _real_initialize(self):\n        self._login()\n\n    def _download_payload(self, path, video_id, data, fatal=True):\n        data['al'] = 1\n        code, payload = self._download_json(\n            'https://vk.com/%s.php' % path, video_id,\n            data=urlencode_postdata(data), fatal=fatal,\n            headers={'X-Requested-With': 'XMLHttpRequest'})['payload']\n        if code == '3':\n            self.raise_login_required()\n        elif code == '8':\n            raise ExtractorError(clean_html(payload[0][1:-1]), expected=True)\n        return payload\n\n\nclass VKIE(VKBaseIE):\n    IE_NAME = 'vk'\n    IE_DESC = 'VK'\n    _VALID_URL = r'''(?x)\n                    https?://\n                        (?:\n                            (?:\n                                (?:(?:m|new)\\.)?vk\\.com/video_|\n                                (?:www\\.)?daxab.com/\n                            )\n                            ext\\.php\\?(?P<embed_query>.*?\\boid=(?P<oid>-?\\d+).*?\\bid=(?P<id>\\d+).*)|\n                            (?:\n                                (?:(?:m|new)\\.)?vk\\.com/(?:.+?\\?.*?z=)?video|\n                                (?:www\\.)?daxab.com/embed/\n                            )","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/vk.py#L56-L92","documentation":"VK's internal _download_payload helper raises this when the JSON payload from vk.com/<module>.php returns code '8'. In that case payload[0] carries an HTML error fragment, which is cleaned via clean_html(payload[0][1:-1]) and raised as an expected ExtractorError. The visible message is whatever VK put in that fragment (not the literal placeholder).","triggerScenarios":"POSTing al=1 AJAX requests to vk.com (e.g. video retrieval via video_ext or similar modules) where the response payload code is '8' — typically an application-level error such as content removal or access restrictions.","commonSituations":"Video removed or region-blocked; account lacks access to the content; VK changed its internal payload codes so the '8' branch fires more often.","solutions":["Read the cleaned HTML text in the raised message — it is VK's own error explanation","Open the VK page in a browser to see the underlying access problem (removal, region, login)","Update youtube-dl/yt-dlp; VK's AJAX payload contract changes over time"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from youtube_dl.utils import ExtractorError\ntry:\n    ydl.extract_info(url)\nexcept ExtractorError as e:\n    vk_msg = str(e)\n    if 'removed' in vk_msg or 'deleted' in vk_msg:\n        blacklist(url)\n    else:\n        log('VK payload error: %s' % vk_msg)","preventionTips":["Treat payload code '8' messages as authoritative VK status text","Wrap batch extraction so one VK error doesn't abort the queue","Keep extractors updated; payload codes shift with VK changes"],"tags":["vk","ajax-payload","html-error","extractor"],"backgroundTag":null,"analyzedSha":"956b8c585591b401a543e409accb163eeaaa1193","analyzedAt":"2026-08-14T18:59:47.863Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}