From 69a05b280d1a2df15cc5256a272beb4d2c1032c3 Mon Sep 17 00:00:00 2001 From: ihmily <961532186@qq.com> Date: Mon, 15 Jul 2024 22:59:29 +0800 Subject: [PATCH] fix: add bigo live record by short link --- main.py | 5 +++-- spider.py | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index 5339603..00d44a9 100644 --- a/main.py +++ b/main.py @@ -4,7 +4,7 @@ Author: Hmily GitHub: https://github.com/ihmily Date: 2023-07-17 23:52:05 -Update: 2024-07-05 12:36:12 +Update: 2024-07-15 22:55:29 Copyright (c) 2023-2024 by Hmily, All Rights Reserved. Function: Record live stream video. """ @@ -792,7 +792,7 @@ def start_record(url_data: tuple, count_variable: int = -1): port_info = get_xhs_stream_url(url=record_url, proxy_addr=proxy_address, cookies=xhs_cookie) retry += 1 - elif record_url.find("https://www.bigo.tv/") > -1: + elif record_url.find("https://www.bigo.tv/") > -1 or record_url.find("slink.bigovideo.tv/") > -1: platform = 'Bigo直播' with semaphore: port_info = get_bigo_stream_url(record_url, proxy_addr=proxy_address, cookies=bigo_cookie) @@ -1801,6 +1801,7 @@ while True: 'www.xiaohongshu.com', 'xhslink.com', 'www.bigo.tv', + 'link.bigovideo.tv', 'app.blued.cn', 'cc.163.com', 'qiandurebo.com', diff --git a/spider.py b/spider.py index 49908cf..d2b02ac 100644 --- a/spider.py +++ b/spider.py @@ -4,7 +4,7 @@ Author: Hmily GitHub: https://github.com/ihmily Date: 2023-07-15 23:15:00 -Update: 2024-07-05 12:33:00 +Update: 2024-07-15 22:55:00 Copyright (c) 2023 by Hmily, All Rights Reserved. Function: Get live stream data. """ @@ -664,7 +664,15 @@ def get_bigo_stream_url(url: str, proxy_addr: Union[str, None] = None, cookies: if cookies: headers['Cookie'] = cookies - room_id = re.search('www.bigo.tv/cn/(\w+)', url).group(1) + if 'bigo.tv' not in url: + html_str = get_req(url, proxy_addr=proxy_addr, headers=headers) + web_url = re.search( + '', + html_str).group(1) + room_id = re.search('&h=(\d+)(?=$|&)', web_url.replace('&', '&')).group(1) + else: + room_id = re.search('www.bigo.tv/cn/(\w+)', url).group(1) + data = {'siteId': room_id} # roomId url2 = 'https://ta.bigo.tv/official_website/studio/getInternalStudioInfo' json_str = get_req(url=url2, proxy_addr=proxy_addr, headers=headers, data=data) @@ -682,8 +690,8 @@ def get_bigo_stream_url(url: str, proxy_addr: Union[str, None] = None, cookies: result['is_live'] = True result['record_url'] = m3u8_url elif result['anchor_name'] == '': - html_str = get_req(url=url, proxy_addr=proxy_addr, headers=headers) - result['anchor_name'] = re.search('