Skip to content

Commit 753c5e0

Browse files
committed
Fix xiaohongshu live record and add afreecatv login
1 parent 63670d0 commit 753c5e0

File tree

5 files changed

+279
-53
lines changed

5 files changed

+279
-53
lines changed

README.md

+9-20
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
[![Supported Platforms](https://img.shields.io/badge/platforms-Windows%20%7C%20Linux-blue.svg)](https://github.com/ihmily/DouyinLiveRecorder)
66
[![Docker Pulls](https://img.shields.io/docker/pulls/ihmily/douyin-live-recorder?label=Docker%20Pulls&color=blue&logo=docker)](https://hub.docker.com/r/ihmily/douyin-live-recorder/tags)
77
![GitHub issues](https://img.shields.io/github/issues/ihmily/DouyinLiveRecorder.svg)
8+
[![Latest Release](https://img.shields.io/github/v/release/ihmily/DouyinLiveRecorder)](https://github.com/ihmily/DouyinLiveRecorder/releases/latest)
89
![Downloads](https://img.shields.io/github/downloads/ihmily/DouyinLiveRecorder/total)
910

1011
一款简易的可循环值守的直播录制工具,基于FFmpeg实现多平台直播源录制,支持自定义配置录制以及直播状态推送。
@@ -106,7 +107,7 @@ B站:
106107
https://live.bilibili.com/320
107108
108109
小红书:
109-
https://www.xiaohongshu.com/hina/livestream/568980065082002402?appuid=5f3f478a00000000010005b3&apptime=
110+
https://www.redelight.cn/hina/livestream/569077534207413574/1707413727088?appuid=5f3f478a00000000010005b3&
110111
111112
bigo直播:
112113
https://www.bigo.tv/cn/716418802
@@ -138,23 +139,9 @@ https://fm.missevan.com/live/868895007
138139

139140
该解析接口 ~~仅供演示~~(演示接口暂时停止,后续再开放),并且只包含抖音、快手、虎牙直播的解析,其他平台如有需要请自行添加,源码在这里 [DouyinLiveRecorder/api](https://github.com/ihmily/DouyinLiveRecorder/tree/main/api)
140141

141-
```HTTP
142-
GET https://hmily.vip/api/jx/live/?url=
143-
```
144-
145-
请求示例:
146-
147-
```HTTP
148-
GET https://hmily.vip/api/jx/live/?url=https://live.douyin.com/573716250978
149-
```
150-
151-
若需要将抖音直播间短链接转换为长链接,使用以下接口:
152142

153-
```HTTP
154-
GET https://hmily.vip/api/jx/live/convert.php?url=https://v.douyin.com/iQLgKSj/
155-
```
156143

157-
在线播放m3u8和flv视频网站:[M3U8 在线视频播放器 ](https://jx.hmily.vip/play/)
144+
在线播放m3u8和flv视频网站:[M3U8 在线视频播放器 ](https://jx.hmily.vip/play/),源码是 [index.html](https://github.com/ihmily/DouyinLiveRecorder/blob/main/index.html)
158145

159146
 
160147

@@ -165,6 +152,7 @@ GET https://hmily.vip/api/jx/live/convert.php?url=https://v.douyin.com/iQLgKSj/
165152

166153
```bash
167154
git clone https://github.com/ihmily/DouyinLiveRecorder.git
155+
168156
```
169157

170158
2.进入项目文件夹,安装依赖
@@ -262,9 +250,13 @@ docker-compose stop
262250

263251
## ⏳提交日志
264252

253+
- 20240209
254+
- 优化AfreecaTV录制,新增账号密码登录获取cookie以及持久保存
255+
- 修复了小红书直播因官方更新直播域名,导致无法录制直播的问题
256+
- 修复了更新URL配置文件的bug
257+
- 最后,祝大家新年快乐!
265258
- 20240129
266259
- 新增猫耳FM直播录制
267-
268260
- 20240127
269261
- 新增千度热播直播录制、新增pandaTV(韩国)直播录制
270262

@@ -273,15 +265,12 @@ docker-compose stop
273265
- 新增自定义设置不同直播间的录制画质(即每个直播间录制画质可不同)
274266

275267
- 修改录制视频保存路径为 `downloads` 文件夹,并且分平台进行保存。
276-
277268
- 20240114
278269
- 新增网易cc直播录制,优化ffmpeg参数,修改AfreecaTV输入直播地址格式
279270

280271
- 修改日志记录器 @[iridescentGray](https://github.com/iridescentGray)
281-
282272
- 20240102
283273
- 修复Linux上运行,新增docker配置文件
284-
285274
- 20231210
286275

287276
- 修复录制分段bug,修复bigo录制检测bug

config/config.ini

+5-1
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,8 @@ afreecatv_cookie =
3838
netease_cookie =
3939
千度热播_cookie =
4040
pandatv_cookie =
41-
猫耳FM_cookie =
41+
猫耳FM_cookie =
42+
43+
[账号密码]
44+
afreecatv账号 =
45+
afreecatv密码 =

main.py

+21-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Author: Hmily
55
GitHub: https://github.com/ihmily
66
Date: 2023-07-17 23:52:05
7-
Update: 2024-01-29 18:45:09
7+
Update: 2024-02-09 02:41:18
88
Copyright (c) 2023-2024 by Hmily, All Rights Reserved.
99
Function: Record live stream video.
1010
"""
@@ -146,13 +146,16 @@ def display_info():
146146
logger.warning(f"错误信息: {e} 发生错误的行数: {e.__traceback__.tb_lineno}")
147147

148148

149-
def update_file(file_path: str, old_str: str, new_str: str):
149+
def update_file(file_path: str, old_str: str, new_str: str, start_str: str = None):
150150
# TODO: 更新文件操作
151151
file_data = ""
152152
with open(file_path, "r", encoding="utf-8-sig") as f:
153153
for text_line in f:
154154
if old_str in text_line:
155155
text_line = text_line.replace(old_str, new_str)
156+
if start_str:
157+
text_line = f'{start_str}{text_line}'
158+
156159
file_data += text_line
157160
with open(file_path, "w", encoding="utf-8-sig") as f:
158161
f.write(file_data)
@@ -576,7 +579,7 @@ def start_record(url_data: tuple, count_variable: int = -1):
576579
no_error = True
577580
new_record_url = ''
578581
count_time = time.time()
579-
582+
retry = 0
580583
record_quality, record_url, anchor_name = url_data
581584
print(f"\r运行新线程,传入地址 {record_url}")
582585

@@ -648,10 +651,14 @@ def start_record(url_data: tuple, count_variable: int = -1):
648651
json_data = get_bilibili_stream_data(record_url, cookies=bili_cookie)
649652
port_info = get_bilibili_stream_url(json_data, record_quality)
650653

651-
elif record_url.find("https://www.xiaohongshu.com/") > -1:
654+
elif record_url.find("https://www.redelight.cn/") > -1:
652655
platform = '小红书直播'
656+
if retry > 0:
657+
time.sleep(7200)
658+
retry = 0
653659
with semaphore:
654660
port_info = get_xhs_stream_url(record_url, cookies=xhs_cookie)
661+
retry += 1
655662

656663
elif record_url.find("https://www.bigo.tv/") > -1:
657664
platform = 'bigo直播'
@@ -1322,7 +1329,7 @@ def contains_url(string: str) -> bool:
13221329

13231330
# 读取URL_config.ini文件
13241331
try:
1325-
with open(url_config_file, "r", encoding=encoding) as file:
1332+
with open(url_config_file, "r", encoding=encoding, errors='ignore') as file:
13261333
for line in file:
13271334
line = line.strip()
13281335
if line.startswith("#") or len(line) < 20:
@@ -1362,7 +1369,7 @@ def contains_url(string: str) -> bool:
13621369
'www.douyu.com',
13631370
'www.yy.com',
13641371
'live.bilibili.com',
1365-
'www.xiaohongshu.com',
1372+
'www.redelight.cn',
13661373
'www.bigo.tv',
13671374
'app.blued.cn',
13681375
'play.afreecatv.com',
@@ -1378,12 +1385,19 @@ def contains_url(string: str) -> bool:
13781385
url_tuples_list.append(new_line)
13791386
else:
13801387
print(f"{url} 未知链接.此条跳过")
1388+
update_file(url_config_file, url, url, start_str='#')
13811389

13821390
while len(name_list):
13831391
a = name_list.pop()
13841392
replace_words = a.split('|')
13851393
if replace_words[0] != replace_words[1]:
1386-
update_file(url_config_file, replace_words[0], replace_words[1])
1394+
if replace_words[1].startswith("#"):
1395+
start_with = '#'
1396+
new_word = replace_words[1][1:]
1397+
else:
1398+
start_with = None
1399+
new_word = replace_words[1]
1400+
update_file(url_config_file, replace_words[0], new_word, start_str=start_with)
13871401

13881402
if len(url_tuples_list) > 0:
13891403
text_no_repeat_url = list(set(url_tuples_list))

0 commit comments

Comments
 (0)