All Projects → orzogc → acfundanmu

orzogc / acfundanmu

Licence: GPL-3.0 license
AcFun直播API

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to acfundanmu

Danmaku
live video comments protocol and platform api
Stars: ✭ 70 (+159.26%)
Mutual labels:  live, danmaku, danmu
acfunlive-backend
AcFun直播通用后端
Stars: ✭ 19 (-29.63%)
Mutual labels:  live, danmaku, acfun
Ocbarrage
iOS 弹幕库 OCBarrage, 同时渲染5000条弹幕也不卡, 轻量, 可拓展, 高度自定义动画, 超高性能, 简单易上手; A barrage render-engine with high performance for iOS. At the same time, rendering 5000 barrages is also very smooth, lightweight, scalable, highly custom animation, ultra high performance, simple and easy to use!
Stars: ✭ 294 (+988.89%)
Mutual labels:  live, danmaku, danmu
Ocbarrage
iOS 弹幕库 OCBarrage, 同时渲染5000条弹幕也不卡, 轻量, 可拓展, 高度自定义动画, 超高性能, 简单易上手; A barrage render-engine with high performance for iOS. At the same time, rendering 5000 barrages is also very smooth, lightweight, scalable, highly custom animation, ultra high performance, simple and easy to use!
Stars: ✭ 589 (+2081.48%)
Mutual labels:  live, danmaku, danmu
Kikoplay
KikoPlay - NOT ONLY A Full-Featured Danmu Player 不仅仅是全功能弹幕播放器
Stars: ✭ 313 (+1059.26%)
Mutual labels:  danmaku, danmu
Danmu.js
HTML5 danmu (danmaku) plugin for any DOM element
Stars: ✭ 130 (+381.48%)
Mutual labels:  danmaku, danmu
Danmaku
A high-performance JavaScript danmaku engine. 高性能弹幕引擎库
Stars: ✭ 446 (+1551.85%)
Mutual labels:  danmaku, danmu
Commentcorelibrary
Javascript Live Comment (Danmaku) Engine Implementation. JS弹幕模块核心,提供从基本骨架到高级弹幕的支持。
Stars: ✭ 1,724 (+6285.19%)
Mutual labels:  danmaku, danmu
awesome-danmaku
一款轻量、适用于 H5 弹幕场景的 JS lib。🚀🚀
Stars: ✭ 35 (+29.63%)
Mutual labels:  danmaku, danmu
Danmu.server
一个开源的弹幕后端
Stars: ✭ 92 (+240.74%)
Mutual labels:  danmaku, danmu
Danmu Client
A cross-platforms danmaku client that supports transparency which based on canvas + WebSocket. 多用跨平台透明弹幕客户端,支持图文弹幕,基于canvas + WebSocket。
Stars: ✭ 151 (+459.26%)
Mutual labels:  danmaku, danmu
blrec
Bilibili Live Streaming Recorder 哔哩哔哩直播录制
Stars: ✭ 124 (+359.26%)
Mutual labels:  live, danmaku
Danmu Server
A danmaku server based on WebSocket. 弹幕服务器,基于WebSocket。
Stars: ✭ 169 (+525.93%)
Mutual labels:  danmaku, danmu
Hjdanmakudemo
A high performance danmaku engine for iOS
Stars: ✭ 844 (+3025.93%)
Mutual labels:  live, danmaku
htmlhost
hostHTML.live is downright the fastest way of hosting your single page HTML!
Stars: ✭ 21 (-22.22%)
Mutual labels:  live
mock-hls-server
Fake a live/event HLS stream from a VOD one. Useful for testing. Supports looping.
Stars: ✭ 61 (+125.93%)
Mutual labels:  live
danmu-classroom-screen
danmu-classroom-screen
Stars: ✭ 18 (-33.33%)
Mutual labels:  danmu
Giftsurfaceview
🌷 直播间送礼物拼图案动画控件
Stars: ✭ 228 (+744.44%)
Mutual labels:  live
Bilibili Live Barrage
🌈Bilibili_Live_Barrage实时监控B站直播弹幕并发送跟随弹幕
Stars: ✭ 28 (+3.7%)
Mutual labels:  live
MMM-NFL
National Football League Module for MagicMirror²
Stars: ✭ 22 (-18.52%)
Mutual labels:  live

acfundanmu

PkgGoDev

AcFun直播API,弹幕实现参照 AcFunDanmaku

示例代码

获取弹幕(非事件响应模式)

// uid为主播的uid
ac, err := acfundanmu.NewAcFunLive(acfundanmu.SetLiverUID(uid))
if err != nil {
    log.Panicln(err)
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
ch := ac.StartDanmu(ctx, false)
for {
    if danmu := ac.GetDanmu(); danmu != nil {
        for _, d := range danmu {
            switch d := d.(type) {
            case *acfundanmu.Comment:
                log.Printf("%s(%d):%s\n", d.Nickname, d.UserID, d.Content)
            case *acfundanmu.Like:
                log.Printf("%s(%d)点赞\n", d.Nickname, d.UserID)
            case *acfundanmu.EnterRoom:
                log.Printf("%s(%d)进入直播间\n", d.Nickname, d.UserID)
            case *acfundanmu.FollowAuthor:
                log.Printf("%s(%d)关注了主播\n", d.Nickname, d.UserID)
            case *acfundanmu.ThrowBanana:
                log.Printf("%s(%d)送出香蕉 * %d\n", d.Nickname, d.UserID, d.BananaCount)
            case *acfundanmu.Gift:
                log.Printf("%s(%d)送出礼物 %s * %d,连击数:%d\n", d.Nickname, d.UserID, d.GiftName, d.Count, d.Combo)
            case *acfundanmu.RichText:
                for _, r := range d.Segments {
                    switch r := r.(type) {
                    case *acfundanmu.RichTextUserInfo:
                        log.Printf("富文本用户信息:%+v\n", *r)
                    case *acfundanmu.RichTextPlain:
                        log.Printf("富文本文字:%s,颜色:%s\n", r.Text, r.Color)
                    case *acfundanmu.RichTextImage:
                        for _, image := range r.Pictures {
                            log.Printf("富文本图片:%s\n", image)
                        }
                        log.Printf("富文本图片另外的文字:%s,颜色:%s\n", r.AlternativeText, r.AlternativeColor)
                    }
                }
            case *acfundanmu.JoinClub:
                log.Printf("%s(%d)加入主播%s(%d)的守护团", d.FansInfo.Nickname, d.FansInfo.UserID, d.UperInfo.Nickname, d.UperInfo.UserID)
            }
            case *acfundanmu.ShareLive:
                log.Printf("%s(%d)分享直播间到 %d %s", d.Nickname, d.UserID, d.SharePlatform, d.SharePlatformIcon)
        }
    } else {
        if err = <-ch; err != nil {
            log.Panicln(err)
        } else {
            log.Println("直播结束")
        }
        break
    }
}

采用事件响应模式

// uid为主播的uid
ac, err := acfundanmu.NewAcFunLive(acfundanmu.SetLiverUID(uid))
if err != nil {
    log.Panicln(err)
}
ac.OnDanmuStop(func(ac *acfundanmu.AcFunLive, err error) {
    if err != nil {
        log.Println(err)
    } else {
        log.Println("直播结束")
    }
})
ac.OnComment(func(ac *acfundanmu.AcFunLive, d *acfundanmu.Comment) {
    log.Printf("%s(%d):%s\n", d.Nickname, d.UserID, d.Content)
})
ac.OnLike(func(ac *acfundanmu.AcFunLive, d *acfundanmu.Like) {
    log.Printf("%s(%d)点赞\n", d.Nickname, d.UserID)
})
ac.OnEnterRoom(func(ac *acfundanmu.AcFunLive, d *acfundanmu.EnterRoom) {
    log.Printf("%s(%d)进入直播间\n", d.Nickname, d.UserID)
})
ac.OnFollowAuthor(func(ac *acfundanmu.AcFunLive, d *acfundanmu.FollowAuthor) {
    log.Printf("%s(%d)关注了主播\n", d.Nickname, d.UserID)
})
ac.OnThrowBanana(func(ac *acfundanmu.AcFunLive, d *acfundanmu.ThrowBanana) {
    log.Printf("%s(%d)送出香蕉 * %d\n", d.Nickname, d.UserID, d.BananaCount)
})
ac.OnGift(func(ac *acfundanmu.AcFunLive, d *acfundanmu.Gift) {
    log.Printf("%s(%d)送出礼物 %s * %d,连击数:%d\n", d.Nickname, d.UserID, d.GiftName, d.Count, d.Combo)
})
ac.OnJoinClub(func(ac *acfundanmu.AcFunLive, d *acfundanmu.JoinClub) {
    log.Printf("%s(%d)加入主播%s(%d)的守护团", d.FansInfo.Nickname, d.FansInfo.UserID, d.UperInfo.Nickname, d.UperInfo.UserID)
})
ac.OnShareLive(func(ac *acfundanmu.AcFunLive, d *acfundanmu.ShareLive) {
    log.Printf("%s(%d)分享直播间到 %d %s", d.Nickname, d.UserID, d.SharePlatform, d.SharePlatformIcon)
})
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
_ = ac.StartDanmu(ctx, true)
// 做其他事情

获取直播间状态信息(非事件模式)

// uid为主播的uid
ac, err := acfundanmu.NewAcFunLive(acfundanmu.SetLiverUID(uid))
if err != nil {
    log.Panicln(err)
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
ch := ac.StartDanmu(ctx, false)
for {
    select {
    case <-ctx.Done():
        return
    default:
        // 循环获取info并处理
        time.Sleep(5 * time.Second)
        info := ac.GetLiveInfo()
        log.Printf("%+v\n", info)
    }
}
if err = <-ch; err != nil {
    log.Panicln(err)
} else {
    log.Println("直播结束")
}

获取直播间排名前50的在线观众信息列表

// uid为主播的uid
ac, err := acfundanmu.NewAcFunLive(acfundanmu.SetLiverUID(uid))
if err != nil {
    log.Panicln(err)
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
liveID := ac.GetLiveID()
go func() {
    for {
        select {
        case <-ctx.Done():
            return
        default:
            // 循环获取watchingList并处理
            watchingList, err := ac.GetWatchingList(liveID)
            if err != nil {
                log.Panicln(err)
            }
            log.Printf("%+v\n", *watchingList)
            time.Sleep(30 * time.Second)
        }
    }
}()
// 做其他事情

将弹幕转换成ass字幕文件

// uid为主播的uid
ac, err := acfundanmu.NewAcFunLive(acfundanmu.SetLiverUID(uid))
if err != nil {
    log.Panicln(err)
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
ch := ac.StartDanmu(ctx, false)
ac.WriteASS(ctx, acfundanmu.SubConfig{
    Title:     "foo",
    PlayResX:  1280, // 直播录播视频的分辨率
    PlayResY:  720,
    FontSize:  40,
    StartTime: time.Now().UnixNano()}, // 这里应该是开始录播的时间
    "foo.ass", true)
if err = <-ch; err != nil {
    log.Panicln(err)
} else {
    log.Println("直播结束")
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].