{"record":{"id":"1e57c930f5e1ba0e","repo":"soimort/you-get","slug":"weibo-api-returns-non-success-s-s","errorCode":null,"errorMessage":"Weibo api returns non-success: (%s)%s","messagePattern":"Weibo api returns non-success: \\((.+?)\\)(.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/you_get/extractors/miaopai.py","lineNumber":102,"sourceCode":"        oid = match1(url, r'\\?fid=(\\d{4}:\\w+)')\n    page = \"/show/%s\" % oid\n    data_url = 'https://h5.video.weibo.com/api/component?%s' % parse.urlencode({\n        'page': page\n    })\n    headers = {}\n    headers.update(fake_headers_mobile)\n    headers['origin'] = 'https://h5.video.weibo.com'\n    headers['page-referer'] = page\n    headers['referer'] = 'https://h5.video.weibo.com/show/%s' % oid\n    post_data = {\n        \"data\": json.dumps({\n            \"Component_Play_Playinfo\": {\"oid\": oid}\n        })\n    }\n    data_content = post_content(data_url, headers=headers, post_data=post_data)\n    data = json.loads(data_content)\n    if data['msg'] != 'succ':\n        raise Exception('Weibo api returns non-success: (%s)%s'.format(data['code'], data['msg']))\n\n    play_info = data['data']['Component_Play_Playinfo']\n    title = play_info['title']\n\n    # get video formats and sort by size desc\n    video_formats = []\n    for fmt, relative_uri in play_info['urls'].items():\n        url = \"https:%s\" % relative_uri\n        type, ext, size = url_info(url, headers=headers)\n        video_formats.append({\n            'fmt': fmt,\n            'url': url,\n            'type': type,\n            'ext': ext,\n            'size': size,\n        })\n    video_formats.sort(key=lambda v:v['size'], reverse=True)\n    selected_video = video_formats[0]","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/soimort/you-get/blob/049548f3f3f35e67ba8d3181c71fdc71d11cf260/src/you_get/extractors/miaopai.py#L84-L120","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before (values never interpolate)\nraise Exception('Weibo api returns non-success: (%s)%s'.format(data['code'], data['msg']))\n\n# after\nraise Exception('Weibo api returns non-success: ({}){}'.format(data['code'], data['msg']))","handlingStrategy":"try-catch","validationCode":"def weibo_playinfo_ok(data):\n    return isinstance(data, dict) and data.get('msg') == 'succ'","typeGuard":null,"tryCatchPattern":"try:\n    miaopai_download(url, ...)\nexcept Exception as e:\n    msg = str(e)\n    if 'Weibo api returns non-success' in msg:\n        print('video deleted or anti-bot refusal; verify in browser')\n    else:\n        raise","preventionTips":["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"],"tags":["miaopai","weibo-api","anti-bot","error-formatting"],"backgroundTag":null,"analyzedSha":"049548f3f3f35e67ba8d3181c71fdc71d11cf260","analyzedAt":"2026-08-15T03:58:15.069Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}