feat: add lianjie and laixiu live

This commit is contained in:
ihmily 2025-07-19 17:45:19 +08:00
parent ae8200e01c
commit 9f499f3fa6
3 changed files with 122 additions and 6 deletions

View File

@ -191,9 +191,17 @@ LIVE_STREAM_CONFIG = {
"url": "https://www.faceit.com/zh/players/Compl1/stream",
"func": spider.get_faceit_stream_data,
},
"lianjie": {
"url": "https://show.lailianjie.com/10000258",
"func": spider.get_lianjie_stream_url,
},
"migu": {
"url": "https://www.miguvideo.com/p/live/120000541321",
"func": spider.get_migu_stream_url,
},
"laixiu": {
"url": "https://www.imkktv.com/h5/share/video.html?uid=1845195&roomId=1710496",
"func": spider.get_laixiu_stream_url,
}
}
@ -213,4 +221,3 @@ def test_live_stream(platform_name: str, proxy_addr=None, cookies=None) -> None:
if __name__ == "__main__":
platform = "douyin"
test_live_stream(platform)

24
main.py
View File

@ -4,7 +4,7 @@
Author: Hmily
GitHub: https://github.com/ihmily
Date: 2023-07-17 23:52:05
Update: 2025-07-04 17:23:00
Update: 2025-07-19 17:43:00
Copyright (c) 2023-2025 by Hmily, All Rights Reserved.
Function: Record live stream video.
"""
@ -38,9 +38,9 @@ from ffmpeg_install import (
check_ffmpeg, ffmpeg_path, current_env_path
)
version = "v4.0.5"
version = "v4.0.6"
platforms = ("\n国内站点:抖音|快手|虎牙|斗鱼|YY|B站|小红书|bigo|blued|网易CC|千度热播|猫耳FM|Look|TwitCasting|百度|微博|"
"酷狗|花椒|流星|Acfun|畅聊|映客|音播|知乎|嗨秀|VV星球|17Live|浪Live|漂漂|六间房|乐嗨|花猫|淘宝|京东|咪咕"
"酷狗|花椒|流星|Acfun|畅聊|映客|音播|知乎|嗨秀|VV星球|17Live|浪Live|漂漂|六间房|乐嗨|花猫|淘宝|京东|咪咕|连接|来秀"
"\n海外站点TikTok|SOOP|PandaTV|WinkTV|FlexTV|PopkonTV|TwitchTV|LiveMe|ShowRoom|CHZZK|Shopee|"
"Youtube|Faceit")
@ -931,6 +931,18 @@ def start_record(url_data: tuple, count_variable: int = -1) -> None:
port_info = asyncio.run(spider.get_migu_stream_url(
url=record_url, proxy_addr=proxy_address, cookies=migu_cookie))
elif record_url.find("show.lailianjie.com") > -1:
platform = '连接直播'
with semaphore:
port_info = asyncio.run(spider.get_lianjie_stream_url(
url=record_url, proxy_addr=proxy_address, cookies=lianjie_cookie))
elif record_url.find("www.imkktv.com") > -1:
platform = '来秀直播'
with semaphore:
port_info = asyncio.run(spider.get_laixiu_stream_url(
url=record_url, proxy_addr=proxy_address, cookies=laixiu_cookie))
elif record_url.find(".m3u8") > -1 or record_url.find(".flv") > -1:
platform = '自定义录制直播'
port_info = {
@ -1772,6 +1784,8 @@ while True:
jd_cookie = read_config_value(config, 'Cookie', 'jd_cookie', '')
faceit_cookie = read_config_value(config, 'Cookie', 'faceit_cookie', '')
migu_cookie = read_config_value(config, 'Cookie', 'migu_cookie', '')
lianjie_cookie = read_config_value(config, 'Cookie', 'lianjie_cookie', '')
laixiu_cookie = read_config_value(config, 'Cookie', 'laixiu_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:
@ -1891,7 +1905,9 @@ while True:
'3.cn',
'eco.m.jd.com',
'www.miguvideo.com',
'm.miguvideo.com'
'm.miguvideo.com',
'show.lailianjie.com',
'www.imkktv.com'
]
overseas_platform_host = [
'www.tiktok.com',

View File

@ -4,7 +4,7 @@
Author: Hmily
GitHub: https://github.com/ihmily
Date: 2023-07-15 23:15:00
Update: 2025-07-04 17:23:00
Update: 2025-07-19 17:43:00
Copyright (c) 2023-2025 by Hmily, All Rights Reserved.
Function: Get live stream data.
"""
@ -3092,3 +3092,96 @@ async def get_migu_stream_url(url: str, proxy_addr: OptionalStr = None, cookies:
result['record_url'] = real_source_url
result['is_live'] = True
return result
@trace_error_decorator
async def get_lianjie_stream_url(url: str, proxy_addr: OptionalStr = None, cookies: OptionalStr = None) -> dict:
headers = {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/121.0.0.0 Safari/537.36 Edg/121.0.0.0',
'accept-language': 'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
}
if cookies:
headers['cookie'] = cookies
room_id = url.split('?')[0].rsplit('lailianjie.com/', maxsplit=1)[-1]
play_api = f'https://api.lailianjie.com/ApiServices/service/live/getRoomInfo?&_$t=&_sign=&roomNumber={room_id}'
json_str = await async_req(play_api, proxy_addr=proxy_addr, headers=headers)
json_data = json.loads(json_str)
room_data = json_data['data']
anchor_name = room_data['nickname']
live_status = room_data['isonline']
result = {"anchor_name": anchor_name, "is_live": False}
if live_status == 1:
title = room_data['defaultRoomTitle']
webrtc_url = room_data['videoUrl']
https_url = "https://" + webrtc_url.split('webrtc://')[1]
flv_url = https_url.replace('?', '.flv?')
m3u8_url = https_url.replace('?', '.m3u8?')
result |= {'is_live': True, 'title': title, 'm3u8_url': m3u8_url, 'flv_url': flv_url, 'record_url': flv_url}
return result
@trace_error_decorator
async def get_laixiu_stream_url(url: str, proxy_addr: OptionalStr = None, cookies: OptionalStr = None) -> dict:
def generate_uuid(ua_type: str):
if ua_type == "mobile":
return str(uuid.uuid4())
return str(uuid.uuid4()).replace('-', '')
def calculate_sign(ua_type: str = 'pc'):
a = int(time.time() * 1000)
s = generate_uuid(ua_type)
u = 'kk792f28d6ff1f34ec702c08626d454b39pro'
input_str = f"web{s}{a}{u}"
md5_hash = hashlib.md5(input_str.encode('utf-8')).hexdigest()
return {
'timestamp': a,
'imei': s,
'requestId': md5_hash,
'inputString': input_str
}
sign_data = calculate_sign(ua_type='pc')
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/138.0.0.0 Safari/537.36 Edg/138.0.0.0',
'mobileModel': 'web',
'timestamp': str(sign_data['timestamp']),
'loginType': '2',
'versionCode': '10003',
'imei': sign_data['imei'],
'requestId': sign_data['requestId'],
'channel': '9',
'version': '1.0.0',
'os': 'web',
'platform': 'WEB',
'Origin': 'https://www.imkktv.com',
'Referer': 'https://www.imkktv.com/',
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
}
if cookies:
headers['cookie'] = cookies
pattern = r"(?:roomId|anchorId)=(.*?)(?=&|$)"
match = re.search(pattern, url)
room_id = match.group(1) if match else ''
play_api = f'https://api.imkktv.com/liveroom/getShareLiveVideo?roomId={room_id}'
json_str = await async_req(play_api, proxy_addr=proxy_addr, headers=headers)
json_data = json.loads(json_str)
room_data = json_data['data']
anchor_name = room_data['nickname']
live_status = room_data['playStatus'] == 0
result = {"anchor_name": anchor_name, "is_live": False}
if live_status:
flv_url = room_data['playUrl']
result |= {'is_live': True, 'flv_url': flv_url, 'record_url': flv_url}
return result