{"record":{"id":"bf1d6c5d72c033b3","repo":"soimort/you-get","slug":"server-returned-error-s","errorCode":null,"errorMessage":"Server returned error:%s","messagePattern":"Server returned error:(.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/you_get/extractors/douyutv.py","lineNumber":66,"sourceCode":"    url = re.sub(r'.*douyu.com','https://m.douyu.com/room', url)\n    html = get_content(url, headers)\n    room_id_patt = r'\"rid\"\\s*:\\s*(\\d+),'\n    room_id = match1(html, room_id_patt)\n    if room_id == \"0\":\n        room_id = url[url.rfind('/') + 1:]\n\n    api_url = \"http://www.douyutv.com/api/v1/\"\n    args = \"room/%s?aid=wp&client_sys=wp&time=%d\" % (room_id, int(time.time()))\n    auth_md5 = (args + \"zNzMV1y4EMxOHS6I5WKm\").encode(\"utf-8\")\n    auth_str = hashlib.md5(auth_md5).hexdigest()\n    json_request_url = \"%s%s&auth=%s\" % (api_url, args, auth_str)\n\n    content = get_content(json_request_url, headers)\n    json_content = json.loads(content)\n    data = json_content['data']\n    server_status = json_content.get('error', 0)\n    if server_status != 0:\n        raise ValueError(\"Server returned error:%s\" % server_status)\n\n    title = data.get('room_name')\n    show_status = data.get('show_status')\n    if show_status != \"1\":\n        raise ValueError(\"The live stream is not online! (Errno:%s)\" % server_status)\n\n    real_url = data.get('rtmp_url') + '/' + data.get('rtmp_live')\n\n    print_info(site_info, title, 'flv', float('inf'))\n    if not info_only:\n        download_url_ffmpeg(real_url, title, 'flv', params={}, output_dir=output_dir, merge=merge)\n\n\nsite_info = \"douyu.com\"\ndownload = douyutv_download\ndownload_playlist = playlist_not_supported('douyu')\n","sourceCodeStart":48,"sourceCodeEnd":83,"githubUrl":"https://github.com/soimort/you-get/blob/049548f3f3f35e67ba8d3181c71fdc71d11cf260/src/you_get/extractors/douyutv.py#L48-L83","documentation":"Raised as ValueError in douyutv_download (src/you_get/extractors/douyutv.py:66). The extractor calls Douyu's private API v1 (room/<id>?aid=wp... with an md5 auth built from a hardcoded key) and checks the 'error' field of the JSON response. Any nonzero value means the API itself rejected the request before room data is usable.","triggerScenarios":"GET of http://www.douyutv.com/api/v1/room/<room_id>?aid=wp&client_sys=wp&time=<ts>&auth=<md5> returns JSON whose 'error' field is nonzero: invalid/nonexistent room_id, or the embedded auth key 'zNzMV1y4EMxOHS6I5WKm' / API contract no longer accepted by Douyu.","commonSituations":"Room ID parsed from an old-style URL no longer exists; Douyu rotated the API secret or shut down API v1 (it is an undocumented endpoint), making every request fail regardless of room; region blocks returning error JSON.","solutions":["Confirm the room ID and URL are correct and the room still exists on douyu.com.","If every room fails, the hardcoded API key/endpoint is outdated — update the auth key and endpoint in douyutv.py or upgrade you-get.","Inspect the raw JSON (log json_content) to see the specific error code Douyu returns."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    douyutv_download(url, output_dir)\nexcept ValueError as e:\n    if str(e).startswith('Server returned error'):\n        log_api_rejection(url, e)  # likely bad room id or dead API; do not retry\n    else:\n        raise","preventionTips":["Validate the room id is numeric and the room exists before calling.","Watch for upstream breakage: a hardcoded md5 auth key means the extractor can die site-wide."],"tags":["you-get","douyu","api-error","extractor","live-stream"],"backgroundTag":null,"analyzedSha":"049548f3f3f35e67ba8d3181c71fdc71d11cf260","analyzedAt":"2026-08-15T03:58:15.069Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}