Skip to content

Commit

Permalink
Fix xiaohongshu live record and add afreecatv login
Browse files Browse the repository at this point in the history
  • Loading branch information
ihmily committed Feb 8, 2024
1 parent 63670d0 commit 753c5e0
Show file tree
Hide file tree
Showing 5 changed files with 279 additions and 53 deletions.
29 changes: 9 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[![Supported Platforms](https://img.shields.io/badge/platforms-Windows%20%7C%20Linux-blue.svg)](https://github.com/ihmily/DouyinLiveRecorder)
[![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)
![GitHub issues](https://img.shields.io/github/issues/ihmily/DouyinLiveRecorder.svg)
[![Latest Release](https://img.shields.io/github/v/release/ihmily/DouyinLiveRecorder)](https://github.com/ihmily/DouyinLiveRecorder/releases/latest)
![Downloads](https://img.shields.io/github/downloads/ihmily/DouyinLiveRecorder/total)

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

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

```HTTP
GET https://hmily.vip/api/jx/live/?url=
```

请求示例:

```HTTP
GET https://hmily.vip/api/jx/live/?url=https://live.douyin.com/573716250978
```

若需要将抖音直播间短链接转换为长链接,使用以下接口:

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

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

 

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

```bash
git clone https://github.com/ihmily/DouyinLiveRecorder.git

```

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

## ⏳提交日志

- 20240209
- 优化AfreecaTV录制,新增账号密码登录获取cookie以及持久保存
- 修复了小红书直播因官方更新直播域名,导致无法录制直播的问题
- 修复了更新URL配置文件的bug
- 最后,祝大家新年快乐!
- 20240129
- 新增猫耳FM直播录制

- 20240127
- 新增千度热播直播录制、新增pandaTV(韩国)直播录制

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

- 修改录制视频保存路径为 `downloads` 文件夹,并且分平台进行保存。

- 20240114
- 新增网易cc直播录制,优化ffmpeg参数,修改AfreecaTV输入直播地址格式

- 修改日志记录器 @[iridescentGray](https://github.com/iridescentGray)

- 20240102
- 修复Linux上运行,新增docker配置文件

- 20231210

- 修复录制分段bug,修复bigo录制检测bug
Expand Down
6 changes: 5 additions & 1 deletion config/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,8 @@ afreecatv_cookie =
netease_cookie =
千度热播_cookie =
pandatv_cookie =
猫耳FM_cookie =
猫耳FM_cookie =

[账号密码]
afreecatv账号 =
afreecatv密码 =
28 changes: 21 additions & 7 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Author: Hmily
GitHub: https://github.com/ihmily
Date: 2023-07-17 23:52:05
Update: 2024-01-29 18:45:09
Update: 2024-02-09 02:41:18
Copyright (c) 2023-2024 by Hmily, All Rights Reserved.
Function: Record live stream video.
"""
Expand Down Expand Up @@ -146,13 +146,16 @@ def display_info():
logger.warning(f"错误信息: {e} 发生错误的行数: {e.__traceback__.tb_lineno}")


def update_file(file_path: str, old_str: str, new_str: str):
def update_file(file_path: str, old_str: str, new_str: str, start_str: str = None):
# TODO: 更新文件操作
file_data = ""
with open(file_path, "r", encoding="utf-8-sig") as f:
for text_line in f:
if old_str in text_line:
text_line = text_line.replace(old_str, new_str)
if start_str:
text_line = f'{start_str}{text_line}'

file_data += text_line
with open(file_path, "w", encoding="utf-8-sig") as f:
f.write(file_data)
Expand Down Expand Up @@ -576,7 +579,7 @@ def start_record(url_data: tuple, count_variable: int = -1):
no_error = True
new_record_url = ''
count_time = time.time()

retry = 0
record_quality, record_url, anchor_name = url_data
print(f"\r运行新线程,传入地址 {record_url}")

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

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

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

# 读取URL_config.ini文件
try:
with open(url_config_file, "r", encoding=encoding) as file:
with open(url_config_file, "r", encoding=encoding, errors='ignore') as file:
for line in file:
line = line.strip()
if line.startswith("#") or len(line) < 20:
Expand Down Expand Up @@ -1362,7 +1369,7 @@ def contains_url(string: str) -> bool:
'www.douyu.com',
'www.yy.com',
'live.bilibili.com',
'www.xiaohongshu.com',
'www.redelight.cn',
'www.bigo.tv',
'app.blued.cn',
'play.afreecatv.com',
Expand All @@ -1378,12 +1385,19 @@ def contains_url(string: str) -> bool:
url_tuples_list.append(new_line)
else:
print(f"{url} 未知链接.此条跳过")
update_file(url_config_file, url, url, start_str='#')

while len(name_list):
a = name_list.pop()
replace_words = a.split('|')
if replace_words[0] != replace_words[1]:
update_file(url_config_file, replace_words[0], replace_words[1])
if replace_words[1].startswith("#"):
start_with = '#'
new_word = replace_words[1][1:]
else:
start_with = None
new_word = replace_words[1]
update_file(url_config_file, replace_words[0], new_word, start_str=start_with)

if len(url_tuples_list) > 0:
text_no_repeat_url = list(set(url_tuples_list))
Expand Down
Loading

0 comments on commit 753c5e0

Please sign in to comment.