soimort/you-get · error · AssertionError
Share not found or canceled: %s
Error message
Share not found or canceled: %s
What it means
Raised as AssertionError in baidu_pan_download (src/you_get/extractors/baidu.py:195). After fetching the share page, baidu_pan_parse fails to extract a sign token (sign is None) and the page does not contain the 'access-code' marker for password-protected shares, so the share is treated as deleted, canceled, or never existed.
Source
Thrown at src/you_get/extractors/baidu.py:195
}
if cookies:
print('Use user specified cookies')
else:
print('Generating cookies...')
fake_headers['Cookie'] = baidu_pan_gen_cookies(url)
refer_url = "http://pan.baidu.com"
html = get_content(url, fake_headers, decoded=True)
isprotected = False
sign, timestamp, bdstoken, appid, primary_id, fs_id, uk = baidu_pan_parse(
html)
if sign is None:
if re.findall(r'\baccess-code\b', html):
isprotected = True
sign, timestamp, bdstoken, appid, primary_id, fs_id, uk, fake_headers, psk = baidu_pan_protected_share(
url)
# raise NotImplementedError("Password required!")
if isprotected != True:
raise AssertionError("Share not found or canceled: %s" % url)
if bdstoken is None:
bdstoken = ""
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)View on GitHub (pinned to 049548f3f3)
Solutions
- Verify the share URL still opens in a browser; if Baidu says the file was canceled/deleted, obtain a fresh share link.
- If the share needs a password, make sure the page is recognized as protected (the 'access-code' marker must appear) and pass the correct password so baidu_pan_protected_share runs.
- If the URL is valid in a browser, the site markup likely changed — update the regexes in baidu_pan_parse or upgrade you-get to a newer release.
Example fix
# before
baidu_pan_download('http://pan.baidu.com/share/link?shareid=123&uk=456') # dead link
# after (verify share exists, then fetch)
# open the URL in a browser first; if canceled, get a new share link
baidu_pan_download(new_valid_share_url) Defensive patterns
Strategy: try-catch
Validate before calling
import re
def baidu_share_alive(html):
# same signal the extractor uses: a parseable sign or an access-code marker
has_sign = re.search(r'"?sign"?\s*[:=]\s*["\']([\w-]+)', html) is not None
is_protected = bool(re.findall(r'\baccess-code\b', html))
return has_sign or is_protected Try / catch
try:
baidu_pan_download(url)
except AssertionError as e:
if 'Share not found or canceled' in str(e):
# dead link: surface to user / drop from queue, do not retry
mark_share_dead(url)
else:
raise Prevention
- Verify the share URL loads in a browser before batch processing.
- For password-protected shares always supply the password so the protected-share branch runs.
When it happens
Trigger: Calling baidu_pan_download with a pan.baidu.com share URL that was deleted/canceled by its owner, never existed, or whose page layout changed so baidu_pan_parse can no longer find the sign regex AND the page lacks r'\baccess-code\b'. Only raised when isprotected stays False.
Common situations: Expired Baidu cloud shares (very common), mistyped share link (wrong uk/id), Baidu changing the share page HTML so the parse regexes break, or a protected share whose access-code marker is not detected due to markup change.
Related errors
- Server refused to provide download link! (Errno:%s)
- Server returned an error: %s (Incorrect password?)
- Playlist is not supported for
- Server returned error:%s
- The live stream is not online! (Errno:%s)
AI-assisted analysis of soimort/you-get@049548f3f3 (2026-08-15).
Data as JSON: /api/errors/ee99bf81c7d709d0.
Report an issue: GitHub.