{"record":{"id":"fd0bd47b62deeda4","repo":"ytdl-org/youtube-dl","slug":"error-fd0bd4","errorCode":null,"errorMessage":"error","messagePattern":"error","errorType":"exception","errorClass":"ExtractorError","httpStatus":null,"severity":"error","filePath":"youtube_dl/extractor/yandexmusic.py","lineNumber":26,"sourceCode":"from .common import InfoExtractor\nfrom ..compat import compat_str\nfrom ..utils import (\n    ExtractorError,\n    int_or_none,\n    float_or_none,\n    try_get,\n)\n\n\nclass YandexMusicBaseIE(InfoExtractor):\n    _VALID_URL_BASE = r'https?://music\\.yandex\\.(?P<tld>ru|kz|ua|by|com)'\n\n    @staticmethod\n    def _handle_error(response):\n        if isinstance(response, dict):\n            error = response.get('error')\n            if error:\n                raise ExtractorError(error, expected=True)\n            if response.get('type') == 'captcha' or 'captcha' in response:\n                YandexMusicBaseIE._raise_captcha()\n\n    @staticmethod\n    def _raise_captcha():\n        raise ExtractorError(\n            'YandexMusic has considered youtube-dl requests automated and '\n            'asks you to solve a CAPTCHA. You can either wait for some '\n            'time until unblocked and optionally use --sleep-interval '\n            'in future or alternatively you can go to https://music.yandex.ru/ '\n            'solve CAPTCHA, then export cookies and pass cookie file to '\n            'youtube-dl with --cookies',\n            expected=True)\n\n    def _download_webpage_handle(self, *args, **kwargs):\n        webpage = super(YandexMusicBaseIE, self)._download_webpage_handle(*args, **kwargs)\n        if 'Нам очень жаль, но&nbsp;запросы, поступившие с&nbsp;вашего IP-адреса, похожи на&nbsp;автоматические.' in webpage:\n            self._raise_captcha()","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/yandexmusic.py#L8-L44","documentation":"Raised by the YandexMusic base extractor's _handle_error when a downloaded JSON response is a dict with a truthy 'error' key. Yandex's API signals failures (invalid track/album IDs, expired sessions, rate limits) in that field, and its string value is raised verbatim.","triggerScenarios":"Any YandexMusic API call (download_json in extractor subclasses) whose response dict contains response['error']; _handle_error is invoked on each response before data extraction.","commonSituations":"Deleted tracks/albums on Yandex Music; region differences between yandex.ru/kz/ua/by/com TLDs; requests without valid cookies being rejected by the API.","solutions":["Read the forwarded error string — it comes straight from Yandex's API.","Verify the track/album/playlist ID on the matching Yandex Music TLD.","Pass authentication with --cookies exported from a logged-in browser session.","If the error mentions automation/captcha, follow the CAPTCHA guidance (see the sibling captcha error)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"def yandex_response_ok(response) -> bool:\n    return not (isinstance(response, dict) and response.get('error'))","tryCatchPattern":"try:\n    info = ydl.extract_info(url)\nexcept ExtractorError as e:\n    if 'captcha' in str(e).lower():\n        handle_captcha_flow()\n    else:\n        log_api_error(url, str(e))","preventionTips":["Pass --cookies from a logged-in browser session for Yandex Music.","Validate track/album IDs against the correct yandex TLD before extraction.","Separate captcha errors from plain API errors in your handling — they need different remedies."],"tags":["api-error","extractor","yandex","music"],"backgroundTag":null,"analyzedSha":"956b8c585591b401a543e409accb163eeaaa1193","analyzedAt":"2026-08-14T18:59:47.863Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}