2019-05-22 21:21:03 +08:00
|
|
|
|
# blivechat
|
2019-10-06 16:56:40 +08:00
|
|
|
|
用于OBS的仿YouTube风格的bilibili直播评论栏
|
2019-05-22 21:21:03 +08:00
|
|
|
|
|
2022-02-28 21:08:12 +08:00
|
|
|
|
![OBS截图](./screenshots/obs.png)
|
|
|
|
|
![Chrome截图](./screenshots/chrome.png)
|
|
|
|
|
![样式生成器截图](./screenshots/stylegen.png)
|
2019-05-22 21:21:03 +08:00
|
|
|
|
|
|
|
|
|
## 特性
|
2019-10-06 16:56:40 +08:00
|
|
|
|
* 兼容YouTube直播评论栏的样式
|
2022-02-28 21:08:12 +08:00
|
|
|
|
* 付费礼物模仿醒目留言显示
|
2019-05-22 21:21:03 +08:00
|
|
|
|
* 高亮舰队、房管、主播的用户名
|
2019-12-16 23:40:01 +08:00
|
|
|
|
* 支持屏蔽弹幕、合并相似弹幕等设置
|
2022-02-28 21:08:12 +08:00
|
|
|
|
* 自带两种样式生成器,经典YouTube风格和仿微信风格
|
2022-03-01 00:57:16 +08:00
|
|
|
|
* 支持前端直连B站服务器或者通过后端转发
|
2022-02-28 21:08:12 +08:00
|
|
|
|
* 支持自动翻译弹幕、醒目留言到日语,可以在后台配置翻译目标语言
|
|
|
|
|
* 支持标注打赏用户名的读音,可选拼音或日文假名
|
|
|
|
|
* 支持配置自定义表情,不需要开通B站官方表情
|
2019-05-22 21:21:03 +08:00
|
|
|
|
|
|
|
|
|
## 使用方法
|
2022-02-28 21:08:12 +08:00
|
|
|
|
以下几种方式任选一种即可
|
|
|
|
|
|
2020-08-16 10:10:49 +08:00
|
|
|
|
### 一、本地使用
|
2019-06-22 17:17:30 +08:00
|
|
|
|
1. 下载[发布版](https://github.com/xfgryujk/blivechat/releases)(仅提供x64 Windows版)
|
2019-05-28 19:05:59 +08:00
|
|
|
|
2. 双击`blivechat.exe`运行服务器,或者用命令行可以指定host和端口号:
|
2022-02-28 21:08:12 +08:00
|
|
|
|
```sh
|
|
|
|
|
blivechat.exe --host 127.0.0.1 --port 12450
|
|
|
|
|
```
|
2020-05-09 22:46:24 +08:00
|
|
|
|
3. 用浏览器打开[http://localhost:12450](http://localhost:12450),输入房间ID,复制房间URL
|
2019-07-15 21:30:52 +08:00
|
|
|
|
4. 用样式生成器生成样式,复制CSS
|
2020-02-01 21:27:50 +08:00
|
|
|
|
5. 在OBS中添加浏览器源,输入URL和自定义CSS
|
2019-05-28 19:05:59 +08:00
|
|
|
|
|
2020-05-09 22:46:24 +08:00
|
|
|
|
**注意事项:**
|
|
|
|
|
|
2020-11-28 22:56:45 +08:00
|
|
|
|
* 本地使用时不要关闭blivechat.exe那个黑框,否则不能继续获取头像或弹幕
|
2020-05-09 22:46:24 +08:00
|
|
|
|
* 样式生成器没有列出所有本地字体,但是可以手动输入本地字体
|
2022-01-02 13:51:22 +08:00
|
|
|
|
* 如果需要使用翻译功能,建议看[配置官方翻译接口傻瓜式教程](https://www.bilibili.com/read/cv14663633)
|
2020-05-09 22:46:24 +08:00
|
|
|
|
|
2020-08-16 10:10:49 +08:00
|
|
|
|
### 二、公共服务器
|
2020-11-28 22:56:45 +08:00
|
|
|
|
请优先在本地使用,使用公共服务器会有更大的延迟,而且服务器故障时可能发生直播事故
|
2019-10-06 16:56:40 +08:00
|
|
|
|
|
2020-10-11 13:00:57 +08:00
|
|
|
|
* [公共服务器](http://chat.bilisc.com/)
|
2019-10-06 16:56:40 +08:00
|
|
|
|
|
2020-08-16 10:10:49 +08:00
|
|
|
|
### 三、源代码版(自建服务器或在Windows以外平台)
|
|
|
|
|
0. 由于使用了git子模块,clone时需要加上`--recursive`参数:
|
2022-02-28 21:08:12 +08:00
|
|
|
|
```sh
|
|
|
|
|
git clone --recursive https://github.com/xfgryujk/blivechat.git
|
|
|
|
|
```
|
|
|
|
|
如果已经clone,拉子模块的方法:
|
|
|
|
|
```sh
|
|
|
|
|
git submodule update --init --recursive
|
|
|
|
|
```
|
2020-08-16 10:10:49 +08:00
|
|
|
|
1. 编译前端(需要安装Node.js):
|
2022-02-28 21:08:12 +08:00
|
|
|
|
```sh
|
|
|
|
|
cd frontend
|
|
|
|
|
npm i
|
|
|
|
|
npm run build
|
|
|
|
|
```
|
2019-07-07 23:01:42 +08:00
|
|
|
|
2. 运行服务器(需要Python3.6以上版本):
|
2022-02-28 21:08:12 +08:00
|
|
|
|
```sh
|
|
|
|
|
pip3 install -r requirements.txt
|
|
|
|
|
python3 main.py
|
|
|
|
|
```
|
|
|
|
|
或者可以指定host和端口号:
|
|
|
|
|
```sh
|
|
|
|
|
python3 main.py --host 127.0.0.1 --port 12450
|
|
|
|
|
```
|
2019-10-06 16:56:40 +08:00
|
|
|
|
3. 用浏览器打开[http://localhost:12450](http://localhost:12450),以下略
|
2019-07-06 01:23:29 +08:00
|
|
|
|
|
2020-08-16 10:10:49 +08:00
|
|
|
|
### 四、Docker(自建服务器)
|
2022-02-28 21:08:12 +08:00
|
|
|
|
1. ```sh
|
|
|
|
|
docker run --name blivechat -d -p 12450:12450 \
|
2022-03-01 00:57:16 +08:00
|
|
|
|
--mount source=blivechat-data,target=/mnt/data \
|
2022-02-28 21:08:12 +08:00
|
|
|
|
xfgryujk/blivechat:latest
|
|
|
|
|
```
|
2019-10-06 16:56:40 +08:00
|
|
|
|
2. 用浏览器打开[http://localhost:12450](http://localhost:12450),以下略
|
2020-08-16 10:10:49 +08:00
|
|
|
|
|
2020-11-28 22:56:45 +08:00
|
|
|
|
## 自建服务器相关补充
|
|
|
|
|
### 服务器配置
|
|
|
|
|
服务器配置在`data/config.ini`,可以配置数据库和允许自动翻译等,编辑后要重启生效
|
|
|
|
|
|
|
|
|
|
**自建服务器时强烈建议不使用加载器**,否则可能因为混合HTTP和HTTPS等原因加载不出来
|
|
|
|
|
|
|
|
|
|
### 参考nginx配置
|
|
|
|
|
`sudo vim /etc/nginx/sites-enabled/blivechat.conf`
|
2020-08-16 10:10:49 +08:00
|
|
|
|
|
2022-01-02 13:51:22 +08:00
|
|
|
|
```nginx
|
2020-08-16 10:10:49 +08:00
|
|
|
|
upstream blivechat {
|
2020-08-19 22:55:54 +08:00
|
|
|
|
keepalive 8;
|
2020-08-16 10:10:49 +08:00
|
|
|
|
# blivechat地址
|
|
|
|
|
server 127.0.0.1:12450;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# 强制HTTPS
|
|
|
|
|
server {
|
|
|
|
|
listen 80;
|
|
|
|
|
listen [::]:80;
|
|
|
|
|
server_name YOUR.DOMAIN.NAME;
|
|
|
|
|
|
|
|
|
|
return 301 https://$server_name$request_uri;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
server {
|
|
|
|
|
listen 443 ssl;
|
|
|
|
|
listen [::]:443 ssl;
|
|
|
|
|
server_name YOUR.DOMAIN.NAME;
|
|
|
|
|
|
|
|
|
|
# SSL
|
|
|
|
|
ssl_certificate /PATH/TO/CERT.crt;
|
|
|
|
|
ssl_certificate_key /PATH/TO/CERT_KEY.key;
|
|
|
|
|
|
2022-02-27 22:05:37 +08:00
|
|
|
|
client_body_buffer_size 256k;
|
|
|
|
|
client_max_body_size 1.1m;
|
|
|
|
|
|
2020-08-16 10:10:49 +08:00
|
|
|
|
# 代理header
|
2020-08-19 22:55:54 +08:00
|
|
|
|
proxy_http_version 1.1;
|
2020-08-16 10:10:49 +08:00
|
|
|
|
proxy_set_header Host $host;
|
2020-08-19 22:55:54 +08:00
|
|
|
|
proxy_set_header Connection "";
|
2020-08-16 10:10:49 +08:00
|
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
|
|
|
|
|
|
# 静态文件
|
|
|
|
|
location / {
|
|
|
|
|
root /PATH/TO/BLIVECHAT/frontend/dist;
|
|
|
|
|
# 如果文件不存在,交给前端路由
|
|
|
|
|
try_files $uri $uri/ /index.html;
|
|
|
|
|
}
|
2022-03-01 22:13:25 +08:00
|
|
|
|
location /emoticons {
|
|
|
|
|
alias /PATH/TO/BLIVECHAT/data/emoticons;
|
|
|
|
|
}
|
2020-08-16 10:10:49 +08:00
|
|
|
|
# 动态API
|
2020-08-19 23:16:01 +08:00
|
|
|
|
location /api {
|
2020-08-16 10:10:49 +08:00
|
|
|
|
proxy_pass http://blivechat;
|
|
|
|
|
}
|
|
|
|
|
# websocket
|
2020-08-19 23:16:01 +08:00
|
|
|
|
location = /api/chat {
|
2020-08-16 10:10:49 +08:00
|
|
|
|
proxy_pass http://blivechat;
|
|
|
|
|
|
|
|
|
|
# 代理websocket必须设置
|
|
|
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
|
|
|
proxy_set_header Connection "Upgrade";
|
2020-08-19 22:55:54 +08:00
|
|
|
|
|
2020-08-16 10:10:49 +08:00
|
|
|
|
# 由于这个块有proxy_set_header,这些不会自动继承
|
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|