soimort/you-get · error · AssertionError
Server refused to provide download link!
Error message
Server refused to provide download link! (Errno:%s)
What it means
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.
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.
Example fix
# before
errno = match1(response_content, errno_patt)
if errno != "0":
raise AssertionError("Server refused to provide download link! (Errno:%s)" % errno)
# after: retry with backoff on transient errnos
for attempt in range(3):
response_content = post_content(request_url, fake_headers, post_data, True)
errno = match1(response_content, errno_patt)
if errno == "0":
break
sleep(30 * (attempt + 1))
else:
raise AssertionError("Server refused to provide download link! (Errno:%s)" % errno) Defensive patterns
Strategy: retry
Try / catch
import time
for attempt in range(3):
try:
return baidu_pan_download(url)
except AssertionError as e:
msg = str(e)
if 'Server refused' in msg and 'Errno:118' in msg or 'Errno:119' in msg:
time.sleep(60 * (attempt + 1)) # throttle backoff
continue
raise Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of soimort/you-get@049548f3f3 (2026-08-15).
Data as JSON: /api/errors/4f2b6bcef44b5ddd.
Report an issue: GitHub.
Appendix: source
Thrown at src/you_get/extractors/baidu.py:216
if isprotected != True:
sign, timestamp, bdstoken, appid, primary_id, fs_id, uk = baidu_pan_parse(
html)
request_url = "http://pan.baidu.com/api/sharedownload?sign=%s×tamp=%s&bdstoken=%s&channel=chunlei&clienttype=0&web=1&app_id=%s" % (
sign, timestamp, bdstoken, appid)
refer_url = url
post_data = {
'encrypt': 0,
'product': 'share',
'uk': uk,
'primaryid': primary_id,
'fid_list': '[' + fs_id + ']'
}
if isprotected == True:
post_data['sekey'] = psk
response_content = post_content(request_url, fake_headers, post_data, True)
errno = match1(response_content, errno_patt)
if errno != "0":
raise AssertionError(
"Server refused to provide download link! (Errno:%s)" % errno)
real_url = r1(r'dlink":"([^"]+)"', response_content).replace('\\/', '/')
title = r1(r'server_filename":"([^"]+)"', response_content)
assert real_url
type, ext, size = url_info(real_url, faker=True)
title_wrapped = json.loads('{"wrapper":"%s"}' % title)
title = title_wrapped['wrapper']
logging.debug(real_url)
return real_url, title, ext, size
def baidu_pan_parse(html):
sign_patt = r'sign":"([^"]+)"'
timestamp_patt = r'timestamp":([^"]+),'
appid_patt = r'app_id":"([^"]+)"'
bdstoken_patt = r'bdstoken":"([^"]+)"'
fs_id_patt = r'fs_id":([^"]+),'
uk_patt = r'uk":([^"]+),'View on GitHub (pinned to 049548f3f3)