diff --git a/config/config.ini b/config/config.ini index f8775a0..42fd3a4 100644 --- a/config/config.ini +++ b/config/config.ini @@ -81,6 +81,7 @@ haixiu_cookie = vvxqiu_cookie = 17live_cookie = langlive_cookie = +pplive_cookie = [Authorization] popkontv_token = diff --git a/demo.py b/demo.py index 4f670a7..abf596c 100644 --- a/demo.py +++ b/demo.py @@ -160,15 +160,19 @@ LIVE_STREAM_CONFIG = { "langlive": { "url": "https://www.lang.live/en-US/room/3349463", "func": spider.get_langlive_stream_url, + }, + "pplive": { + "url": "https://m.pp.weimipopo.com/live/preview.html?uid=91648673&anchorUid=91625862&app=plpl", + "func": spider.get_pplive_stream_url, } } -def test_live_stream(platform_name: str) -> None: +def test_live_stream(platform_name: str, proxy_addr=None) -> None: if platform_name in LIVE_STREAM_CONFIG: config = LIVE_STREAM_CONFIG[platform_name] try: - stream_data = config['func'](config['url'], proxy_addr='') + stream_data = config['func'](config['url'], proxy_addr=proxy_addr) logger.debug(f"Stream data for {platform_name}: {stream_data}") except Exception as e: logger.error(f"Error fetching stream data for {platform_name}: {e}") @@ -178,4 +182,4 @@ def test_live_stream(platform_name: str) -> None: if __name__ == "__main__": platform = "douyin" - test_live_stream(platform) \ No newline at end of file + test_live_stream(platform) diff --git a/douyinliverecorder/spider.py b/douyinliverecorder/spider.py index 871e504..87cfdfa 100644 --- a/douyinliverecorder/spider.py +++ b/douyinliverecorder/spider.py @@ -2708,6 +2708,41 @@ def get_langlive_stream_url(url: str, proxy_addr: Union[str, None] = None, cooki flv_url = json_data['data']['live_info']['liveurl'] m3u8_url = json_data['data']['live_info']['liveurl_hls'] result['flv_url'] = flv_url - result['flv_url'] = m3u8_url + result['m3u8_url'] = m3u8_url result['record_url'] = m3u8_url return result + + +@trace_error_decorator +def get_pplive_stream_url(url: str, proxy_addr: Union[str, None] = None, cookies: Union[str, None] = None) -> \ + Dict[str, Any]: + headers = { + 'Content-Type': 'application/json', + 'Origin': 'https://m.pp.weimipopo.com', + 'Referer': 'https://m.pp.weimipopo.com/', + 'User-Agent': 'ios/7.830 (ios 17.0; ; iPhone 15 (A2846/A3089/A3090/A3092))', + } + + if cookies: + headers['Cookie'] = cookies + + room_id = get_params(url, 'anchorUid') + json_data = { + 'inviteUuid': '', + 'anchorUuid': room_id, + } + api = 'https://api.pp.weimipopo.com/live/preview' + json_str = get_req(api, json_data=json_data, proxy_addr=proxy_addr, headers=headers) + json_data = json.loads(json_str) + live_info = json_data['data'] + anchor_name = live_info['name'] + live_status = live_info['living'] + result = { + "anchor_name": anchor_name, + "is_live": False, + } + if live_status: + result["is_live"] = True + result['m3u8_url'] = live_info['pullUrl'] + result['record_url'] = live_info['pullUrl'] + return result \ No newline at end of file diff --git a/main.py b/main.py index 446728f..d2dea5c 100644 --- a/main.py +++ b/main.py @@ -37,7 +37,7 @@ from msg_push import ( version = "v3.0.9" platforms = ("\n国内站点:抖音|快手|虎牙|斗鱼|YY|B站|小红书|bigo|blued|网易CC|千度热播|猫耳FM|Look|TwitCasting|百度|微博|" - "酷狗|花椒|流星|Acfun|时光|映客|音播|知乎|嗨秀|VV星球|17Live" + "酷狗|花椒|流星|Acfun|时光|映客|音播|知乎|嗨秀|VV星球|17Live|漂漂" "\n海外站点:TikTok|SOOP[AfreecaTV]|PandaTV|WinkTV|FlexTV|PopkonTV|TwitchTV|LiveMe|ShowRoom|CHZZK|浪Live") recording = set() @@ -717,6 +717,13 @@ def start_record(url_data: tuple, count_variable: int = -1): with semaphore: port_info = spider.get_langlive_stream_url( url=record_url, proxy_addr=proxy_address, cookies=langlive_cookie) + + elif record_url.find("m.pp.weimipopo.com/") > -1: + platform = '漂漂直播' + with semaphore: + port_info = spider.get_pplive_stream_url( + url=record_url, proxy_addr=proxy_address, cookies=pplive_cookie) + else: logger.error(f'{record_url} {platform}直播地址') return @@ -1264,7 +1271,7 @@ def check_ffmpeg_existence(): # print(f"已将ffmpeg路径添加到环境变量:{ffmpeg_path}") return True else: - logger.error("检测到ffmpeg不存在,请将ffmpeg.exe放到同目录,或者设置为环境变量,没有ffmpeg将无法录制") + logger.error("未检测到ffmpeg。请确保ffmpeg位于系统路径中,或将其路径添加到环境变量。缺少ffmpeg将导致无法进行录制。") sys.exit(0) finally: dev_null.close() @@ -1448,6 +1455,7 @@ while True: vvxqiu_cookie = read_config_value(config, 'Cookie', 'vvxqiu_cookie', '') yiqilive_cookie = read_config_value(config, 'Cookie', '17live_cookie', '') langlive_cookie = read_config_value(config, 'Cookie', 'langlive_cookie', '') + pplive_cookie = read_config_value(config, 'Cookie', 'pplive_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: @@ -1539,7 +1547,8 @@ while True: 'www.zhihu.com', 'www.haixiutv.com', "h5webcdn-pro.vvxqiu.com", - "17.live" + "17.live", + "m.pp.weimipopo.com" ] overseas_platform_host = [ 'www.tiktok.com', @@ -1629,4 +1638,4 @@ while True: t2.start() first_run = False - time.sleep(3) + time.sleep(3) \ No newline at end of file