mirror of
https://github.com/ihmily/DouyinLiveRecorder.git
synced 2025-12-26 05:48:32 +08:00
feat: Add qiandurebo live and pandatv record
This commit is contained in:
parent
77eeaf3b40
commit
f91e3cd907
@ -16,12 +16,12 @@ TS录制完成后自动增加生成m4a格式 = 否
|
||||
追加格式后删除原文件 = 否
|
||||
|
||||
[推送配置]
|
||||
直播状态通知(可选微信|钉钉|TG或者都填) =
|
||||
直播状态通知(可选微信|钉钉|TG或者都填) =
|
||||
钉钉推送接口链接 =
|
||||
微信推送接口链接 =
|
||||
钉钉通知@对象(填手机号) =
|
||||
TGAPI令牌 =
|
||||
TG聊天ID(个人或者群组ID) =
|
||||
TG聊天ID(个人或者群组ID) =
|
||||
|
||||
[Cookie]
|
||||
抖音cookie(录制抖音必须要有) = ttwid=1%7CB1qls3GdnZhUov9o2NxOMxxYS2ff6OSvEWbv0ytbES4%7C1680522049%7C280d802d6d478e3e78d0c807f7c487e7ffec0ae4e5fdd6a0fe74c3c6af149511; my_rd=1; passport_csrf_token=3ab34460fa656183fccfb904b16ff742; passport_csrf_token_default=3ab34460fa656183fccfb904b16ff742; d_ticket=9f562383ac0547d0b561904513229d76c9c21; n_mh=hvnJEQ4Q5eiH74-84kTFUyv4VK8xtSrpRZG1AhCeFNI; store-region=cn-fj; store-region-src=uid; LOGIN_STATUS=1; __security_server_data_status=1; FORCE_LOGIN=%7B%22videoConsumedRemainSeconds%22%3A180%7D; pwa2=%223%7C0%7C3%7C0%22; download_guide=%223%2F20230729%2F0%22; volume_info=%7B%22isUserMute%22%3Afalse%2C%22isMute%22%3Afalse%2C%22volume%22%3A0.6%7D; strategyABtestKey=%221690824679.923%22; stream_recommend_feed_params=%22%7B%5C%22cookie_enabled%5C%22%3Atrue%2C%5C%22screen_width%5C%22%3A1536%2C%5C%22screen_height%5C%22%3A864%2C%5C%22browser_online%5C%22%3Atrue%2C%5C%22cpu_core_num%5C%22%3A8%2C%5C%22device_memory%5C%22%3A8%2C%5C%22downlink%5C%22%3A10%2C%5C%22effective_type%5C%22%3A%5C%224g%5C%22%2C%5C%22round_trip_time%5C%22%3A150%7D%22; VIDEO_FILTER_MEMO_SELECT=%7B%22expireTime%22%3A1691443863751%2C%22type%22%3Anull%7D; home_can_add_dy_2_desktop=%221%22; __live_version__=%221.1.1.2169%22; device_web_cpu_core=8; device_web_memory_size=8; xgplayer_user_id=346045893336; csrf_session_id=2e00356b5cd8544d17a0e66484946f28; odin_tt=724eb4dd23bc6ffaed9a1571ac4c757ef597768a70c75fef695b95845b7ffcd8b1524278c2ac31c2587996d058e03414595f0a4e856c53bd0d5e5f56dc6d82e24004dc77773e6b83ced6f80f1bb70627; __ac_nonce=064caded4009deafd8b89; __ac_signature=_02B4Z6wo00f01HLUuwwAAIDBh6tRkVLvBQBy9L-AAHiHf7; ttcid=2e9619ebbb8449eaa3d5a42d8ce88ec835; webcast_leading_last_show_time=1691016922379; webcast_leading_total_show_times=1; webcast_local_quality=sd; live_can_add_dy_2_desktop=%221%22; msToken=1JDHnVPw_9yTvzIrwb7cQj8dCMNOoesXbA_IooV8cezcOdpe4pzusZE7NB7tZn9TBXPr0ylxmv-KMs5rqbNUBHP4P7VBFUu0ZAht_BEylqrLpzgt3y5ne_38hXDOX8o=; msToken=jV_yeN1IQKUd9PlNtpL7k5vthGKcHo0dEh_QPUQhr8G3cuYv-Jbb4NnIxGDmhVOkZOCSihNpA2kvYtHiTW25XNNX_yrsv5FN8O6zm3qmCIXcEe0LywLn7oBO2gITEeg=; tt_scid=mYfqpfbDjqXrIGJuQ7q-DlQJfUSG51qG.KUdzztuGP83OjuVLXnQHjsz-BRHRJu4e986
|
||||
@ -35,4 +35,6 @@ B站cookie =
|
||||
bigo_cookie =
|
||||
blued_cookie =
|
||||
afreecatv_cookie =
|
||||
netease_cookie =
|
||||
netease_cookie =
|
||||
千度热播_cookie =
|
||||
pandatv_cookie =
|
||||
49
main.py
49
main.py
@ -4,7 +4,7 @@
|
||||
Author: Hmily
|
||||
GitHub: https://github.com/ihmily
|
||||
Date: 2023-07-17 23:52:05
|
||||
Update: 2024-01-25 12:47:12
|
||||
Update: 2024-01-27 21:45:09
|
||||
Copyright (c) 2023-2024 by Hmily, All Rights Reserved.
|
||||
Function: Record live stream video.
|
||||
"""
|
||||
@ -38,7 +38,9 @@ from spider import (
|
||||
get_bigo_stream_url,
|
||||
get_blued_stream_url,
|
||||
get_afreecatv_stream_url,
|
||||
get_netease_stream_data
|
||||
get_netease_stream_data,
|
||||
get_qiandurebo_stream_data,
|
||||
get_pandatv_stream_data
|
||||
)
|
||||
|
||||
from web_rid import (
|
||||
@ -52,7 +54,7 @@ from utils import (
|
||||
from msg_push import dingtalk, xizhi, tg_bot
|
||||
|
||||
version = "v2.0.9"
|
||||
platforms = "抖音|TikTok|快手|虎牙|斗鱼|YY|B站|小红书|bigo直播|blued直播|AfreecaTV|网易CC"
|
||||
platforms = "抖音|TikTok|快手|虎牙|斗鱼|YY|B站|小红书|bigo直播|blued直播|AfreecaTV|网易CC|千度热播|pandaTV"
|
||||
# --------------------------全局变量-------------------------------------
|
||||
recording = set()
|
||||
unrecording = set()
|
||||
@ -606,8 +608,10 @@ def start_record(url_data: tuple, count_variable: int = -1):
|
||||
with semaphore:
|
||||
if use_proxy:
|
||||
if global_proxy or proxy_addr != '':
|
||||
json_data = get_tiktok_stream_data(record_url, proxy_addr=proxy_addr,
|
||||
cookies=tiktok_cookie)
|
||||
json_data = get_tiktok_stream_data(
|
||||
url=record_url,
|
||||
proxy_addr=proxy_addr,
|
||||
cookies=tiktok_cookie)
|
||||
port_info = get_tiktok_stream_url(json_data, record_quality)
|
||||
|
||||
elif record_url.find("https://live.kuaishou.com/") > -1:
|
||||
@ -626,8 +630,10 @@ def start_record(url_data: tuple, count_variable: int = -1):
|
||||
platform = '斗鱼直播'
|
||||
with semaphore:
|
||||
json_data = get_douyu_info_data(record_url)
|
||||
port_info = get_douyu_stream_url(json_data, cookies=douyu_cookie,
|
||||
video_quality=record_quality)
|
||||
port_info = get_douyu_stream_url(
|
||||
json_data, cookies=douyu_cookie,
|
||||
video_quality=record_quality
|
||||
)
|
||||
|
||||
elif record_url.find("https://www.yy.com/") > -1:
|
||||
platform = 'YY直播'
|
||||
@ -659,14 +665,30 @@ def start_record(url_data: tuple, count_variable: int = -1):
|
||||
elif record_url.find("afreecatv.com/") > -1:
|
||||
platform = 'AfreecaTv直播'
|
||||
with semaphore:
|
||||
port_info = get_afreecatv_stream_url(record_url, proxy_addr=proxy_addr,
|
||||
cookies=afreecatv_cookie)
|
||||
port_info = get_afreecatv_stream_url(
|
||||
url=record_url, proxy_addr=proxy_addr,
|
||||
cookies=afreecatv_cookie
|
||||
)
|
||||
|
||||
elif record_url.find("cc.163.com/") > -1:
|
||||
platform = '网易CC直播'
|
||||
with semaphore:
|
||||
json_data = get_netease_stream_data(record_url, cookies=netease_cookie)
|
||||
json_data = get_netease_stream_data(url=record_url, cookies=netease_cookie)
|
||||
port_info = get_netease_stream_url(json_data, record_quality)
|
||||
|
||||
elif record_url.find("qiandurebo.com/") > -1:
|
||||
platform = '千度热播'
|
||||
with semaphore:
|
||||
port_info = get_qiandurebo_stream_data(url=record_url, cookies=qiandurebo_cookie)
|
||||
|
||||
elif record_url.find("www.pandalive.co.kr/") > -1:
|
||||
platform = 'pandaTV'
|
||||
with semaphore:
|
||||
port_info = get_pandatv_stream_data(
|
||||
url=record_url,
|
||||
proxy_addr=proxy_addr,
|
||||
cookies=pandatv_cookie
|
||||
)
|
||||
else:
|
||||
logger.warning(f'{record_url} 未知直播地址')
|
||||
return
|
||||
@ -1254,6 +1276,8 @@ while True:
|
||||
blued_cookie = read_config_value(config, 'Cookie', 'blued_cookie', '')
|
||||
afreecatv_cookie = read_config_value(config, 'Cookie', 'afreecatv_cookie', '')
|
||||
netease_cookie = read_config_value(config, 'Cookie', 'netease_cookie', '')
|
||||
qiandurebo_cookie = read_config_value(config, 'Cookie', '千度热播_cookie', '')
|
||||
pandatv_cookie = read_config_value(config, 'Cookie', 'pandatv_cookie', '')
|
||||
|
||||
if len(video_save_type) > 0:
|
||||
if video_save_type.upper().lower() == "FLV".lower():
|
||||
@ -1335,8 +1359,11 @@ while True:
|
||||
'app.blued.cn',
|
||||
'play.afreecatv.com',
|
||||
'm.afreecatv.com',
|
||||
'cc.163.com'
|
||||
'cc.163.com',
|
||||
'qiandurebo.com',
|
||||
'www.pandalive.co.kr'
|
||||
]
|
||||
|
||||
if url_host in host_list:
|
||||
new_line = (quality, url, name)
|
||||
url_tuples_list.append(new_line)
|
||||
|
||||
87
spider.py
87
spider.py
@ -4,7 +4,7 @@
|
||||
Author: Hmily
|
||||
GitHub:https://github.com/ihmily
|
||||
Date: 2023-07-15 23:15:00
|
||||
Update: 2024-01-24 22:57:03
|
||||
Update: 2024-01-27 21:32:55
|
||||
Copyright (c) 2023 by Hmily, All Rights Reserved.
|
||||
Function: Get live stream data.
|
||||
"""
|
||||
@ -583,6 +583,85 @@ def get_netease_stream_data(url: str, cookies: Union[str, None] = None) -> Dict[
|
||||
return result
|
||||
|
||||
|
||||
@trace_error_decorator
|
||||
def get_qiandurebo_stream_data(url: str, cookies: Union[str, None] = None) -> Dict[str, Any]:
|
||||
headers = {
|
||||
'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
|
||||
'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
|
||||
'referer': 'https://qiandurebo.com/web/index.php',
|
||||
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.58',
|
||||
}
|
||||
if cookies:
|
||||
headers['Cookie'] = cookies
|
||||
|
||||
req = urllib.request.Request(url, headers=headers)
|
||||
response = opener.open(req, timeout=15)
|
||||
html_str = response.read().decode('utf-8')
|
||||
data = re.search('var user = (.*?)\r\n\s+user\.play_url', html_str, re.S).group(1)
|
||||
anchor_name = re.findall('"zb_nickname": "(.*?)",\r\n', data)
|
||||
|
||||
result = {"anchor": "", "is_live": False}
|
||||
if len(anchor_name) > 0:
|
||||
result['anchor_name'] = anchor_name[0]
|
||||
play_url = re.findall('"play_url": "(.*?)",\r\n', data)
|
||||
|
||||
if len(play_url) > 0:
|
||||
result['anchor_name'] = anchor_name[0]
|
||||
result['flv_url'] = play_url[0]
|
||||
result['is_live'] = True
|
||||
result['record_url'] = play_url[0]
|
||||
return result
|
||||
|
||||
|
||||
@trace_error_decorator
|
||||
def get_pandatv_stream_data(url: str, proxy_addr: Union[str, None] = None, cookies: Union[str, None] = None) -> Dict[str, Any]:
|
||||
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',
|
||||
'content-type': 'application/x-www-form-urlencoded',
|
||||
'referer': 'https://www.pandalive.co.kr/',
|
||||
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.58',
|
||||
}
|
||||
if cookies:
|
||||
headers['Cookie'] = cookies
|
||||
|
||||
user_id = url.split('?')[0].rsplit('/', maxsplit=1)[1]
|
||||
url2 = 'https://api.pandalive.co.kr/v1/live/play'
|
||||
data = {
|
||||
'action': 'watch',
|
||||
'userId': user_id,
|
||||
'password': '',
|
||||
'shareLinkType': '',
|
||||
}
|
||||
|
||||
if proxy_addr:
|
||||
proxies = {
|
||||
'http': proxy_addr,
|
||||
'https': proxy_addr
|
||||
}
|
||||
response = requests.post(url2, data=data, headers=headers, proxies=proxies, timeout=15)
|
||||
json_data = response.json()
|
||||
|
||||
else:
|
||||
|
||||
data = urllib.parse.urlencode(data).encode('utf-8')
|
||||
req = urllib.request.Request(url2, data=data, headers=headers)
|
||||
response = urllib.request.urlopen(req, timeout=15)
|
||||
json_str = response.read().decode('utf-8')
|
||||
json_data = json.loads(json_str)
|
||||
|
||||
anchor_name = json_data['media']['userNick']
|
||||
result = {"anchor_name": anchor_name, "is_live": False}
|
||||
live_status = json_data['media']['isLive']
|
||||
|
||||
if live_status:
|
||||
play_url = json_data['PlayList']['hls'][0]['url']
|
||||
result['m3u8_url'] = play_url
|
||||
result['is_live'] = True
|
||||
result['record_url'] = play_url
|
||||
return result
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# 尽量用自己的cookie,以避免默认的不可用导致无法获取数据
|
||||
# 以下示例链接不保证时效性,请自行查看链接是否能正常访问
|
||||
@ -602,6 +681,8 @@ if __name__ == '__main__':
|
||||
# url = 'https://play.afreecatv.com/sw7love' # afreecatv直播
|
||||
# url = 'https://m.afreecatv.com/#/player/hl6260' # afreecatv直播
|
||||
# url = 'https://cc.163.com/583946984' # 网易cc直播
|
||||
# url = 'https://qiandurebo.com/web/video.php?roomnumber=33333' # 千度热播
|
||||
# url = 'https://www.pandalive.co.kr/live/play/bara0109' # pandaTV
|
||||
|
||||
print(get_douyin_stream_data(url))
|
||||
# print(get_tiktok_stream_data(url,proxy_addr=''))
|
||||
@ -615,4 +696,6 @@ if __name__ == '__main__':
|
||||
# print(get_bigo_stream_url(url))
|
||||
# print(get_blued_stream_url(url))
|
||||
# print(get_afreecatv_stream_url(url, proxy_addr=''))
|
||||
# print(get_netease_stream_data(url))
|
||||
# print(get_netease_stream_data(url))
|
||||
# print(get_qiandurebo_stream_data(url))
|
||||
# print(get_pandatv_stream_data(url, proxy_addr=''))
|
||||
Loading…
x
Reference in New Issue
Block a user