mirror of
https://github.com/ihmily/DouyinLiveRecorder.git
synced 2025-12-26 05:48:32 +08:00
fix: update shopee live record
This commit is contained in:
parent
9d292cf865
commit
6657374db3
@ -2942,26 +2942,32 @@ def get_shopee_stream_url(url: str, proxy_addr: OptionalStr = None, cookies: Opt
|
|||||||
|
|
||||||
result = {"anchor_name": "", "is_live": False}
|
result = {"anchor_name": "", "is_live": False}
|
||||||
|
|
||||||
if 'live.shopee' not in url:
|
if 'live.shopee' not in url and 'uid' not in url:
|
||||||
url = get_req(url, proxy_addr=proxy_addr, headers=headers, redirect_url=True, abroad=True)
|
url = get_req(url, proxy_addr=proxy_addr, headers=headers, redirect_url=True, abroad=True)
|
||||||
|
|
||||||
|
if 'live.shopee' in url:
|
||||||
|
host_suffix = url.split('/')[2].rsplit('.', maxsplit=1)[1]
|
||||||
|
else:
|
||||||
|
host_suffix = url.split('/')[2].split('.', maxsplit=1)[0]
|
||||||
|
|
||||||
uid = get_params(url, 'uid')
|
uid = get_params(url, 'uid')
|
||||||
host_suffix = url.split('/')[2].rsplit('.', maxsplit=1)[1]
|
|
||||||
api_host = f'https://live.shopee.{host_suffix}'
|
api_host = f'https://live.shopee.{host_suffix}'
|
||||||
|
session_id = get_params(url, 'session')
|
||||||
|
is_live = False
|
||||||
if uid:
|
if uid:
|
||||||
json_str = get_req(f'{api_host}/api/v1/shop_page/live/ongoing?uid={uid}',
|
json_str = get_req(f'{api_host}/api/v1/shop_page/live/ongoing?uid={uid}',
|
||||||
proxy_addr=proxy_addr, headers=headers, abroad=True)
|
proxy_addr=proxy_addr, headers=headers, abroad=True)
|
||||||
json_data = json.loads(json_str)
|
json_data = json.loads(json_str)
|
||||||
if not json_data['data']['ongoing_live']:
|
if json_data['data']['ongoing_live']:
|
||||||
|
session_id = json_data['data']['ongoing_live']['session_id']
|
||||||
|
is_live = True
|
||||||
|
else:
|
||||||
json_str = get_req(f'{api_host}/api/v1/shop_page/live/replay_list?offset=0&limit=1&uid={uid}',
|
json_str = get_req(f'{api_host}/api/v1/shop_page/live/replay_list?offset=0&limit=1&uid={uid}',
|
||||||
proxy_addr=proxy_addr, headers=headers, abroad=True)
|
proxy_addr=proxy_addr, headers=headers, abroad=True)
|
||||||
json_data = json.loads(json_str)
|
json_data = json.loads(json_str)
|
||||||
result['anchor_name'] = json_data['data']['replay'][0]['nick_name']
|
if json_data['data']['replay']:
|
||||||
return result
|
result['anchor_name'] = json_data['data']['replay'][0]['nick_name']
|
||||||
else:
|
return result
|
||||||
session_id = json_data['data']['ongoing_live']['session_id']
|
|
||||||
else:
|
|
||||||
session_id = get_params(url, 'session')
|
|
||||||
|
|
||||||
json_str = get_req(f'{api_host}/api/v1/session/{session_id}', proxy_addr=proxy_addr, headers=headers, abroad=True)
|
json_str = get_req(f'{api_host}/api/v1/session/{session_id}', proxy_addr=proxy_addr, headers=headers, abroad=True)
|
||||||
json_data = json.loads(json_str)
|
json_data = json.loads(json_str)
|
||||||
@ -2973,7 +2979,7 @@ def get_shopee_stream_url(url: str, proxy_addr: OptionalStr = None, cookies: Opt
|
|||||||
live_status = json_data['data']['session']['status']
|
live_status = json_data['data']['session']['status']
|
||||||
result["anchor_name"] = anchor_name
|
result["anchor_name"] = anchor_name
|
||||||
result['uid'] = f'uid={uid}&session={session_id}'
|
result['uid'] = f'uid={uid}&session={session_id}'
|
||||||
if live_status == 1:
|
if live_status == 1 and is_live:
|
||||||
result["is_live"] = True
|
result["is_live"] = True
|
||||||
flv_url = json_data['data']['session']['play_url']
|
flv_url = json_data['data']['session']['play_url']
|
||||||
result['title'] = json_data['data']['session']['title']
|
result['title'] = json_data['data']['session']['title']
|
||||||
|
|||||||
6
main.py
6
main.py
@ -929,7 +929,8 @@ def start_record(url_data: tuple, count_variable: int = -1) -> None:
|
|||||||
if enable_https_recording and real_url.startswith("http://"):
|
if enable_https_recording and real_url.startswith("http://"):
|
||||||
real_url = real_url.replace("http://", "https://")
|
real_url = real_url.replace("http://", "https://")
|
||||||
|
|
||||||
if platform == 'shopee':
|
http_record_list = ['shopee']
|
||||||
|
if platform in http_record_list:
|
||||||
real_url = real_url.replace("https://", "http://")
|
real_url = real_url.replace("https://", "http://")
|
||||||
|
|
||||||
user_agent = ("Mozilla/5.0 (Linux; Android 11; SAMSUNG SM-G973U) AppleWebKit/537.36 ("
|
user_agent = ("Mozilla/5.0 (Linux; Android 11; SAMSUNG SM-G973U) AppleWebKit/537.36 ("
|
||||||
@ -962,13 +963,14 @@ def start_record(url_data: tuple, count_variable: int = -1) -> None:
|
|||||||
"-analyzeduration", analyzeduration,
|
"-analyzeduration", analyzeduration,
|
||||||
"-probesize", probesize,
|
"-probesize", probesize,
|
||||||
"-fflags", "+discardcorrupt",
|
"-fflags", "+discardcorrupt",
|
||||||
"-i", real_url,
|
"-re", "-i", real_url,
|
||||||
"-bufsize", bufsize,
|
"-bufsize", bufsize,
|
||||||
"-sn", "-dn",
|
"-sn", "-dn",
|
||||||
"-reconnect_delay_max", "60",
|
"-reconnect_delay_max", "60",
|
||||||
"-reconnect_streamed", "-reconnect_at_eof",
|
"-reconnect_streamed", "-reconnect_at_eof",
|
||||||
"-max_muxing_queue_size", max_muxing_queue_size,
|
"-max_muxing_queue_size", max_muxing_queue_size,
|
||||||
"-correct_ts_overflow", "1",
|
"-correct_ts_overflow", "1",
|
||||||
|
"-avoid_negative_ts", "1"
|
||||||
]
|
]
|
||||||
|
|
||||||
record_headers = {
|
record_headers = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user