{"record":{"id":"7f1bc36932d06247","repo":"soimort/you-get","slug":"the-live-stream-is-not-online","errorCode":null,"errorMessage":"The live stream is not online!","messagePattern":"The live stream is not online!","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/you_get/extractors/longzhu.py","lineNumber":30,"sourceCode":"    playlist_not_supported,\n)\nfrom ..common import player\n\ndef longzhu_download(url, output_dir = '.', merge=True, info_only=False, **kwargs):\n    web_domain = url.split('/')[2]\n    if (web_domain == 'star.longzhu.com') or (web_domain == 'y.longzhu.com'):\n        domain = url.split('/')[3].split('?')[0]\n        m_url = 'http://m.longzhu.com/{0}'.format(domain)\n        m_html = get_content(m_url)\n        room_id_patt = r'var\\s*roomId\\s*=\\s*(\\d+);'\n        room_id = match1(m_html,room_id_patt)\n\n        json_url = 'http://liveapi.plu.cn/liveapp/roomstatus?roomId={0}'.format(room_id)\n        content = get_content(json_url)\n        data = json.loads(content)\n        streamUri = data['streamUri']\n        if len(streamUri) <= 4:\n            raise ValueError('The live stream is not online!')\n        title = data['title']\n        streamer = data['userName']\n        title = str.format(streamer,': ',title)\n\n        steam_api_url = 'http://livestream.plu.cn/live/getlivePlayurl?roomId={0}'.format(room_id)\n        content = get_content(steam_api_url)\n        data = json.loads(content)\n        isonline = data.get('isTransfer')\n        if isonline == '0':\n            raise ValueError('The live stream is not online!')\n\n        real_url = data['playLines'][0]['urls'][0]['securityUrl']\n\n        print_info(site_info, title, 'flv', float('inf'))\n\n        if not info_only:\n            download_urls([real_url], title, 'flv', None, output_dir, merge=merge)\n","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/soimort/you-get/blob/049548f3f3f35e67ba8d3181c71fdc71d11cf260/src/you_get/extractors/longzhu.py#L12-L48","documentation":"Raised by the Longzhu (star.longzhu.com / y.longzhu.com) extractor after fetching http://liveapi.plu.cn/liveapp/roomstatus?roomId=... — the returned JSON's 'streamUri' field is 4 characters or shorter (effectively empty). you-get treats an empty streamUri as proof that the room exists but is not currently broadcasting, so it aborts with ValueError instead of trying to download a nonexistent stream.","triggerScenarios":"Calling you_get with a URL whose host is star.longzhu.com or y.longzhu.com while the room's roomId resolves to an offline/ended broadcast; the roomstatus API responds 200 with streamUri=\"\" (or similarly tiny), triggering the len(streamUri) <= 4 branch at src/you_get/extractors/longzhu.py:30.","commonSituations":"Streamers who went offline between page load and API call; bookmarked/VOD-shared links to rooms that no longer broadcast; API schema drift where streamUri is renamed, making len() read as 0 on an absent key (would instead KeyError) or empty default.","solutions":["Open the room page in a browser and confirm the broadcaster is actually live right now","Retry the download while the stream is actively broadcasting","If the stream is live but the error persists, inspect the roomstatus JSON (curl 'http://liveapi.plu.cn/liveapp/roomstatus?roomId=<id>') to check whether the 'streamUri' key or its format changed","For ended broadcasts, use a replay.longzhu.com URL (handled by the replay branch) instead of the live-room URL"],"exampleFix":"# before\nyou_get 'http://star.longzhu.com/12345'  # room offline -> ValueError\n\n# after\n# verify liveness first\nimport json, urllib.request\nd = json.load(urllib.request.urlopen('http://liveapi.plu.cn/liveapp/roomstatus?roomId=%s' % room_id))\nassert len(d['streamUri']) > 4, 'room offline, do not attempt download'","handlingStrategy":"validation","validationCode":"import json\nfrom urllib.request import urlopen\n\ndef longzhu_room_live(room_id):\n    d = json.load(urlopen('http://liveapi.plu.cn/liveapp/roomstatus?roomId=%s' % room_id))\n    return len(d.get('streamUri', '')) > 4","typeGuard":null,"tryCatchPattern":"try:\n    longzhu_download(url, ...)\nexcept ValueError as e:\n    if 'not online' in str(e):\n        print('room offline, skip')\n    else:\n        raise","preventionTips":["Check the room is broadcasting on star.longzhu.com before starting the download","Poll the roomstatus API for a non-empty streamUri when automation must start at stream begin","Treat 'not online' as an expected terminal state, not a transient error — do not blind-retry"],"tags":["live-stream","longzhu","api-response","offline"],"backgroundTag":null,"analyzedSha":"049548f3f3f35e67ba8d3181c71fdc71d11cf260","analyzedAt":"2026-08-15T03:58:15.069Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}