mirror of
https://github.com/ihmily/DouyinLiveRecorder.git
synced 2026-03-22 07:28:24 +08:00
feat: add chzzk live record
This commit is contained in:
17
README.md
17
README.md
@@ -46,6 +46,7 @@
|
||||
- [x] 时光直播
|
||||
- [x] 映客直播
|
||||
- [x] 音播直播
|
||||
- [x] CHZZK
|
||||
- [ ] 更多平台正在更新中
|
||||
|
||||
</div>
|
||||
@@ -85,13 +86,13 @@
|
||||
|
||||
- 另外,如果需要录制TikTok、AfreecaTV等海外平台,请在配置文件中设置开启代理并添加proxy_addr链接 如:`127.0.0.1:7890` (这只是示例地址,具体根据实际填写)。
|
||||
|
||||
- 假如`URL_config.ini`文件中添加的直播间地址,有个别直播间暂时不想录制又不想移除链接,可以在对应直播间的链接开头加上`#`,那么下次启动软件录制时将跳过该直播间。
|
||||
- 假如`URL_config.ini`文件中添加的直播间地址,有个别直播间暂时不想录制又不想移除链接,可以在对应直播间的链接开头加上`#`,那么将停止该直播间的监测以及录制。
|
||||
|
||||
- 软件默认录制清晰度为 `原画` ,如果要单独设置某个直播间的录制画质,可以在添加直播间地址时前面加上画质即可,如`超清,https://live.douyin.com/745964462470` 记得中间要有`,` 分隔。
|
||||
|
||||
- 如果要长时间挂着软件循环监测直播,最好循环时间设置长一点(咱也不差没录制到的那几分钟),避免因请求频繁导致被官方封禁IP 。
|
||||
|
||||
- 要停止直播录制,在录制界面使用 `Ctrl+C ` 组合键中断录制。
|
||||
- 要停止直播录制,在录制界面使用 `Ctrl+C ` 组合键中断录制,若要停止其中某个直播间的录制,可在`URL_config.ini`文件中的地址前加#,会自动停止对应直播间的录制并正常保存视频。
|
||||
- 最后,欢迎右上角给本项目一个star,同时也非常乐意大家提交pr。
|
||||
|
||||
 
|
||||
@@ -199,7 +200,10 @@ https://www.rengzu.com/180778
|
||||
https://www.inke.cn/liveroom/index.html?uid=22954469&id=1720860391070904
|
||||
|
||||
音播直播:
|
||||
https://www.ybw1666.com/800002949
|
||||
https://live.ybw1666.com/800002949
|
||||
|
||||
CHZZK:
|
||||
https://chzzk.naver.com/live/458f6ec20b034f49e0fc6d03921646d2
|
||||
```
|
||||
|
||||
 
|
||||
@@ -308,7 +312,7 @@ docker-compose stop
|
||||
|
||||
②在容器内时,如果手动中断容器运行停止录制,会导致正在录制的视频文件损坏!
|
||||
|
||||
**如果想避免手动中断或者异常中断导致文件损坏的情况,请使用 `ts` 格式录制并且不要开启自动转成mp4设置**。
|
||||
**无论哪种运行方式,为避免手动中断或者异常中断导致录制的视频文件损坏的情况,推荐使用 `ts` 格式保存**。
|
||||
|
||||
 
|
||||
|
||||
@@ -323,10 +327,15 @@ docker-compose stop
|
||||
<a href="https://github.com/kaine1973" target="_blank"><img src="https://github.com/kaine1973.png?size=50" alt="kaine1973" style="width:53px; height:51px;" /></a>
|
||||
<a href="https://github.com/Max-Tortoise" target="_blank"><img src="https://github.com/Max-Tortoise.png?size=50" alt="Max-Tortoise" style="width:53px; height:51px;" /></a>
|
||||
[](https://github.com/justdoiting)
|
||||
[](https://github.com/wujiyu115)
|
||||
 
|
||||
|
||||
## ⏳提交日志
|
||||
|
||||
- 20240928
|
||||
- 新增CHZZK直播录制
|
||||
- 修复音播直播录制
|
||||
|
||||
- 20240903
|
||||
- 新增抖音双屏录制、音播直播录制
|
||||
- 修复PandaTV、bigo直播录制
|
||||
|
||||
@@ -76,6 +76,7 @@ shiguang_cookie =
|
||||
yinbo_cookie =
|
||||
yingke_cookie =
|
||||
zhihu_cookie =
|
||||
chzzk_cookie =
|
||||
|
||||
[Authorization]
|
||||
popkontv_token =
|
||||
|
||||
30
main.py
30
main.py
@@ -4,7 +4,7 @@
|
||||
Author: Hmily
|
||||
GitHub: https://github.com/ihmily
|
||||
Date: 2023-07-17 23:52:05
|
||||
Update: 2024-09-25 07:14:00
|
||||
Update: 2024-09-25 08:32:00
|
||||
Copyright (c) 2023-2024 by Hmily, All Rights Reserved.
|
||||
Function: Record live stream video.
|
||||
"""
|
||||
@@ -65,7 +65,8 @@ from spider import (
|
||||
get_shiguang_stream_url,
|
||||
get_yinbo_stream_url,
|
||||
get_yingke_stream_url,
|
||||
get_zhihu_stream_url
|
||||
get_zhihu_stream_url,
|
||||
get_chzzk_stream_data
|
||||
)
|
||||
|
||||
from utils import (
|
||||
@@ -74,10 +75,10 @@ from utils import (
|
||||
)
|
||||
from msg_push import dingtalk, xizhi, tg_bot, email_message, bark
|
||||
|
||||
version = "v3.0.7"
|
||||
version = "v3.0.8"
|
||||
platforms = ("\n国内站点:抖音|快手|虎牙|斗鱼|YY|B站|小红书|bigo|blued|网易CC|千度热播|猫耳FM|Look|TwitCasting|百度|微博|"
|
||||
"酷狗|LiveMe|花椒|流星|Acfun|时光|映客|音播|知乎"
|
||||
"\n海外站点:TikTok|AfreecaTV|PandaTV|WinkTV|FlexTV|PopkonTV|TwitchTV|ShowRoom")
|
||||
"\n海外站点:TikTok|AfreecaTV|PandaTV|WinkTV|FlexTV|PopkonTV|TwitchTV|ShowRoom|CHZZK")
|
||||
|
||||
recording = set()
|
||||
not_recording = set()
|
||||
@@ -1021,6 +1022,13 @@ def start_record(url_data: tuple, count_variable: int = -1):
|
||||
port_info = get_zhihu_stream_url(
|
||||
url=record_url, proxy_addr=proxy_address, cookies=zhihu_cookie)
|
||||
|
||||
elif record_url.find("chzzk.naver.com/") > -1:
|
||||
platform = 'CHZZK'
|
||||
with semaphore:
|
||||
json_data = get_chzzk_stream_data(
|
||||
url=record_url, proxy_addr=proxy_address, cookies=chzzk_cookie)
|
||||
port_info = get_stream_url(json_data, record_quality, spec=True)
|
||||
|
||||
else:
|
||||
logger.error(f'{record_url} 未知直播地址')
|
||||
return
|
||||
@@ -1181,7 +1189,7 @@ def start_record(url_data: tuple, count_variable: int = -1):
|
||||
rec_info = f"\r{anchor_name} 准备开始录制视频: {full_path}"
|
||||
filename_short = full_path + '/' + anchor_name + '_' + now
|
||||
if show_url:
|
||||
re_plat = ('WinkTV', 'PandaTV', 'ShowRoom')
|
||||
re_plat = ('WinkTV', 'PandaTV', 'ShowRoom', 'CHZZK')
|
||||
if platform in re_plat:
|
||||
logger.info(f"{platform} | {anchor_name} | 直播源地址: {port_info['m3u8_url']}")
|
||||
else:
|
||||
@@ -1755,7 +1763,7 @@ while True:
|
||||
create_time_file = options.get(read_config_value(config, '录制设置', '生成时间文件', "否"), False)
|
||||
enable_proxy_platform = read_config_value(
|
||||
config, '录制设置', '使用代理录制的平台(逗号分隔)',
|
||||
'tiktok, afreecatv, pandalive, winktv, flextv, popkontv, twitch, showroom')
|
||||
'tiktok, afreecatv, pandalive, winktv, flextv, popkontv, twitch, showroom, chzzk')
|
||||
enable_proxy_platform_list = enable_proxy_platform.replace(',', ',').split(',') if enable_proxy_platform else None
|
||||
extra_enable_proxy = read_config_value(config, '录制设置', '额外使用代理录制的平台(逗号分隔)', '')
|
||||
extra_enable_proxy_platform_list = extra_enable_proxy.replace(',', ',').split(',') if extra_enable_proxy else None
|
||||
@@ -1821,6 +1829,7 @@ while True:
|
||||
yinbo_cookie = read_config_value(config, 'Cookie', 'yinbo_cookie', '')
|
||||
yingke_cookie = read_config_value(config, 'Cookie', 'yingke_cookie', '')
|
||||
zhihu_cookie = read_config_value(config, 'Cookie', 'zhihu_cookie', '')
|
||||
chzzk_cookie = read_config_value(config, 'Cookie', 'chzzk_cookie', '')
|
||||
|
||||
video_save_type_list = ("FLV", "MKV", "TS", "MP4", "TS音频", "MKV音频")
|
||||
if video_save_type and video_save_type.upper() in video_save_type_list:
|
||||
@@ -1928,7 +1937,9 @@ while True:
|
||||
'www.flextv.co.kr',
|
||||
'www.popkontv.com',
|
||||
'www.twitch.tv',
|
||||
'www.showroom-live.com'
|
||||
'www.showroom-live.com',
|
||||
'chzzk.naver.com',
|
||||
'm.chzzk.naver.com',
|
||||
]
|
||||
|
||||
platform_host.extend(overseas_platform_host)
|
||||
@@ -1939,7 +1950,8 @@ while True:
|
||||
"www.zhihu.com",
|
||||
"www.xiaohongshu.com",
|
||||
"www.redelight.cn",
|
||||
"www.huya.com"
|
||||
"www.huya.com",
|
||||
"chzzk.naver.com"
|
||||
)
|
||||
|
||||
if url_host in platform_host:
|
||||
@@ -1999,4 +2011,4 @@ while True:
|
||||
t2.start()
|
||||
first_run = False
|
||||
|
||||
time.sleep(3)
|
||||
time.sleep(3)
|
||||
58
spider.py
58
spider.py
@@ -4,8 +4,8 @@
|
||||
Author: Hmily
|
||||
GitHub: https://github.com/ihmily
|
||||
Date: 2023-07-15 23:15:00
|
||||
Update: 2024-09-19 02:05:12
|
||||
Copyright (c) 2023 by Hmily, All Rights Reserved.
|
||||
Update: 2024-09-28 08:31:12
|
||||
Copyright (c) 2023-2024 by Hmily, All Rights Reserved.
|
||||
Function: Get live stream data.
|
||||
"""
|
||||
import gzip
|
||||
@@ -2378,7 +2378,7 @@ def get_yinbo_stream_url(url: str, proxy_addr: Union[str, None] = None, cookies:
|
||||
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Mobile/15E148 Safari/604.1',
|
||||
'Accept': 'application/json, text/plain, */*',
|
||||
'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',
|
||||
'Referer': 'https://www.ybw1666.com/800005143?promoters=0',
|
||||
'Referer': 'https://live.ybw1666.com/800005143?promoters=0',
|
||||
}
|
||||
if cookies:
|
||||
headers['Cookie'] = cookies
|
||||
@@ -2391,8 +2391,9 @@ def get_yinbo_stream_url(url: str, proxy_addr: Union[str, None] = None, cookies:
|
||||
play_api = f'https://wap.ybw1666.com/api/ui/room/v1.0.0/live.ashx?{urllib.parse.urlencode(params)}'
|
||||
json_str = get_req(play_api, proxy_addr=proxy_addr, headers=headers)
|
||||
json_data = json.loads(json_str)
|
||||
anchor_name = json_data['data']['roomInfo']['nickname']
|
||||
live_status = json_data['data']['roomInfo']['live_stat']
|
||||
room_data = json_data['data']['roomInfo']
|
||||
anchor_name = room_data['nickname']
|
||||
live_status = room_data['live_stat']
|
||||
|
||||
def get_live_domain(page_url):
|
||||
html_str = get_req(page_url, proxy_addr=proxy_addr, headers=headers)
|
||||
@@ -2406,7 +2407,7 @@ def get_yinbo_stream_url(url: str, proxy_addr: Union[str, None] = None, cookies:
|
||||
result = {"anchor_name": anchor_name, "is_live": False}
|
||||
if live_status == 1:
|
||||
flv_domain, hls_domain = get_live_domain(url)
|
||||
live_id = json_data['data']['roomInfo']['liveID']
|
||||
live_id = room_data['liveID']
|
||||
flv_url = f'{flv_domain}/{live_id}.flv'
|
||||
m3u8_url = f'{hls_domain}/{live_id}.m3u8'
|
||||
result["is_live"] = True
|
||||
@@ -2443,6 +2444,40 @@ def get_zhihu_stream_url(url: str, proxy_addr: Union[str, None] = None, cookies:
|
||||
return result
|
||||
|
||||
|
||||
@trace_error_decorator
|
||||
def get_chzzk_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',
|
||||
'origin': 'https://chzzk.naver.com',
|
||||
'referer': 'https://chzzk.naver.com/live/458f6ec20b034f49e0fc6d03921646d2',
|
||||
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0',
|
||||
}
|
||||
if cookies:
|
||||
headers['Cookie'] = cookies
|
||||
|
||||
room_id = url.split('?')[0].rsplit('/', maxsplit=1)[-1]
|
||||
play_api = f'https://api.chzzk.naver.com/service/v3/channels/{room_id}/live-detail'
|
||||
json_str = get_req(play_api, proxy_addr=proxy_addr, headers=headers, abroad=True)
|
||||
json_data = json.loads(json_str)
|
||||
live_data = json_data['content']
|
||||
anchor_name = live_data['channel']['channelName']
|
||||
live_status = live_data['status']
|
||||
|
||||
result = {"anchor_name": anchor_name, "is_live": False}
|
||||
if live_status == 'OPEN':
|
||||
play_data = json.loads(live_data['livePlaybackJson'])
|
||||
m3u8_url = play_data['media'][0]['path']
|
||||
result["is_live"] = True
|
||||
result["m3u8_url"] = m3u8_url
|
||||
m3u8_url_list = get_play_url_list(m3u8_url, proxy=proxy_addr, header=headers, abroad=True)
|
||||
prefix = m3u8_url.split('?')[0].rsplit('/', maxsplit=1)[0]
|
||||
m3u8_url_list = [prefix + '/' + i for i in m3u8_url_list]
|
||||
result["play_url_list"] = m3u8_url_list
|
||||
return result
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# 尽量用自己的cookie,以避免默认的不可用导致无法获取数据
|
||||
# 以下示例链接不保证时效性,请自行查看链接是否能正常访问
|
||||
@@ -2456,10 +2491,7 @@ if __name__ == '__main__':
|
||||
# room_url = 'https://www.yy.com/22490906/22490906' # YY直播
|
||||
# room_url = 'https://live.bilibili.com/21593109' # b站直播
|
||||
# room_url = 'https://live.bilibili.com/23448867' # b站直播
|
||||
# 小红书直播
|
||||
# room_url = 'http://xhslink.com/O9f9fM'
|
||||
# room_url = 'https://www.redelight.cn/hina/livestream/569077534207413574?appuid=5f3f478a00000000010005b3&'
|
||||
# room_url = 'https://www.xiaohongshu.com/hina/livestream/569098486282043893?appuid=5f3f478a00000000010005b3&'
|
||||
# room_url = 'http://xhslink.com/O9f9fM' # 小红书直播
|
||||
# room_url = 'https://www.bigo.tv/cn/716418802' # bigo直播
|
||||
# room_url = 'https://slink.bigovideo.tv/uPvCVq' # bigo直播
|
||||
# room_url = 'https://app.blued.cn/live?id=Mp6G2R' # blued直播
|
||||
@@ -2488,8 +2520,9 @@ if __name__ == '__main__':
|
||||
# room_url = 'https://live.acfun.cn/live/17912421' # Acfun
|
||||
# room_url = 'https://www.rengzu.com/180778' # 时光直播
|
||||
# room_url = 'https://www.inke.cn/liveroom/index.html?uid=710032101&id=1720857535354099' # 映客直播
|
||||
# room_url = 'https://www.ybw1666.com/800002949' # 音播直播
|
||||
# room_url = 'https://live.ybw1666.com/800002949' # 音播直播
|
||||
# room_url = 'https://www.zhihu.com/theater/114453' # 知乎直播
|
||||
# room_url = 'https://chzzk.naver.com/live/458f6ec20b034f49e0fc6d03921646d2' # CHZZK
|
||||
|
||||
print(get_douyin_stream_data(room_url, proxy_addr=''))
|
||||
# print(get_douyin_app_stream_data(room_url, proxy_addr=''))
|
||||
@@ -2526,4 +2559,5 @@ if __name__ == '__main__':
|
||||
# print(get_shiguang_stream_url(room_url, proxy_addr=''))
|
||||
# print(get_yingke_stream_url(room_url, proxy_addr=''))
|
||||
# print(get_yinbo_stream_url(room_url, proxy_addr=''))
|
||||
# print(get_zhihu_stream_url(room_url, proxy_addr=''))
|
||||
# print(get_zhihu_stream_url(room_url, proxy_addr=''))
|
||||
# print(get_chzzk_stream_data(room_url, proxy_addr=''))
|
||||
|
||||
Reference in New Issue
Block a user