{"record":{"id":"acf313891511a643","repo":"soimort/you-get","slug":"the-live-stream-is-not-online-acf313","errorCode":null,"errorMessage":"The live stream is not online!","messagePattern":"The live stream is not online!","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/you_get/extractors/zhanqi.py","lineNumber":27,"sourceCode":"\ndef zhanqi_download(url, output_dir = '.', merge = True, info_only = False, **kwargs):\n    path = urlparse(url).path[1:]\n\n    if not (path.startswith('videos') or path.startswith('v2/videos')): #url = \"https://www.zhanqi.tv/huashan?param_s=1_0.2.0\"\n        path_list = path.split('/')\n        room_id = path_list[1] if path_list[0] == 'topic' else path_list[0]\n        zhanqi_live(room_id, merge=merge, output_dir=output_dir, info_only=info_only, **kwargs)\n    else: #url = 'https://www.zhanqi.tv/videos/Lyingman/2017/01/182308.html'\n        # https://www.zhanqi.tv/v2/videos/215593.html\n        video_id = path.split('.')[0].split('/')[-1]\n        zhanqi_video(video_id, merge=merge, output_dir=output_dir, info_only=info_only, **kwargs)\n\ndef zhanqi_live(room_id, merge=True, output_dir='.', info_only=False, **kwargs):\n    api_url = \"https://www.zhanqi.tv/api/static/v2.1/room/domain/{}.json\".format(room_id)\n    json_data = json.loads(get_content(api_url))['data']\n    status = json_data['status']\n    if status != '4':\n        raise Exception(\"The live stream is not online!\")\n\n    nickname = json_data['nickname']\n    title = nickname + \": \" + json_data['title']\n    video_levels = base64.b64decode(json_data['flashvars']['VideoLevels']).decode('utf8')\n    m3u8_url = json.loads(video_levels)['streamUrl']\n\n    print_info(site_info, title, 'm3u8', 0, m3u8_url=m3u8_url, m3u8_type='master')\n    if not info_only:\n        download_url_ffmpeg(m3u8_url, title, 'mp4', output_dir=output_dir, merge=merge)\n\ndef zhanqi_video(video_id, output_dir='.', info_only=False, merge=True, **kwargs):\n    api_url = 'https://www.zhanqi.tv/api/static/v2.1/video/{}.json'.format(video_id)\n    json_data = json.loads(get_content(api_url))['data']\n\n    title = json_data['title']\n    vid = json_data['flashvars']['VideoID']\n    m3u8_url = 'http://dlvod.cdn.zhanqi.tv/' + vid\n    urls = general_m3u8_extractor(m3u8_url)","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/soimort/you-get/blob/049548f3f3f35e67ba8d3181c71fdc71d11cf260/src/you_get/extractors/zhanqi.py#L9-L45","documentation":"zhanqi_live fetches https://www.zhanqi.tv/api/static/v2.1/room/domain/<room_id>.json and treats room status code '4' as the only live state; any other status raises Exception('The live stream is not online!'). The status field encodes the room lifecycle, and non-4 values cover offline, ended, and other non-broadcasting states.","triggerScenarios":"Downloading a zhanqi.tv room that is not currently broadcasting (status 0/1/2/3 etc. from the domain API), or a room_id that resolves to a closed/renamed room; the check sits at src/you_get/extractors/zhanqi.py:27 before nickname/stream parsing.","commonSituations":"Streamers offline at download time; bookmarked rooms that stopped existing; status enum drift (site adding a new live-ish status the extractor doesn't map to '4'); recordings mistakenly addressed with the live-room URL instead of the /videos/ path handled by zhanqi_video.","solutions":["Confirm the room is broadcasting on zhanqi.tv before invoking","For finished broadcasts, use the VOD URL form (e.g. https://www.zhanqi.tv/videos/215593.html) which routes to zhanqi_video instead","Inspect the domain API JSON to see the actual status value; if a new status means live, update the != '4' check","Retry while the stream is up — capture live streams promptly since they cannot be fetched after the fact via this path"],"exampleFix":"# before\nstatus = json_data['status']\nif status != '4':\n    raise Exception(\"The live stream is not online!\")\n\n# after (include the raw status for diagnosis)\nstatus = json_data['status']\nif status != '4':\n    raise Exception(\"The live stream is not online! (room status=%s)\" % status)","handlingStrategy":"validation","validationCode":"import json\n\ndef zhanqi_room_live(room_id, fetch):\n    d = json.loads(fetch('https://www.zhanqi.tv/api/static/v2.1/room/domain/%s.json' % room_id))['data']\n    return d['status'] == '4'","typeGuard":null,"tryCatchPattern":"try:\n    zhanqi_download(url, ...)\nexcept Exception as e:\n    if 'not online' in str(e):\n        print('room offline; use a /videos/ URL for VOD or retry while live')\n    else:\n        raise","preventionTips":["Poll the room domain API until status == '4' before starting capture automation","Use the /videos/<id>.html form for recordings — it routes to zhanqi_video, not the live path","Log the raw status value on failure so enum drift is detectable"],"tags":["zhanqi","live-stream","offline","api-response"],"backgroundTag":null,"analyzedSha":"049548f3f3f35e67ba8d3181c71fdc71d11cf260","analyzedAt":"2026-08-15T03:58:15.069Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}