diff --git a/config/config.ini b/config/config.ini index 4f968a2..70d6bd8 100644 --- a/config/config.ini +++ b/config/config.ini @@ -104,6 +104,7 @@ shopee_cookie = youtube_cookie = taobao_cookie = jd_cookie = +faceit_cookie = [Authorization] popkontv_token = diff --git a/douyinliverecorder/spider.py b/douyinliverecorder/spider.py index 098a451..2dfd025 100644 --- a/douyinliverecorder/spider.py +++ b/douyinliverecorder/spider.py @@ -4,7 +4,7 @@ Author: Hmily GitHub: https://github.com/ihmily Date: 2023-07-15 23:15:00 -Update: 2025-01-24 15:35:16 +Update: 2025-01-25 13:38:16 Copyright (c) 2023-2024 by Hmily, All Rights Reserved. Function: Get live stream data. """ @@ -3146,3 +3146,33 @@ async def get_jd_stream_url(url: str, proxy_addr: OptionalStr = None, cookies: O m3u8_url = json_data['data']['h5VideoUrl'] result |= {"is_live": True, "m3u8_url": m3u8_url, "flv_url": flv_url, "record_url": m3u8_url} return result + + +@trace_error_decorator +async def get_faceit_stream_data(url: str, proxy_addr: OptionalStr = None, cookies: OptionalStr = None) -> dict: + headers = { + 'Referer': 'https://www.faceit.com/zh/players/qpjzz/stream', + 'faceit-referer': 'web-next', + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0', + } + + if cookies: + headers['Cookie'] = cookies + nickname = re.findall(f'/players/(.*?)/stream', url)[0] + api = f'https://www.faceit.com/api/users/v1/nicknames/{nickname}' + json_str = await async_req(api, proxy_addr=proxy_addr, headers=headers) + json_data = json.loads(json_str) + user_id = json_data['payload']['id'] + api2 = f'https://www.faceit.com/api/stream/v1/streamings?userId={user_id}' + json_str2 = await async_req(api2, proxy_addr=proxy_addr, headers=headers) + json_data2 = json.loads(json_str2) + platform_info = json_data2['payload'][0] + anchor_name = platform_info.get('userNickname') + anchor_id = platform_info.get('platformId') + platform = platform_info.get('platform') + if platform == 'twitch': + result = await get_twitchtv_stream_data(f'https://www.twitch.tv/{anchor_id}') + result['anchor_name'] = anchor_name + else: + result = {'anchor_name': anchor_name, 'is_live': False} + return result diff --git a/main.py b/main.py index ce70b87..1ebf2cd 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: 2025-01-23 20:36:00 +Update: 2025-01-25 13:39:00 Copyright (c) 2023-2024 by Hmily, All Rights Reserved. Function: Record live stream video. """ @@ -39,7 +39,8 @@ from msg_push import ( version = "v4.0.2" platforms = ("\n国内站点:抖音|快手|虎牙|斗鱼|YY|B站|小红书|bigo|blued|网易CC|千度热播|猫耳FM|Look|TwitCasting|百度|微博|" "酷狗|花椒|流星|Acfun|畅聊|映客|音播|知乎|嗨秀|VV星球|17Live|浪Live|漂漂|六间房|乐嗨|花猫|淘宝|京东" - "\n海外站点:TikTok|SOOP|PandaTV|WinkTV|FlexTV|PopkonTV|TwitchTV|LiveMe|ShowRoom|CHZZK|Shopee|Youtube") + "\n海外站点:TikTok|SOOP|PandaTV|WinkTV|FlexTV|PopkonTV|TwitchTV|LiveMe|ShowRoom|CHZZK|Shopee|" + "Youtube|faceit") recording = set() error_count = 0 @@ -880,6 +881,17 @@ def start_record(url_data: tuple, count_variable: int = -1) -> None: port_info = asyncio.run(spider.get_jd_stream_url( url=record_url, proxy_addr=proxy_address, cookies=jd_cookie)) + elif record_url.find("faceit.com/") > -1: + platform = 'faceit' + with semaphore: + if global_proxy or proxy_address: + with semaphore: + json_data = asyncio.run(spider.get_faceit_stream_data( + url=record_url, proxy_addr=proxy_address, cookies=faceit_cookie)) + port_info = stream.get_stream_url(json_data, record_quality, spec=True) + else: + logger.error("错误信息: 网络异常,请检查本网络是否能正常访问faceit直播平台") + elif record_url.find(".m3u8") > -1 or record_url.find(".flv") > -1: platform = '自定义录制直播' port_info = { @@ -1622,7 +1634,8 @@ while True: custom_script = read_config_value(config, '录制设置', '自定义脚本执行命令', "") if is_run_script else None enable_proxy_platform = read_config_value( config, '录制设置', '使用代理录制的平台(逗号分隔)', - 'tiktok, soop, pandalive, winktv, flextv, popkontv, twitch, liveme, showroom, chzzk, shopee, shp, youtu') + 'tiktok, soop, pandalive, winktv, flextv, popkontv, twitch, liveme, showroom, chzzk, shopee, shp, youtu, faceit' + ) enable_proxy_platform_list = enable_proxy_platform.replace(',', ',').split(',') if enable_proxy_platform else None extra_enable_proxy = read_config_value(config, '录制设置', '额外使用代理录制的平台(逗号分隔)', '') extra_enable_proxy_platform_list = extra_enable_proxy.replace(',', ',').split(',') if extra_enable_proxy else None @@ -1708,6 +1721,7 @@ while True: youtube_cookie = read_config_value(config, 'Cookie', 'youtube_cookie', '') taobao_cookie = read_config_value(config, 'Cookie', 'taobao_cookie', '') jd_cookie = read_config_value(config, 'Cookie', 'jd_cookie', '') + faceit_cookie = read_config_value(config, 'Cookie', 'faceit_cookie', '') video_save_type_list = ("FLV", "MKV", "TS", "MP4", "MP3音频", "M4A音频") if video_save_type and video_save_type.upper() in video_save_type_list: @@ -1844,6 +1858,7 @@ while True: '.shp.ee', 'www.youtube.com', 'youtu.be', + 'www.faceit.com' ] platform_host.extend(overseas_platform_host)