{"record":{"id":"4f2b6bcef44b5ddd","repo":"soimort/you-get","slug":"server-refused-to-provide-download-link-errno-s","errorCode":null,"errorMessage":"Server refused to provide download link! (Errno:%s)","messagePattern":"Server refused to provide download link! \\(Errno:(.+?)\\)","errorType":"exception","errorClass":"AssertionError","httpStatus":null,"severity":"error","filePath":"src/you_get/extractors/baidu.py","lineNumber":216,"sourceCode":"    if isprotected != True:\n        sign, timestamp, bdstoken, appid, primary_id, fs_id, uk = baidu_pan_parse(\n            html)\n    request_url = \"http://pan.baidu.com/api/sharedownload?sign=%s&timestamp=%s&bdstoken=%s&channel=chunlei&clienttype=0&web=1&app_id=%s\" % (\n        sign, timestamp, bdstoken, appid)\n    refer_url = url\n    post_data = {\n        'encrypt': 0,\n        'product': 'share',\n        'uk': uk,\n        'primaryid': primary_id,\n        'fid_list': '[' + fs_id + ']'\n    }\n    if isprotected == True:\n        post_data['sekey'] = psk\n    response_content = post_content(request_url, fake_headers, post_data, True)\n    errno = match1(response_content, errno_patt)\n    if errno != \"0\":\n        raise AssertionError(\n            \"Server refused to provide download link! (Errno:%s)\" % errno)\n    real_url = r1(r'dlink\":\"([^\"]+)\"', response_content).replace('\\\\/', '/')\n    title = r1(r'server_filename\":\"([^\"]+)\"', response_content)\n    assert real_url\n    type, ext, size = url_info(real_url, faker=True)\n    title_wrapped = json.loads('{\"wrapper\":\"%s\"}' % title)\n    title = title_wrapped['wrapper']\n    logging.debug(real_url)\n    return real_url, title, ext, size\n\n\ndef baidu_pan_parse(html):\n    sign_patt = r'sign\":\"([^\"]+)\"'\n    timestamp_patt = r'timestamp\":([^\"]+),'\n    appid_patt = r'app_id\":\"([^\"]+)\"'\n    bdstoken_patt = r'bdstoken\":\"([^\"]+)\"'\n    fs_id_patt = r'fs_id\":([^\"]+),'\n    uk_patt = r'uk\":([^\"]+),'","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/soimort/you-get/blob/049548f3f3f35e67ba8d3181c71fdc71d11cf260/src/you_get/extractors/baidu.py#L198-L234","documentation":"Raised as AssertionError in baidu_pan_download (src/you_get/extractors/baidu.py:216). The POST to pan.baidu.com/api/sharedownload succeeded HTTP-wise but the JSON errno field is not '0', meaning Baidu declined to hand out the dlink (download URL). errno values distinguish rate limiting, auth failures, invalid sekey, etc.","triggerScenarios":"post_content() to http://pan.baidu.com/api/sharedownload returns an errno != '0'. Typical cases: too many download-link requests from one IP (errno 118/119- style throttling), missing/invalid sekey for a protected share, expired sign/timestamp, or Baidu API policy changes.","commonSituations":"Repeated batch downloads of Baidu shares triggering anti-leech throttling; protected share where the password cookie (BDCLND/sekey) is wrong or expired; long-running scripts where the one-time sign has gone stale.","solutions":["Wait a while (minutes) and retry — most nonzero errnos here are transient rate-limit responses.","For protected shares, re-run the password flow so a fresh sekey/BDCLND cookie is used.","Log the actual errno value to identify the specific Baidu refusal reason and adjust (e.g. reduce request frequency, rotate referer/headers).","If persistent across all shares, Baidu's API changed — update the request/parse code or upgrade you-get."],"exampleFix":"# before\nerrno = match1(response_content, errno_patt)\nif errno != \"0\":\n    raise AssertionError(\"Server refused to provide download link! (Errno:%s)\" % errno)\n\n# after: retry with backoff on transient errnos\nfor attempt in range(3):\n    response_content = post_content(request_url, fake_headers, post_data, True)\n    errno = match1(response_content, errno_patt)\n    if errno == \"0\":\n        break\n    sleep(30 * (attempt + 1))\nelse:\n    raise AssertionError(\"Server refused to provide download link! (Errno:%s)\" % errno)","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"import time\nfor attempt in range(3):\n    try:\n        return baidu_pan_download(url)\n    except AssertionError as e:\n        msg = str(e)\n        if 'Server refused' in msg and 'Errno:118' in msg or 'Errno:119' in msg:\n            time.sleep(60 * (attempt + 1))  # throttle backoff\n            continue\n        raise","preventionTips":["Throttle Baidu share downloads (minutes between link requests) to avoid anti-leech errnos.","Log the errno value so refusals can be classified as transient vs permanent."],"tags":["you-get","baidu","rate-limit","api-error","network"],"backgroundTag":null,"analyzedSha":"049548f3f3f35e67ba8d3181c71fdc71d11cf260","analyzedAt":"2026-08-15T03:58:15.069Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}