From 3965487746d4330a71ef9906b8d0fed88034f5d7 Mon Sep 17 00:00:00 2001 From: Hmily <114978440+ihmily@users.noreply.github.com> Date: Thu, 28 Aug 2025 17:03:10 +0800 Subject: [PATCH] fix bigo room_id parse and twitcasting login (#1194) --- src/spider.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/spider.py b/src/spider.py index 950fa32..3e1d107 100644 --- a/src/spider.py +++ b/src/spider.py @@ -772,7 +772,7 @@ async def get_bigo_stream_url(url: str, proxy_addr: OptionalStr = None, cookies: if '&h=' in url: room_id = url.split('&h=')[-1] else: - room_id = re.search('www.bigo.tv/cn/(\\w+)', url).group(1) + room_id = url.split("?")[0].rsplit("/", maxsplit=1)[-1] data = {'siteId': room_id} # roomId url2 = 'https://ta.bigo.tv/official_website/studio/getInternalStudioInfo' @@ -789,8 +789,16 @@ async def get_bigo_stream_url(url: str, proxy_addr: OptionalStr = None, cookies: result['record_url'] = m3u8_url result |= {"title": live_title, "is_live": True, "m3u8_url": m3u8_url, 'record_url': m3u8_url} elif result['anchor_name'] == '': - html_str = await async_req(url=f'https://www.bigo.tv/cn/{room_id}', proxy_addr=proxy_addr, headers=headers) - result['anchor_name'] = re.search('欢迎来到(.*?)的直播间', html_str, re.DOTALL).group(1) + html_str = await async_req(url=f'https://www.bigo.tv/{url.split("/")[3]}/{room_id}', + proxy_addr=proxy_addr, headers=headers) + match_anchor_name = re.search('欢迎来到(.*?)的直播间', html_str, re.DOTALL) + if match_anchor_name: + anchor_name = match_anchor_name.group(1) + else: + match_anchor_name = re.search('', html_str, re.DOTALL) + anchor_name = match_anchor_name.group(1) + result['anchor_name'] = anchor_name return result @@ -1711,7 +1719,7 @@ async def login_twitcasting( } try: cookie_dict = await async_req(login_api, proxy_addr=proxy_addr, headers=headers, - json_data=data, return_cookies=True, timeout=20) + data=data, return_cookies=True, timeout=20) if 'tc_ss' in cookie_dict: cookie = utils.dict_to_cookie_str(cookie_dict) return cookie @@ -3238,4 +3246,4 @@ async def get_picarto_stream_url(url: str, proxy_addr: OptionalStr = None, cooki title = json_data['channel']['title'] m3u8_url = f"https://1-edge1-us-newyork.picarto.tv/stream/hls/golive+{anchor_name}/index.m3u8" result |= {'is_live': True, 'title': title, 'm3u8_url': m3u8_url, 'record_url': m3u8_url} - return result + return result \ No newline at end of file