soimort/you-get · error · Exception
Weibo api returns non-success: (%s)%s
Error message
Weibo api returns non-success: (%s)%s
What it means
The Miaopai extractor resolves videos through Weibo's h5 API (POST to https://h5.video.weibo.com with Component_Play_Playinfo {oid}) and expects data['msg'] == 'succ'. Any other msg/code — invalid oid, deleted video, anti-crawler refusal — raises Exception('Weibo api returns non-success: ...'). Note the message is built with '.format' on a '%s' template, so the code/msg values never appear; the literal text '(%s)%s' is what you see.
Source
Thrown at src/you_get/extractors/miaopai.py:102
oid = match1(url, r'\?fid=(\d{4}:\w+)')
page = "/show/%s" % oid
data_url = 'https://h5.video.weibo.com/api/component?%s' % parse.urlencode({
'page': page
})
headers = {}
headers.update(fake_headers_mobile)
headers['origin'] = 'https://h5.video.weibo.com'
headers['page-referer'] = page
headers['referer'] = 'https://h5.video.weibo.com/show/%s' % oid
post_data = {
"data": json.dumps({
"Component_Play_Playinfo": {"oid": oid}
})
}
data_content = post_content(data_url, headers=headers, post_data=post_data)
data = json.loads(data_content)
if data['msg'] != 'succ':
raise Exception('Weibo api returns non-success: (%s)%s'.format(data['code'], data['msg']))
play_info = data['data']['Component_Play_Playinfo']
title = play_info['title']
# get video formats and sort by size desc
video_formats = []
for fmt, relative_uri in play_info['urls'].items():
url = "https:%s" % relative_uri
type, ext, size = url_info(url, headers=headers)
video_formats.append({
'fmt': fmt,
'url': url,
'type': type,
'ext': ext,
'size': size,
})
video_formats.sort(key=lambda v:v['size'], reverse=True)
selected_video = video_formats[0]View on GitHub (pinned to 049548f3f3)
Solutions
- Open the miaopai page in a browser to confirm the video still exists
- Retry once — transient anti-bot refusals often pass on a fresh request
- Fix the message formatting bug so the real code/msg show: use 'Weibo api returns non-success: ({}){}'.format(data['code'], data['msg']) at src/you_get/extractors/miaopai.py:102
- If the API requires cookies, extend headers/post_data to include a valid session
Example fix
# before (values never interpolate)
raise Exception('Weibo api returns non-success: (%s)%s'.format(data['code'], data['msg']))
# after
raise Exception('Weibo api returns non-success: ({}){}'.format(data['code'], data['msg'])) Defensive patterns
Strategy: try-catch
Validate before calling
def weibo_playinfo_ok(data):
return isinstance(data, dict) and data.get('msg') == 'succ' Try / catch
try:
miaopai_download(url, ...)
except Exception as e:
msg = str(e)
if 'Weibo api returns non-success' in msg:
print('video deleted or anti-bot refusal; verify in browser')
else:
raise Prevention
- Remember the raised message shows literal '(%s)%s' — the real code/msg are not interpolated; inspect the API response yourself
- Verify the miaopai page still plays in a browser before batch jobs
- Space out automated requests to avoid Weibo h5 API anti-bot responses
When it happens
Trigger: miaopai_download_by_fid invoked with an oid the Weibo API rejects (deleted/expired video, wrong fid prefix), or the API returning a captcha/verification response because the request lacks expected cookies/headers.
Common situations: Old miaopai links whose backing Weibo video was removed; heavy automated use tripping anti-bot; API response shape change making data['msg'] absent (that case raises KeyError instead); fid extracted with an incompatible prefix.
Related errors
AI-assisted analysis of soimort/you-get@049548f3f3 (2026-08-15).
Data as JSON: /api/errors/1e57c930f5e1ba0e.
Report an issue: GitHub.