Giter Site home page Giter Site logo

streamerhelper's Introduction

StreamerHelper

StreamerHelper

🍰 Never miss your Streamer again

MIT npm version nodejs version

Introduction

StreamerHelper 部署后,会在后台批量监测各个平台主播是否在线,并实时录制直播保存为视频文件,停播后投稿到b站。

(关于版权问题,投稿的参数默认一律设置的转载,简介处默认放有直播间链接)

Installation

录播配置

cp templates/info-example.json templates/info.json

Docker 部署(推荐)

配置文件: /app/templates/info.json

视频目录: /app/download

容器的保活使用docker提供的restart参数,不再使用PM2。

DNS参数可以根据地区以及实际情况进行配置。

# 本地编译
docker build -t streamerhelper .
# /your_project_path/info.json 指你配置好的info.json文件的绝对路径,后面的同理。
docker run --name stream -itd -v /your_project_path/info.json:/app/templates/info.json -v /your_project_path/download/:/app/download --dns 114.114.114.114 --restart always streamerhelper



直接部署到本机环境上

安装 Node.js

curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs

安装 ffmpeg

# Mac
brew update
brew install ffmpeg
# Linux
sudo add-apt-repository ppa:djcj/hybrid
sudo apt-get update
sudo apt-get install ffmpeg

登录:

现在只支持扫码登录和access_token登录,程序启动后会在控制台打印二维码,如果无法正常显示,请打开./qrcode.png 如果选择access_token登录,需要手动填写personInfoaccess_token的值

运行:

npm i -g pm2
# 如果装不动,添加 --registry=https://registry.npm.taobao.org 参数,npm i 同理
git clone https://github.com/ZhangMingZhao1/StreamerHelper.git && cd StreamerHelper
npm i
npm run serve

Configuration

info.json中字段的含义

StreamerHelper

字段 说明 可选值 是否必填 默认值
debug debug开关,开启后会有多余的记录 true/false false
recycleCheckTime 检测本地文件上传以及删除的间隔 300(s)
roomCheckTime 检测直播间的间隔 600(s)
videoPartLimitSize 小于此大小的文件不上传 100(mb)
logLevel 此级别之上(包括)的日志将被推送,无视大小写 "TRACE"|"DEBUG"|"INFO"|"WARN"|"ERROR" "error"

push

日志推送配置,WeChat 推送使用 Server 酱

mail

字段 说明 是否必填 默认值
enable 是否开启 true
host STMP 服务主机
port STMP 服务端口 465
from STMP 服务邮箱,作为发送邮件的邮箱
pwd STMP 服务密码
to 接受邮件的邮箱
secure 是否开启安全服务 true

wechat

字段 说明 是否必填 默认值
enable 是否开启 false
sendKey Server酱sendkey

personInfo

以下各字段的值会在登录后自动填写,如果选择access_token登录,需要手动填写personInfoaccess_token的值。

字段 说明 是否必填
nickname B站昵称
access_token 用于鉴权的token凭证
refresh_token
expires_in
tokenSignDate
mid

streamerInfo

是一个数组,描述需要录制的主播信息。

字段 说明 可选值 是否必填 默认值
name 主播名
uploadLocalFile 是否投稿 true/false true
deleteLocalFile 是否删除本地视频文件 true/false true
delayTime 投稿成功后延迟删除本地文件的时间(需要deleteLocalFile为true) 2(天)
templateTile 稿件标题,支持占位符{{name}} {{time}} 直播间名称
desc 稿件描述 Powered By StreamerHelper. https://github.com/ZhangMingZhao1/StreamerHelper
source 稿件直播源(需要copyright为2) {直播间名称} 直播间 {直播间地址}
dynamic 稿件粉丝动态 {直播间名称} 直播间 {直播间地址}
copyright 稿件来源,1为自制2为转载 1/2 2
roomUrl 直播间地址
tid 稿件分区 详见tid表 为空会导致投稿失败
tags 稿件标签 至少一个,总数量不能超过12个,并且单个不能超过20个字,否则稿件投稿失败

Example:

{
  "StreamerHelper": {
    "debug": false,
    "roomCheckTime": 600,
    "recycleCheckTime": 1800,
    "videoPartLimitSize": 100
    "logLevel": "error",
    "push": {
      "mail": {
        "enable": true,
        "host": "smtp.qq.com",
        "port": 465,
        "from": "***@qq.com",
        "pwd": ""***",
        "to": ""***@gmail.com",
        "secure": true
      },
      "wechat": {
        "enable": true,
        "sendKey": ""***"
      }
    }
  },
  "personInfo": {
    "nickname": "",
    "access_token": "",
    "refresh_token": "",
    "expires_in": 0,
    "tokenSignDate": 0,
    "mid": 0
  },
  "streamerInfo": [
    {
      "name": "主播1",
      "uploadLocalFile": true,
      "deleteLocalFile": true,
      "templateTitle": "{{name}}{{time}} 直播",
      "delayTime": 0,
      "desc": "",
      "source": "",
      "dynamic": "",
      "copyright": 2,
      "roomUrl": "https://live.xxx.com/111",
      "tid": 121,
      "tags": [
        "tag1",
        "tag2",
        "tag3"
      ]
    },
    {
      "name": "主播2",
      "uploadLocalFile": true,
      "deleteLocalFile": false,
      "templateTitle": "{{name}}{{time}} 直播",
      "delayTime": 1,
      "desc": "",
      "source": "",
      "dynamic": "",
      "copyright": 2,
      "roomUrl": "https://live.xxx.com/222",
      "tid": 171,
      "tags": [
        "tag1",
        "tag2",
        "tag3"
      ]
    }
  ]
}

Environment

我们的测试机器配置以及环境如下:

cpu mem bps OS Node.js
Intel i5-4590 @ 3.30GHz 2GB 100m Ubuntu 18.04 12.18.3

可以同时下载4个主播,不会产生卡顿。

Contributor

@ZhangMingZhao1 @umuoy1 @ni00 @daofeng2015 @FortuneDayssss @bulai0408 @zsnmwy

Thanks:

TodoList

  • 支持斗鱼,虎牙,b站直播,afreeca,抖音直播,快手直播,西瓜直播,花椒直播,YY 直播,战旗直播,酷狗繁星,NOW 直播,CC 直播,企鹅电竞直播
  • 自动监测主播在线
  • 自动上传b站
  • 多p下载多p上传
  • 支持多个主播
  • tag可配置,对应在info.json的每个主播
  • 支持access_token验证,防验证码
  • 重启后同时检测本地是否有上传失败的视频文件,并上传。
  • 爬虫定时区间,节省服务器流量,现支持配置房间检测间隔
  • 支持docker部署
  • 上传文件大小监测,解决主播断流问题出现很多小切片导致上传审核失败
  • 增加一个独立脚本遍历download文件夹下的视频文件重新上传(重启上传的折中解决办法,还有解决第一次账号密码配置错误失败上传的问题)
  • 支持twitch
  • 规范化log,完善debug log

Example

例子

见:https://space.bilibili.com/3356199 或者 https://space.bilibili.com/11314291

Tips

建议使用管口大的vps,否则上传下载速度可能会受影响。更新后请及时拉取像或git pull重新pm2 stop && npm run serve。vps比较低配的话配置的主播数量不要太多,也要注意vps的磁盘大小。日志文件会自动创建,在./logs/下。

有问题加qq群1142141023,备注streamerHelper

请开发者喝杯咖啡

您的捐赠和star是开发者持续维护的最大动力!

streamerhelper's People

Contributors

umuoy1 avatar zhangmingzhao1 avatar zsnmwy avatar ni00 avatar dfaofeng avatar cuteluobo avatar fortunedayssss avatar notplus avatar a554233472 avatar bulai0408 avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.