Skip to content

puzzlemoondev/BililiveRecorder-webhook-docker

Repository files navigation

BililiveRecorder-webhook-docker

Test Publish Docker Image Version (latest semver) Docker Image Size (latest semver)

Dockerized BililiveRecorder with biliup, DanmakuFactory, baidupcs and aliyunpan upload webhook with caddy reverse proxy support for automated HTTPS.

The webhook server listens for FileClosed events, uploads files, and removes them after upload success.

B 站专栏

Why

  • Parallelism (celery task queue)
  • Lightweight enough to run on t2.micro
  • Real time service & task monitoring and management (using supervisor & flower)
  • Automated HTTPS (using caddy)

Why not

  • No GUI for configuration
  • No GPU acceleration for ffmpeg tasks
  • Multiple services in a docker container (to keep memory footprint low)
  • Python

How to use

⚠️ DO NOT TURN BURN_DANMAKU ON if your machine is low on resource.

  • Add a .env file with these variables. Note that every variable is optional. For baidupcs, provide both bduss and stoken. For aliyunpan, provide rtoken. Providing credentials for both platform at the same time triggers upload to both platform concurrently.
    • RECORDER_USER: username for BiliveRecorder
    • RECORDER_PASS: password for BiliveRecorder
    • RECORDER_ADDRESS: needed if you want to use reverse proxy. defaults to localhost. If you have an A record in your DNS records you should use that instead.
    • BAIDUPCS_UPLOAD_DIR: baidupcs folder to upload files into
    • BAIDUPCS_BDUSS: bduss for baidupcs login. See baidupcs for how to retrieve.
    • BAIDUPCS_STOKEN: stoken for baidupcs login. See baidupcs for how to retrieve.
    • BAIDUPCS_MAX_UPLOAD_PARALLEL: parallel upload setting for SVIP user. Max 100.
    • ALIYUNPAN_UPLOAD_DIR: aliyunpan folder to upload files into
    • ALIYUNPAN_RTOKEN: refresh token for aliyunpan login. See aliyunpan for how to retrieve.
    • BURN_DANMAKU: pass 1 to turn danmaku burning on. This creates a separate video file with hardcoded danmaku.
    • BILIBILI_UPLOAD_BURNED: pass 1 to upload video with danmaku instead of the original.
    • REMOVE_LOCAL: pass 1 to remove local files after upload.
# without reverse proxy
make up
# with reverse proxy
make proxy-up
  • Add webhook to settings
    • Go to Settings -> Webhook -> Webhook V2
    • Add this line: http://localhost:9000/hooks/recorder-file-closed

How to Update

# without reverse proxy
make update
# with reverse proxy
make proxy-update

Biliup Integration

  • To use biliup, add your cookies.json under biliup. This directory will be mounted to /etc/biliup in the container. Alternatively, run docker compose run --rm -w /etc/biliup webhook biliup login to login interactively.
  • (Optional) Add your config yaml and cover files (optional) under biliup. See sample for all supported fields. title and desc supports string interpolation. Run biliup upload --help to see default values.
  • If you have multiple bilibili accounts, put all their cookies json inside /etc/biliup and specify their name in your config yaml.

Sample config.yml

line: kodo
limit: 3
streamers:
  "弥瑟里*": # supports unix glob syntax
    title: "【弥瑟里seri】%Y-%m-%dT%H:%M:%S录播_{title}"
    tid: 27
    copyright: 1
    tag:
      - 虚拟UP主
      - 直播
      - 录播
      - 直播录像
      - 弥瑟里seri
      - 弥瑟里
      - seri
  "*": # all supported fields
    user_cookie: cookies_for_another_account.json # defaults to cookies.json
    copyright: 1
    source: ''
    tid: 27
    cover: /etc/biliup/cover.png
    title: "【{streamer}】%Y-%m-%dT%H:%M:%S录播_{title}"
    desc: |
      streamer: {streamer}
      title: {title}
      date: %Y-%m-%dT%H:%M:%S
    dynamic: ''
    tag:
      - 虚拟UP主
      - 直播
      - 录播
      - 直播录像
    dtime: 28800
    dolby: 0
    hires: 0
    no_reprint: 1
    open_elec: 0

DanmakuFactory Integration

  • To use DanmakuFactory, add your DanmakuFactoryConfig.json under DanmakuFactory. If not, default values will be used. This directory will be mounted to /etc/DanmakuFactory in the container.

Sample DanmakuFactoryConfig.json

This is the default config file from https://github.com/hihkm/DanmakuFactory

{
    "resolution": [1920, 1080],
    "scrolltime": 12.000000,
    "fixtime": 5.000000,
    "density": 0,
    "fontname": "Microsoft YaHei",
    "fontsize": 38,
    "opacity": 180,
    "outline": 0,
    "shadow": 1,
    "displayArea": 1.000000,
    "scrollArea": 1.000000,
    "bold": true,
    "showUsernames": true,
    "showMsgbox": true,
    "msgboxSize": [500, 1080],
    "msgboxPos": [20, 0],
    "msgboxFontsize": 38,
    "giftMinPrice": 0.00,
    "blockmode": [],
    "statmode": []
}

Monitoring

  • We use flower to monitor task queues. Visit http://[RECORDER_ADDRESS]:5555/flower (or https://[RECORDER_ADDRESS]/flower for reverse proxy) to see the panel.
  • For supervisor, visit http://[RECORDER_ADDRESS]:9001 (or https://[RECORDER_ADDRESS]/supervisor for reverse proxy). Note that supervisor does not fully support reverse proxy so expect some weird behavior under reverse proxy.

Dependencies

About

Dockerized BililiveRecorder with biliup, DanmakuFactory, baidupcs and aliyunpan upload webhook with caddy reverse proxy support for automated HTTPS

Topics

Resources

License

Stars

Watchers

Forks