mirror of
https://github.com/ihmily/DouyinLiveRecorder.git
synced 2025-12-25 21:36:46 +08:00
feat: add shopee live record
This commit is contained in:
parent
2e6e699fdb
commit
b3f110e3ec
@ -98,6 +98,7 @@ pplive_cookie =
|
||||
6room_cookie =
|
||||
lehaitv_cookie =
|
||||
huamao_cookie =
|
||||
shopee_cookie =
|
||||
|
||||
[Authorization]
|
||||
popkontv_token =
|
||||
|
||||
4
demo.py
4
demo.py
@ -169,6 +169,10 @@ LIVE_STREAM_CONFIG = {
|
||||
"huamao": {
|
||||
"url": "https://h.catshow168.com/live/preview.html?uid=19066357&anchorUid=18895331",
|
||||
"func": spider.get_pplive_stream_url,
|
||||
},
|
||||
"shopee": {
|
||||
"url": "https://sg.shp.ee/GmpXeuf?uid=1006401066&session=802458",
|
||||
"func": spider.get_shopee_stream_url,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
Author: Hmily
|
||||
GitHub: https://github.com/ihmily
|
||||
Date: 2023-07-15 23:15:00
|
||||
Update: 2024-10-28 00:32:16
|
||||
Update: 2024-11-09 03:20:16
|
||||
Copyright (c) 2023-2024 by Hmily, All Rights Reserved.
|
||||
Function: Get live stream data.
|
||||
"""
|
||||
@ -2925,4 +2925,56 @@ def get_6room_stream_url(url: str, proxy_addr: OptionalStr = None, cookies: Opti
|
||||
flv_url = f'https://wlive.6rooms.com/httpflv/{flv_title}.flv'
|
||||
result['flv_url'] = flv_url
|
||||
result['record_url'] = get_req(flv_url, proxy_addr=proxy_addr, headers=headers, redirect_url=True)
|
||||
return result
|
||||
return result
|
||||
|
||||
|
||||
@trace_error_decorator
|
||||
def get_shopee_stream_url(url: str, proxy_addr: OptionalStr = None, cookies: OptionalStr = None) -> dict:
|
||||
headers = {
|
||||
'accept': 'application/json, text/plain, */*',
|
||||
'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
|
||||
'referer': 'https://live.shopee.sg/share?from=live&session=802458&share_user_id=',
|
||||
'user-agent': 'ios/7.830 (ios 17.0; ; iPhone 15 (A2846/A3089/A3090/A3092))',
|
||||
}
|
||||
|
||||
if cookies:
|
||||
headers['Cookie'] = cookies
|
||||
|
||||
result = {"anchor_name": "", "is_live": False}
|
||||
if 'live.shopee' not in url:
|
||||
url = get_req(url, proxy_addr=proxy_addr, headers=headers, redirect_url=True)
|
||||
uid = get_params(url, 'uid')
|
||||
if uid:
|
||||
json_str = get_req(f'https://live.shopee.sg/api/v1/shop_page/live/ongoing?uid={uid}',
|
||||
proxy_addr=proxy_addr, headers=headers)
|
||||
json_data = json.loads(json_str)
|
||||
if not json_data['data']['ongoing_live']:
|
||||
json_str = get_req(
|
||||
f'https://live.shopee.sg/api/v1/shop_page/live/replay_list?offset=0&limit=1&uid={uid}',
|
||||
proxy_addr=proxy_addr, headers=headers)
|
||||
json_data = json.loads(json_str)
|
||||
result['anchor_name'] = json_data['data']['replay'][0]['nick_name']
|
||||
return result
|
||||
else:
|
||||
session_id = json_data['data']['ongoing_live']['session_id']
|
||||
else:
|
||||
session_id = get_params(url, 'session')
|
||||
|
||||
json_str = get_req(f'https://live.shopee.sg/api/v1/session/{session_id}',
|
||||
proxy_addr=proxy_addr, headers=headers)
|
||||
json_data = json.loads(json_str)
|
||||
if not json_data.get('data'):
|
||||
print("Fetch shopee live data failed, please update the address of the live broadcast room and try again.")
|
||||
return result
|
||||
uid = json_data['data']['session']['uid']
|
||||
anchor_name = json_data['data']['session']['nickname']
|
||||
live_status = json_data['data']['session']['status']
|
||||
result["anchor_name"] = anchor_name
|
||||
result['uid'] = f'uid={uid}&session={session_id}'
|
||||
if live_status == 1:
|
||||
result["is_live"] = True
|
||||
flv_url = json_data['data']['session']['play_url']
|
||||
result['title'] = json_data['data']['session']['title']
|
||||
result['flv_url'] = flv_url
|
||||
result['record_url'] = flv_url
|
||||
return result
|
||||
|
||||
Binary file not shown.
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: 4.0.1\n"
|
||||
"POT-Creation-Date: 2024-10-20 00:00+0800\n"
|
||||
"PO-Revision-Date: 2024-11-08 19:10+0800\n"
|
||||
"PO-Revision-Date: 2024-11-09 03:05+0800\n"
|
||||
"Last-Translator: Hmily <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: Chinese\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
@ -79,3 +79,7 @@ msgstr "获取TwitCasting数据失败,正在尝试登录..."
|
||||
|
||||
msgid "Failed to retrieve live room data, the Huajiao live room address is not fixed, please manually change the address for recording."
|
||||
msgstr "获取直播间数据失败,花椒直播间地址是非固定的,请手动更换地址进行录制"
|
||||
|
||||
msgid "Fetch shopee live data failed, please update the address of the live broadcast room and try again."
|
||||
msgstr "获取shopee直播间数据失败,请手动更换直播录制地址后重试"
|
||||
|
||||
|
||||
24
main.py
24
main.py
@ -4,7 +4,7 @@
|
||||
Author: Hmily
|
||||
GitHub: https://github.com/ihmily
|
||||
Date: 2023-07-17 23:52:05
|
||||
Update: 2024-11-07 01:00:00
|
||||
Update: 2024-11-09 03:05:00
|
||||
Copyright (c) 2023-2024 by Hmily, All Rights Reserved.
|
||||
Function: Record live stream video.
|
||||
"""
|
||||
@ -37,7 +37,7 @@ from msg_push import (
|
||||
|
||||
version = "v4.0.1"
|
||||
platforms = ("\n国内站点:抖音|快手|虎牙|斗鱼|YY|B站|小红书|bigo|blued|网易CC|千度热播|猫耳FM|Look|TwitCasting|百度|微博|"
|
||||
"酷狗|花椒|流星|Acfun|畅聊|映客|音播|知乎|嗨秀|VV星球|17Live|浪Live|漂漂|六间房|乐嗨|花猫"
|
||||
"酷狗|花椒|流星|Acfun|畅聊|映客|音播|知乎|嗨秀|VV星球|17Live|浪Live|漂漂|六间房|乐嗨|花猫|shopee"
|
||||
"\n海外站点:TikTok|SOOP|PandaTV|WinkTV|FlexTV|PopkonTV|TwitchTV|LiveMe|ShowRoom|CHZZK")
|
||||
|
||||
recording = set()
|
||||
@ -374,7 +374,6 @@ def start_record(url_data: tuple, count_variable: int = -1) -> None:
|
||||
try:
|
||||
record_finished = False
|
||||
run_once = False
|
||||
is_long_url = False
|
||||
start_pushed = False
|
||||
new_record_url = ''
|
||||
count_time = time.time()
|
||||
@ -773,6 +772,14 @@ def start_record(url_data: tuple, count_variable: int = -1) -> None:
|
||||
port_info = spider.get_pplive_stream_url(
|
||||
url=record_url, proxy_addr=proxy_address, cookies=huamao_cookie)
|
||||
|
||||
elif record_url.find("live.shopee") > -1 or record_url.find("shp.ee/") > -1:
|
||||
platform = 'shopee'
|
||||
with semaphore:
|
||||
port_info = spider.get_shopee_stream_url(
|
||||
url=record_url, proxy_addr=proxy_address, cookies=shopee_cookie)
|
||||
if port_info.get('uid'):
|
||||
new_record_url = record_url.split('?')[0] + '?' + str(port_info['uid'])
|
||||
|
||||
elif record_url.find(".m3u8") > -1 or record_url.find(".flv") > -1:
|
||||
platform = '自定义录制直播'
|
||||
port_info = {
|
||||
@ -814,9 +821,10 @@ def start_record(url_data: tuple, count_variable: int = -1) -> None:
|
||||
return
|
||||
|
||||
if not url_data[-1] and run_once is False:
|
||||
if is_long_url:
|
||||
if new_record_url:
|
||||
need_update_line_list.append(
|
||||
f'{record_url}|{new_record_url},主播: {anchor_name.strip()}')
|
||||
not_record_list.append(new_record_url)
|
||||
else:
|
||||
need_update_line_list.append(f'{record_url}|{record_url},主播: {anchor_name.strip()}')
|
||||
run_once = True
|
||||
@ -1396,8 +1404,8 @@ def read_config_value(config_parser: configparser.RawConfigParser, section: str,
|
||||
|
||||
options = {"是": True, "否": False}
|
||||
config = configparser.RawConfigParser()
|
||||
skip_proxy_check = options.get(read_config_value(config, '录制设置', '是否跳过代理检测(是/否)', "否"), False)
|
||||
language = read_config_value(config, '录制设置', 'language(zh_cn/en)', "zh_cn")
|
||||
skip_proxy_check = options.get(read_config_value(config, '录制设置', '是否跳过代理检测(是/否)', "否"), False)
|
||||
if language and 'en' not in language.lower():
|
||||
from i18n import translated_print
|
||||
builtins.print = translated_print
|
||||
@ -1545,6 +1553,7 @@ while True:
|
||||
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', '')
|
||||
shopee_cookie = read_config_value(config, 'Cookie', 'shopee_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:
|
||||
@ -1653,7 +1662,9 @@ while True:
|
||||
"v.6.cn",
|
||||
"m.6.cn",
|
||||
'www.lehaitv.com',
|
||||
'h.catshow168.com'
|
||||
'h.catshow168.com',
|
||||
'live.shopee.*',
|
||||
'*.shp.ee',
|
||||
]
|
||||
overseas_platform_host = [
|
||||
'www.tiktok.com',
|
||||
@ -1685,6 +1696,7 @@ while True:
|
||||
'www.lehaitv.com'
|
||||
)
|
||||
|
||||
url_host = '*.shp.ee' if '*.shp.ee' in url_host else 'live.shopee.*'
|
||||
if url_host in platform_host or any(ext in url for ext in (".flv", ".m3u8")):
|
||||
if url_host in clean_url_host_list:
|
||||
url = update_file(url_config_file, old_str=url, new_str=url.split('?')[0])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user