dsh-bili-video: Convert Bilibili videos to directly playable video messages in QQ groups

Introduction

When doing content forwarding in DSH, a common scenario is: an Agent receives a Bilibili link and needs to send the video to a QQ group. Sending the link directly allows users to jump to the external link in the group; to send a video message, one has to write the entire chain of parsing, downloading, transcoding, and uploading, and also handle the official QQ Bot’s chunk upload protocol and group ID mapping. The plugin introduced below encapsulates this series of steps into a bili_relay tool, while also supporting listening to group messages for automatic forwarding.

This plugin is dsh-bili-video (same as the npm package name), independently published at lucifermbbgh/dsh-bilivideo-qqbot-forward-plugin, maintained by lucifermbbgh, categorized as a workflow, and authored by dsh-bili-video contributors. Plugin runtime data is managed by the root directory and does not ship with the package.

Core Features

First, let’s explain what it can do. The plugin’s capability boundaries are clearly listed in the README:

  • Link Forwarding: The bili_relay tool accepts Bilibili links, BV numbers, or b23.tv short links, as well as real group IDs;
  • Automatic Card Forwarding: Optionally connect to a SnowLuma OneBot v11 WebSocket to listen for Bilibili cards and links in group messages without needing to be @mentioned;
  • Quality Adaptation: With a Bilibili Cookie, prioritize high quality; when not logged in, use anonymous streams;
  • Large File Chunking: Files not exceeding 4.5MB are uploaded directly inline; larger files use the official chunk upload protocol and are not treated as group files;
  • Deduplication and Rate Limiting: The same BV number is forwarded only once within 6 hours, with a maximum of 3 messages per group every 10 minutes;
  • Failure Tracking: Retries once on failure and writes to data/video-failures.ndjson.

Limitations

This directly affects usability, please check before installing:

  • Only supports standard Bilibili videos, not multi-part, live streams, anime, or paid content;
  • Video duration limit is 15 minutes, inline file limit is 30MB;
  • Requires official QQ Bot credentials, and the target group must already have a group_openid mapping;
  • Requires the local machine to be able to execute ffmpeg (or specify the path via configuration).

Installation and Activation

The installation command comes from the README and does not use the github:owner/repo form:

dsh plugin --profile desktop add dsh-bili-video

After installation, override configuration in cordis.patch.yml of the profile. Minimal configuration example:

- insert:
    - id: bili-video
      name: dsh-bili-video
      config:
        root: /path/to/dsh-bili-video-data
        groups: "123456789"
        maxBytes: 31457280
        maxDurationSec: 900
        oneBotWs: ws://127.0.0.1:3001/?access_token=...

This step hooks the plugin into the current profile and sets the data directory and the group IDs allowed to be forwarded.

Configuration Items

Field Description
root Data root directory; defaults to current working directory, or use BILI_VIDEO_ROOT environment variable
groups Allowed real group IDs, comma-separated; empty means no restriction, not recommended for production environments
maxBytes Inline upload limit, default 31457280 (30MB)
maxDurationSec Duration limit, default 900 (15 minutes)
ffmpeg ffmpeg executable; defaults to ffmpeg, or use FFMPEG_PATH
oneBotWs SnowLuma OneBot v11 WS address; if empty, only tool invocation is retained
cookieFile Bilibili Cookie file; defaults to <root>/secrets/bilibili-cookie.txt
appId / appSecret Official QQ Bot credentials; can also use QQBOT_APPID / QQBOT_SECRET

The mapping from group IDs to official group_openid is read by default from <root>/data/official-bot/group-map.json.

Typical Usage

On the Agent side, directly call the bili_relay tool, passing the video address and group ID:

{
  "url": "https://www.bilibili.com/video/BV1xx411c7mD",
  "group_id": "123456789"
}

On the OneBot side, after configuring oneBotWs, Bilibili links or cards in group messages will be automatically recognized without user @. The same BV number will not be sent repeatedly within 6 hours.

Applicable Scenarios and Notes

Suitable for agent workflows that are already using the official QQ Bot and where people in the group actually post Bilibili links. Two points need to be emphasized: First, the plugin runs with the permissions of the current DSH process; the data directories it can read, networks it can access, and credentials depend on the running account, so source code and license should be checked before installation. Second, the official QQ Bot has constraints on sending frequency and file size for group video messages. The plugin’s groups, rate limiting, and deduplication configurations are designed for this, so it is not recommended to leave groups empty in production environments.

License is MIT, repository version 0.1.1, current stars 0. The code structure is relatively simple: src/core.js handles parsing, downloading, merging, chunk uploading, and sending; src/index.js is the Cordis plugin entry point, registering bili_relay and OneBot WS listening. Self-check commands for development are:

node --check src/core.js
node --check src/index.js

With the steps above, you can directly turn a Bilibili link into a playable video message in a QQ group without having to piece together the upload protocol yourself.

Directory page: https://www.skillhub.cn/plugins/lucifermbbgh/dsh-bilivideo-qqbot-forward-plugin
Source code: https://github.com/lucifermbbgh/dsh-bilivideo-qqbot-forward-plugin

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye