diff --git a/config/config.ini b/config/config.ini index 6acc0e5..238b1b9 100644 --- a/config/config.ini +++ b/config/config.ini @@ -83,6 +83,8 @@ vvxqiu_cookie = langlive_cookie = pplive_cookie = 6room_cookie = +lehaitv_cookie = +huamao_cookie = [Authorization] popkontv_token = diff --git a/demo.py b/demo.py index a9703bf..22c1e27 100644 --- a/demo.py +++ b/demo.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from loguru import logger +from douyinliverecorder.logger import logger from douyinliverecorder import spider # 以下示例直播间链接不保证时效性,请自行查看链接是否能正常访问 @@ -168,6 +168,14 @@ LIVE_STREAM_CONFIG = { "6room": { "url": "https://v.6.cn/634435", "func": spider.get_6room_stream_url, + }, + "lehai": { + "url": "https://www.lehaitv.com/8059096", + "func": spider.get_haixiu_stream_url, + }, + "huamao": { + "url": "https://h.catshow168.com/live/preview.html?uid=19066357&anchorUid=18895331", + "func": spider.get_pplive_stream_url, } } @@ -185,5 +193,5 @@ def test_live_stream(platform_name: str, proxy_addr=None) -> None: if __name__ == "__main__": - platform = "douyin" - test_live_stream(platform) \ No newline at end of file + platform = "huamao" + test_live_stream(platform) diff --git a/douyinliverecorder/spider.py b/douyinliverecorder/spider.py index c437317..a1f2a7a 100644 --- a/douyinliverecorder/spider.py +++ b/douyinliverecorder/spider.py @@ -2583,7 +2583,11 @@ def get_haixiu_stream_url(url: str, proxy_addr: Union[str, None] = None, cookies headers['Cookie'] = cookies room_id = url.split("?")[0].rsplit('/', maxsplit=1)[-1] - access_token = "pLXSC%252FXJ0asc1I21tVL5FYZhNJn2Zg6d7m94umCnpgL%252BuVm31GQvyw%253D%253D" + if 'haixiutv' in url: + access_token = "pLXSC%252FXJ0asc1I21tVL5FYZhNJn2Zg6d7m94umCnpgL%252BuVm31GQvyw%253D%253D" + else: + access_token = "s7FUbTJ%252BjILrR7kicJUg8qr025ZVjd07DAnUQd8c7g%252Fo4OH9pdSX6w%253D%253D" + params = { "accessToken": access_token, "tku": "3000006", @@ -2596,7 +2600,13 @@ def get_haixiu_stream_url(url: str, proxy_addr: Union[str, None] = None, cookies params['_ajaxData1'] = ajax_data params['_'] = int(time.time()*1000) - api = f'https://service.haixiutv.com/v2/room/{room_id}/media/advanceInfoRoom?{urllib.parse.urlencode(params)}' + if 'haixiutv' in url: + api = f'https://service.haixiutv.com/v2/room/{room_id}/media/advanceInfoRoom?{urllib.parse.urlencode(params)}' + else: + headers['origin'] = 'https://www.lehaitv.com' + headers['referer'] = 'https://www.lehaitv.com' + api = f'https://service.lehaitv.com/v2/room/{room_id}/media/advanceInfoRoom?{urllib.parse.urlencode(params)}' + json_str = get_req(api, proxy_addr=proxy_addr, headers=headers, abroad=True) json_data = json.loads(json_str) @@ -2731,7 +2741,13 @@ def get_pplive_stream_url(url: str, proxy_addr: Union[str, None] = None, cookies 'inviteUuid': '', 'anchorUuid': room_id, } - api = 'https://api.pp.weimipopo.com/live/preview' + + if 'catshow' in url: + api = 'https://api.catshow168.com/live/preview' + headers['Origin'] = 'https://h.catshow168.com' + headers['Referer'] = 'https://h.catshow168.com' + else: + 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'] diff --git a/main.py b/main.py index a9dfd43..3f5236e 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() @@ -730,6 +730,18 @@ def start_record(url_data: tuple, count_variable: int = -1): port_info = spider.get_6room_stream_url( url=record_url, proxy_addr=proxy_address, cookies=six_room_cookie) + elif record_url.find("lehaitv.com/") > -1: + platform = '乐嗨直播' + with semaphore: + port_info = spider.get_haixiu_stream_url( + url=record_url, proxy_addr=proxy_address, cookies=lehaitv_cookie) + + elif record_url.find("h.catshow168.com/") > -1: + platform = '花猫直播' + with semaphore: + port_info = spider.get_pplive_stream_url( + url=record_url, proxy_addr=proxy_address, cookies=huamao_cookie) + else: logger.error(f'{record_url} {platform}直播地址') return @@ -1463,6 +1475,8 @@ while True: langlive_cookie = read_config_value(config, 'Cookie', 'langlive_cookie', '') pplive_cookie = read_config_value(config, 'Cookie', 'pplive_cookie', '') six_room_cookie = read_config_value(config, 'Cookie', '6room_cookie', '') + lehaitv_cookie = read_config_value(config, 'Cookie', 'lehaitv_cookie', '') + huamao_cookie = read_config_value(config, 'Cookie', 'huamao_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: @@ -1555,7 +1569,9 @@ while True: "17.live", "m.pp.weimipopo.com", "v.6.cn", - "m.6.cn" + "m.6.cn", + 'www.lehaitv.com', + 'h.catshow168.com' ] overseas_platform_host = [ 'www.tiktok.com', @@ -1586,7 +1602,8 @@ while True: "www.liveme.com", "www.haixiutv.com", "v.6.cn", - "m.6.cn" + "m.6.cn", + 'www.lehaitv.com' ) if url_host in platform_host: