npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

acfun-live-danmaku

v0.7.3

Published

acfun直播弹幕获取

Downloads

69

Readme

acfun-live-danmaku

简介

acfun-live-danmaku是一个用于获取acfun直播弹幕的服务端js组件

  • 因为使用了buffer所以不能运行在浏览器环境下, 编写使用node v16 lts

使用方式

const { getAcClient } = require("acfun-live-danmaku")

// 使用init(主播房间号)初始化客户端
AcClient("8500263").then(({ client }) => {
    // 启动websocket连接
    client.wsStart();
    client.on("EnterRoomAck", () => {
        console.log("Enter room success!");
    });
    client.on("RecentComment", (msg) => {
        // 获得建立连接当前的弹幕列表
        console.log(msg);
    });
    client.on("Comment", (msg) => {
        // 收到的弹幕
        console.log(msg);
    });
});

或者

const { getAcClient } = require("acfun-live-danmaku")

// 使用init(主播房间号)初始化客户端
const { client } = await getAcClient("8500263")
// 启动websocket连接
client.wsStart();
client.on("EnterRoomAck", () => {
    console.log("Enter room success!");
});
client.on("RecentComment", (commmnets) => {
    // 获得建立连接当前的弹幕列表
    console.log(commmnets);
});
client.on("Comment", (danmaku) => {
    // 收到的弹幕
    console.log(danmaku);
});

收到的弹幕返回如下

{
    content: '晚安',
    sendTimeMs: Long {
        low: -1921110048,
        high: 372,
        unsigned: false
    },
    userInfo: ZtLiveUserInfo {
        avatar: [
            [ImageCdnNode]
        ],
        userId: Long {
            low: 147764,
            high: 0,
            unsigned: false
        },
        nickname: 'NNK',
        badge: '{"medalInfo":{"uperId":100001,"userId":100001,"clubName":"蓝钻","level":100}}',
        userIdentity: ZtLiveUserIdentity {}
    }
}

事件列表

| 事件 | 消息 | payload类型 | |---------------------|-------------------------|------------------------------------| | EnterRoomAck | 程序进入直播间 | null | | Comment | 弹幕 | CommonActionSignalComment | | Like | 点赞 | CommonActionSignalLike | | Gift | 发送礼物 | CommonActionSignalGift | | UserFollowAuthor | 关注主播 | CommonActionSignalUserFollowAuthor | | UserEnterRoom | 用户进入直播间 | CommonActionSignalUserEnterRoom | | DisplayInfo | 当前直播间数据状态 | CommonStateSignalDisplayInfo | | RecentComment | 当前弹幕列表 | CommonStateSignalRecentComment | | TopUsers | 前几名用户的数据 | CommonStateSignalTopUsers | | JoinClub | 用户加入主播守护团 | AcfunActionSignalJoinClub |

安装

npm i acfun-live-danmaku --save