acfundanmu

package module
v0.0.0-...-f29103a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 14, 2024 License: GPL-3.0 Imports: 36 Imported by: 3

README

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("直播结束")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDeviceID

func GetDeviceID() (string, error)

GetDeviceID 获取设备ID

Types

type AcFunLive

type AcFunLive struct {
	// contains filtered or unexported fields
}

AcFunLive 就是直播间弹幕系统相关信息,支持并行

func NewAcFunLive

func NewAcFunLive(options ...Option) (ac *AcFunLive, err error)

NewAcFunLive 新建一个 *AcFunLive

func (*AcFunLive) AddManager

func (ac *AcFunLive) AddManager(managerUID int64) error

AddManager 主播添加房管,需要登陆AcFun帐号

func (*AcFunLive) AuthorKick

func (ac *AcFunLive) AuthorKick(liveID string, kickedUID int64) error

AuthorKick 主播踢人,需要登陆AcFun帐号,需要设置主播uid

func (*AcFunLive) CancelWearMedal

func (ac *AcFunLive) CancelWearMedal() error

CancelWearMedal 取消佩戴守护徽章,需要登陆AcFun帐号

func (*AcFunLive) CancelWearMedalWithLiverUID

func (ac *AcFunLive) CancelWearMedalWithLiverUID(liverUID int64) error

CancelWearMedalWithLiverUID 取消佩戴守护徽章,需要登陆AcFun帐号,liverUID必须是登陆帐号正在佩戴的守护徽章的主播uid

func (*AcFunLive) ChangeTitleAndCover

func (ac *AcFunLive) ChangeTitleAndCover(title, coverFile, liveID string) error

ChangeTitleAndCover 更改直播间标题和封面,coverFile为直播间封面图片(可以是gif)的本地路径或网络链接。 title为空时会没有标题,coverFile为空时只更改标题,需要登陆主播的AcFun帐号。

func (*AcFunLive) CheckLiveAuth

func (ac *AcFunLive) CheckLiveAuth() (bool, error)

CheckLiveAuth 检测登陆帐号是否有直播权限,需要登陆主播的AcFun帐号

func (*AcFunLive) CopyEventHandlers

func (ac *AcFunLive) CopyEventHandlers(anotherAC *AcFunLive)

CopyEventHandlers 弹幕获取采用事件响应模式时复制 anotherAC 的事件处理函数到 ac

func (*AcFunLive) DeleteManager

func (ac *AcFunLive) DeleteManager(managerUID int64) error

DeleteManager 主播删除房管,需要登陆AcFun帐号

func (*AcFunLive) FetchKuaiShouAPI

func (ac *AcFunLive) FetchKuaiShouAPI(url string, form *fasthttp.Args, sign bool) (body []byte, e error)

FetchKuaiShouAPI 获取快手API的响应,测试用

func (*AcFunLive) GetAllGiftList

func (ac *AcFunLive) GetAllGiftList() (map[int64]GiftDetail, error)

GetAllGiftList 返回全部礼物的数据

func (*AcFunLive) GetAllKickHistory

func (ac *AcFunLive) GetAllKickHistory(liveID string) ([]KickHistory, error)

GetAllKickHistory 返回主播正在直播的那一场踢人的全部历史记录,需要登陆主播的AcFun帐号

func (*AcFunLive) GetAllLiveList

func (ac *AcFunLive) GetAllLiveList() ([]UserLiveInfo, error)

GetAllLiveList 返回全部正在直播的直播间列表

func (*AcFunLive) GetBillboard

func (ac *AcFunLive) GetBillboard(uid int64) ([]BillboardUser, error)

GetBillboard 返回指定uid的主播最近七日内的礼物贡献榜前50名观众的详细信息

func (*AcFunLive) GetDanmu

func (ac *AcFunLive) GetDanmu() (danmu []DanmuMessage)

GetDanmu 返回弹幕数据danmu,danmu为nil时说明弹幕获取结束(出现错误或者主播下播),需要先调用StartDanmu(ctx, false)。 一个AcFunLive只能同时调用GetDanmu()一次。

func (*AcFunLive) GetDeviceID

func (ac *AcFunLive) GetDeviceID() string

GetDeviceID 返回设备ID

func (*AcFunLive) GetGiftList

func (ac *AcFunLive) GetGiftList(liveID string) (map[int64]GiftDetail, error)

GetGiftList 返回指定主播直播间的礼物数据

func (*AcFunLive) GetKickHistory

func (ac *AcFunLive) GetKickHistory(liveID string, count, page int) (list []KickHistory, lastPage bool, e error)

GetKickHistory 返回主播正在直播的那一场踢人的历史记录,count为每页的数量,page为第几页(从0开始数起),lastPage说明是否最后一页,需要登陆主播的AcFun帐号

func (*AcFunLive) GetLiveCutInfo

func (ac *AcFunLive) GetLiveCutInfo(uid int64, liveID string) (*LiveCutInfo, error)

GetLiveCutInfo 获取uid指定主播的直播剪辑信息,只在主播直播时才能请求,需要直播的liveID,需要登陆AcFun帐号

func (*AcFunLive) GetLiveCutStatus

func (ac *AcFunLive) GetLiveCutStatus() (bool, error)

GetLiveCutStatus 查询是否允许观众剪辑直播录像,需要登陆主播的AcFun帐号

func (*AcFunLive) GetLiveData

func (ac *AcFunLive) GetLiveData(days int) (*LiveData, error)

GetLiveData 返回前days日到目前为止所有直播的统计数据,需要登陆主播的AcFun帐号

func (*AcFunLive) GetLiveID

func (ac *AcFunLive) GetLiveID() string

GetLiveID 返回liveID,有可能为空

func (*AcFunLive) GetLiveInfo

func (ac *AcFunLive) GetLiveInfo() *LiveInfo

GetLiveInfo 返回直播间的状态信息,需要先调用StartDanmu(ctx, false)

func (*AcFunLive) GetLiveList

func (ac *AcFunLive) GetLiveList(count, page int) (liveList []UserLiveInfo, lastPage bool, err error)

GetLiveList 返回正在直播的直播间列表,count为每页的直播间数量,page为第几页(从0开始数起),lastPage说明是否最后一页

func (*AcFunLive) GetLiveStatus

func (ac *AcFunLive) GetLiveStatus() (*LiveStatus, error)

GetLiveStatus 返回直播状态,需要登陆主播的AcFun帐号并启动直播后调用

func (*AcFunLive) GetLiveTypeList

func (ac *AcFunLive) GetLiveTypeList() ([]LiveType, error)

GetLiveTypeList 返回直播分类列表

func (*AcFunLive) GetLiverUID

func (ac *AcFunLive) GetLiverUID() int64

GetLiverUID 返回主播的uid,有可能是0

func (*AcFunLive) GetLuckList

func (ac *AcFunLive) GetLuckList(liveID, redpackID, redpackBizUnit string) ([]LuckyUser, error)

GetLuckList 返回抢到红包的用户列表,需要登陆AcFun帐号,redpackBizUnit为空时默认为ztLiveAcfunRedpackGift

func (*AcFunLive) GetManagerList

func (ac *AcFunLive) GetManagerList() ([]Manager, error)

GetManagerList 返回主播的房管列表,需要登陆主播的AcFun帐号

func (*AcFunLive) GetMedalDetail

func (ac *AcFunLive) GetMedalDetail(uid int64) (*MedalDetail, error)

GetMedalDetail 返回登陆帐号拥有的指定主播的守护徽章详细信息,需要登陆AcFun帐号

func (*AcFunLive) GetMedalList

func (ac *AcFunLive) GetMedalList() ([]Medal, error)

GetMedalList 返回登陆用户拥有的守护徽章列表,最多返回亲密度最高的300个,需要登陆AcFun帐号

func (*AcFunLive) GetMedalRankList

func (ac *AcFunLive) GetMedalRankList(uid int64) (medalRankList *MedalRankList, e error)

GetMedalRankList 返回uid指定主播的守护榜(守护徽章亲密度排名前50名的用户),可用于获取指定主播的守护徽章名字

func (*AcFunLive) GetPlayback

func (ac *AcFunLive) GetPlayback(liveID string) (*Playback, error)

GetPlayback 返回直播回放的相关信息,目前部分直播没有回放

func (*AcFunLive) GetPushConfig

func (ac *AcFunLive) GetPushConfig() (*PushConfig, error)

GetPushConfig 返回推流设置,需要登陆主播的AcFun帐号

func (*AcFunLive) GetStreamInfo

func (ac *AcFunLive) GetStreamInfo() *StreamInfo

GetStreamInfo 返回直播的直播源信息,不需要调用StartDanmu()

func (*AcFunLive) GetSummary

func (ac *AcFunLive) GetSummary(liveID string) (*Summary, error)

GetSummary 返回直播总结信息

func (*AcFunLive) GetTokenInfo

func (ac *AcFunLive) GetTokenInfo() *TokenInfo

GetTokenInfo 返回直播间token相关信息,不需要调用StartDanmu()

func (*AcFunLive) GetTranscodeInfo

func (ac *AcFunLive) GetTranscodeInfo(streamName string) ([]TranscodeInfo, error)

GetTranscodeInfo 返回转码信息,推流后调用,返回的info长度不为0说明推流成功,需要登陆主播的AcFun帐号

func (*AcFunLive) GetUserID

func (ac *AcFunLive) GetUserID() int64

GetUserID 返回AcFun帐号的uid

func (*AcFunLive) GetUserInfo

func (ac *AcFunLive) GetUserInfo(uid int64) (*UserProfileInfo, error)

GetUserInfo 返回uid指定用户的信息

func (*AcFunLive) GetUserLiveInfo

func (ac *AcFunLive) GetUserLiveInfo(uid int64) (*UserLiveInfo, error)

GetUserLiveInfo 返回uid指定用户的直播信息,可能会出现超时等各种网络原因的错误

func (*AcFunLive) GetWalletBalance

func (ac *AcFunLive) GetWalletBalance() (accoins int, bananas int, e error)

GetWalletBalance 返回钱包里AC币和拥有的香蕉的数量,需要登陆AcFun帐号

func (*AcFunLive) GetWatchingList

func (ac *AcFunLive) GetWatchingList(liveID string) ([]WatchingUser, error)

GetWatchingList 返回直播间排名前50的在线观众信息列表

func (*AcFunLive) ManagerKick

func (ac *AcFunLive) ManagerKick(liveID string, kickedUID int64) error

ManagerKick 房管踢人,需要登陆AcFun帐号,需要设置主播uid

func (*AcFunLive) OnAuthorChatAccept

func (ac *AcFunLive) OnAuthorChatAccept(handler func(*AcFunLive, *AuthorChatAccept))

OnAuthorChatAccept 处理主播接受连麦,可以多次调用

func (*AcFunLive) OnAuthorChatCall

func (ac *AcFunLive) OnAuthorChatCall(handler func(*AcFunLive, *AuthorChatCall))

OnAuthorChatCall 处理主播发起连麦,可以多次调用

func (*AcFunLive) OnAuthorChatChangeSoundConfig

func (ac *AcFunLive) OnAuthorChatChangeSoundConfig(handler func(*AcFunLive, *AuthorChatChangeSoundConfig))

OnAuthorChatChangeSoundConfig 处理主播连麦声音设置更改,可以多次调用

func (*AcFunLive) OnAuthorChatEnd

func (ac *AcFunLive) OnAuthorChatEnd(handler func(*AcFunLive, *AuthorChatEnd))

OnAuthorChatEnd 处理连麦结束,可以多次调用

func (*AcFunLive) OnAuthorChatReady

func (ac *AcFunLive) OnAuthorChatReady(handler func(*AcFunLive, *AuthorChatReady))

OnAuthorChatReady 处理主播接受连麦的信息,可以多次调用

func (*AcFunLive) OnBananaCount

func (ac *AcFunLive) OnBananaCount(handler func(ac *AcFunLive, allBananaCount string))

OnBananaCount 处理直播间获得的香蕉数,handler需要支持并行处理,可以多次调用

func (*AcFunLive) OnChatAccept

func (ac *AcFunLive) OnChatAccept(handler func(*AcFunLive, *ChatAccept))

OnChatAccept 处理用户接受连麦,可以多次调用

func (*AcFunLive) OnChatCall

func (ac *AcFunLive) OnChatCall(handler func(*AcFunLive, *ChatCall))

OnChatCall 处理主播发起连麦,可以多次调用

func (*AcFunLive) OnChatEnd

func (ac *AcFunLive) OnChatEnd(handler func(*AcFunLive, *ChatEnd))

OnChatEnd 处理连麦结束,可以多次调用

func (*AcFunLive) OnChatReady

func (ac *AcFunLive) OnChatReady(handler func(*AcFunLive, *ChatReady))

OnChatReady 处理用户接受连麦的信息,可以多次调用

func (*AcFunLive) OnComment

func (ac *AcFunLive) OnComment(handler func(*AcFunLive, *Comment))

OnComment 处理评论弹幕,handler需要支持并行处理,可以多次调用

func (*AcFunLive) OnDanmuStop

func (ac *AcFunLive) OnDanmuStop(handler func(*AcFunLive, error))

OnDanmuStop 处理获取弹幕结束,有可能是网络原因导致连接超时无法获取弹幕,直播不一定结束,可以多次调用

func (*AcFunLive) OnDisplayInfo

func (ac *AcFunLive) OnDisplayInfo(handler func(*AcFunLive, *DisplayInfo))

OnDisplayInfo 处理直播间的一些数据,handler需要支持并行处理,可以多次调用

func (*AcFunLive) OnEnterRoom

func (ac *AcFunLive) OnEnterRoom(handler func(*AcFunLive, *EnterRoom))

OnEnterRoom 处理用户进场,handler需要支持并行处理,可以多次调用

func (*AcFunLive) OnFollowAuthor

func (ac *AcFunLive) OnFollowAuthor(handler func(*AcFunLive, *FollowAuthor))

OnFollowAuthor 处理用户关注主播,handler需要支持并行处理,可以多次调用

func (*AcFunLive) OnGift

func (ac *AcFunLive) OnGift(handler func(*AcFunLive, *Gift))

OnGift 处理用户赠送礼物,handler需要支持并行处理,可以多次调用

func (*AcFunLive) OnJoinClub

func (ac *AcFunLive) OnJoinClub(handler func(*AcFunLive, *JoinClub))

OnJoinClub 处理用户加入主播守护团,handler需要支持并行处理,可以多次调用

func (*AcFunLive) OnKickedOut

func (ac *AcFunLive) OnKickedOut(handler func(ac *AcFunLive, kickedOutReason string))

OnKickedOut 处理被踢出直播间,可以多次调用

func (*AcFunLive) OnLike

func (ac *AcFunLive) OnLike(handler func(*AcFunLive, *Like))

OnLike 处理点赞弹幕,handler需要支持并行处理,可以多次调用

func (*AcFunLive) OnManagerState

func (ac *AcFunLive) OnManagerState(handler func(*AcFunLive, ManagerState))

OnManagerState 处理登陆帐号的房管状态,可以多次调用

func (*AcFunLive) OnRecentComment

func (ac *AcFunLive) OnRecentComment(handler func(*AcFunLive, []Comment))

OnRecentComment 处理APP进直播间时显示的最近发的弹幕,可以多次调用

func (*AcFunLive) OnRedpackList

func (ac *AcFunLive) OnRedpackList(handler func(*AcFunLive, []Redpack))

OnRedpackList 处理直播间的红包列表,handler需要支持并行处理,可以多次调用

func (*AcFunLive) OnRichText

func (ac *AcFunLive) OnRichText(handler func(*AcFunLive, *RichText))

OnRichText 处理富文本,handler需要支持并行处理,可以多次调用

func (*AcFunLive) OnShareLive

func (ac *AcFunLive) OnShareLive(handler func(*AcFunLive, *ShareLive))

OnShareLive 处理分享直播间到其他平台的弹幕,handler需要支持并行处理,可以多次调用

func (*AcFunLive) OnThrowBanana

func (ac *AcFunLive) OnThrowBanana(handler func(*AcFunLive, *ThrowBanana))

OnThrowBanana 处理用户投蕉,现在基本用 OnGift 代替,handler需要支持并行处理,可以多次调用

func (*AcFunLive) OnTopUsers

func (ac *AcFunLive) OnTopUsers(handler func(*AcFunLive, []TopUser))

OnTopUsers 处理直播间礼物榜在线前三的信息,handler需要支持并行处理,可以多次调用

func (*AcFunLive) OnViolationAlert

func (ac *AcFunLive) OnViolationAlert(handler func(ac *AcFunLive, violationContent string))

OnViolationAlert 处理直播间警告,可以多次调用

func (*AcFunLive) SetLiveCutStatus

func (ac *AcFunLive) SetLiveCutStatus(canCut bool) error

SetLiveCutStatus 设置是否允许观众剪辑直播录像,需要登陆主播的AcFun帐号,主播直播时无法设置

func (*AcFunLive) SetLiverUID

func (ac *AcFunLive) SetLiverUID(uid int64) (newAC *AcFunLive, err error)

SetLiverUID 设置主播uid,返回一个新的 *AcFunLive,不会复制弹幕获取采用事件响应模式时的事件处理函数

func (*AcFunLive) StartDanmu

func (ac *AcFunLive) StartDanmu(ctx context.Context, event bool) <-chan error

StartDanmu 获取弹幕,ctx用来结束弹幕的获取,event为true时采用事件响应模式。 event为false时最好调用GetDanmu()或WriteASS()以清空弹幕队列。 一个AcFunLive只能同时调用StartDanmu()一次。

func (*AcFunLive) StartLive

func (ac *AcFunLive) StartLive(title, coverFile, streamName string, portrait, panoramic bool, liveType *LiveType) (liveID string, e error)

StartLive 启动直播,title为直播间标题,coverFile为直播间封面图片(可以是gif)的本地路径或网络链接,portrait为是否手机直播,panoramic为是否全景直播。 推流成功服务器开始转码(用GetTranscodeInfo()判断)后调用,title和coverFile不能为空,需要登陆主播的AcFun帐号。

func (*AcFunLive) StopLive

func (ac *AcFunLive) StopLive(liveID string) (*StopPushInfo, error)

StopLive 停止直播,需要登陆主播的AcFun帐号

func (*AcFunLive) WearMedal

func (ac *AcFunLive) WearMedal(uid int64) error

WearMedal 佩戴uid指定的主播的守护徽章,需要登陆AcFun帐号,如果登陆帐号没有uid指定的主播的守护徽章则会取消佩戴任何徽章

func (*AcFunLive) WriteASS

func (ac *AcFunLive) WriteASS(ctx context.Context, s SubConfig, file string, newFile bool)

WriteASS 将ass字幕写入到file里,s为字幕的设置,ctx用来结束写入ass字幕,需要先调用StartDanmu(ctx, false)。 newFile为true时覆盖写入,为false时不覆盖写入且只写入Dialogue字幕。 一个AcFunLive只能同时调用WriteASS()一次。

type AuthorChatAccept

type AuthorChatAccept struct {
	ChatID     string `json:"chatID"` // 连麦ID
	SignalInfo string `json:"signalInfo"`
}

AuthorChatAccept 主播接受连麦

type AuthorChatCall

type AuthorChatCall struct {
	Inviter  AuthorChatPlayerInfo `json:"inviter"`  // 发起连麦的主播的用户信息
	ChatID   string               `json:"chatID"`   // 连麦ID
	CallTime int64                `json:"callTime"` // 连麦发起时间,是以毫秒为单位的Unix时间
}

AuthorChatCall 主播发起连麦

type AuthorChatChangeSoundConfig

type AuthorChatChangeSoundConfig struct {
	ChatID                string                `json:"chatID"`                // 连麦ID
	SoundConfigChangeType SoundConfigChangeType `json:"soundConfigChangeType"` // 声音设置更改的类型
}

AuthorChatChangeSoundConfig 主播连麦更改声音设置

type AuthorChatEnd

type AuthorChatEnd struct {
	ChatID    string      `json:"chatID"`    // 连麦ID
	EndType   ChatEndType `json:"endType"`   // 连麦结束类型
	EndLiveID string      `json:"endLiveID"` // 结束连麦的直播ID
}

AuthorChatEnd 主播连麦结束

type AuthorChatPlayerInfo

type AuthorChatPlayerInfo struct {
	UserInfo               `json:"userInfo"`
	LiveID                 string `json:"liveID"`                 // 直播ID
	EnableJumpPeerLiveRoom bool   `json:"enableJumpPeerLiveRoom"` // 允许跳转到连麦的主播直播间?
}

AuthorChatPlayerInfo 主播之间连麦的主播信息

type AuthorChatReady

type AuthorChatReady struct {
	Inviter AuthorChatPlayerInfo `json:"inviter"` // 发起连麦的主播的用户信息
	Invitee AuthorChatPlayerInfo `json:"invitee"` // 接受连麦的主播的用户信息
	ChatID  string               `json:"chatID"`  // 连麦ID
}

AuthorChatReady 主播接受连麦的信息

type BillboardUser

type BillboardUser WatchingUser

BillboardUser 就是礼物贡献榜上的用户的信息,没有AnonymousUser、Medal和ManagerType

type ChatAccept

type ChatAccept struct {
	ChatID     string        `json:"chatID"`    // 连麦ID
	MediaType  ChatMediaType `json:"mediaType"` // 连麦类型
	SignalInfo string        `json:"signalInfo"`
}

ChatAccept 用户接受连麦

type ChatCall

type ChatCall struct {
	ChatID   string `json:"chatID"`   // 连麦ID
	LiveID   string `json:"liveID"`   // 直播ID
	CallTime int64  `json:"callTime"` // 连麦发起时间,是以毫秒为单位的Unix时间
}

ChatCall 主播发起连麦

type ChatEnd

type ChatEnd struct {
	ChatID  string      `json:"chatID"`  // 连麦ID
	EndType ChatEndType `json:"endType"` // 连麦结束类型
}

ChatEnd 连麦结束

type ChatEndType

type ChatEndType int32

ChatEndType 连麦结束类型

const (
	// ChatEndUnknown 未知的连麦结束类型
	ChatEndUnknown ChatEndType = iota
	// ChatEndCancelByAuthor 连麦发起者(主播)取消连麦
	ChatEndCancelByAuthor
	// ChatEndByAuthor 连麦发起者(主播)结束连麦
	ChatEndByAuthor
	// ChatEndByGuest 被连麦的人结束连麦
	ChatEndByGuest
	// ChatEndGuestReject 被连麦的人拒绝连麦
	ChatEndGuestReject
	// ChatEndGuestTimeout 等待连麦超时
	ChatEndGuestTimeout
	// ChatEndGuestHeartbeatTimeout 被连麦的人Heartbeat超时
	ChatEndGuestHeartbeatTimeout
	// ChatEndAuthorHeartbeatTimeout 连麦发起者(主播)Heartbeat超时
	ChatEndAuthorHeartbeatTimeout
	// ChatEndPeerLiveStopped 直播下播?
	ChatEndPeerLiveStopped
)

type ChatMediaType

type ChatMediaType int32

ChatMediaType 连麦类型

const (
	// ChatMediaUnknown 未知的连麦类型
	ChatMediaUnknown ChatMediaType = iota
	// ChatMediaAudio 语音连麦
	ChatMediaAudio
	// ChatMediaVideo 视频连麦
	ChatMediaVideo
)

type ChatReady

type ChatReady struct {
	ChatID    string        `json:"chatID"`    // 连麦ID
	Guest     UserInfo      `json:"guest"`     // 被连麦的帐号信息,目前没有房管类型
	MediaType ChatMediaType `json:"mediaType"` // 连麦类型
}

ChatReady 用户接受连麦的信息

type Comment

type Comment struct {
	DanmuCommon `json:"danmuInfo"`
	Content     string `json:"content"` // 弹幕文字内容
}

Comment 用户发的弹幕

func (*Comment) GetSendTime

func (d *Comment) GetSendTime() int64

GetSendTime 获取弹幕发送时间

func (*Comment) GetUserInfo

func (d *Comment) GetUserInfo() *UserInfo

GetUserInfo 获取弹幕的用户信息

type Cookies

type Cookies []*fasthttp.Cookie

Cookies 就是AcFun帐号的cookies

func Login

func Login(account, password string) (cookies Cookies, err error)

Login 登陆AcFun帐号,account为帐号邮箱或手机号,password为帐号密码

func (Cookies) MarshalJSON

func (c Cookies) MarshalJSON() ([]byte, error)

MarshalJSON 实现json的Marshaler接口

func (*Cookies) UnmarshalJSON

func (c *Cookies) UnmarshalJSON(b []byte) error

UnmarshalJSON 实现json的Unmarshaler接口

type DailyData

type DailyData struct {
	Date      string `json:"date"`      // 直播日期,格式类似"20210206"
	LiveTimes int    `json:"liveTimes"` // 当日直播次数
	LiveStat  `json:"liveStat"`
}

DailyData 就是单日直播统计数据

type DanmuClient

type DanmuClient interface {
	// New 返回新的弹幕客户端
	NewDanmuClient() DanmuClient

	// Type 返回弹幕客户端类型
	Type() DanmuClientType

	// Dial 连接弹幕服务器,address是地址,在调用Close()后可重复调用
	Dial(address string) error

	// 读接口
	io.Reader

	// 写接口
	io.Writer

	// Close 关闭连接
	Close(message string) error
}

DanmuClient 弹幕客户端

type DanmuClientType

type DanmuClientType uint8

DanmuClientType 弹幕客户端类型

const (
	// 弹幕客户端使用WebSocket连接
	WebSocketDanmuClientType DanmuClientType = iota
	// 弹幕客户端使用TCP连接
	TCPDanmuClientType
)

type DanmuCommon

type DanmuCommon struct {
	SendTime int64 `json:"sendTime"` // 弹幕发送时间,是以毫秒为单位的Unix时间
	UserInfo `json:"userInfo"`
}

DanmuCommon 弹幕通用部分

type DanmuMessage

type DanmuMessage interface {
	GetSendTime() int64     // 获取弹幕发送时间
	GetUserInfo() *UserInfo // 获取UserInfo
}

DanmuMessage 弹幕的接口

type DisplayInfo

type DisplayInfo struct {
	WatchingCount string `json:"watchingCount"` // 直播间在线观众数量
	LikeCount     string `json:"likeCount"`     // 直播间点赞总数
	LikeDelta     int    `json:"likeDelta"`     // 点赞增加数量
}

DisplayInfo 就是直播间的一些数据

type DrawGiftInfo

type DrawGiftInfo struct {
	ScreenWidth  int64       `json:"screenWidth"`  // 手机屏幕宽度
	ScreenHeight int64       `json:"screenHeight"` // 手机屏幕高度
	DrawPoint    []DrawPoint `json:"drawPoint"`
}

DrawGiftInfo 涂鸦礼物信息

type DrawPoint

type DrawPoint struct {
	MarginLeft  int64   `json:"marginLeft"` // 到手机屏幕左边的距离
	MarginTop   int64   `json:"marginTop"`  // 到手机屏幕顶部的距离
	ScaleRatio  float64 `json:"scaleRatio"` // 放大倍数?
	Handup      bool    `json:"handup"`
	PointWidth  int64   `json:"pointWidth"`  // 点的宽度?
	PointHeight int64   `json:"pointHeight"` // 点的高度?
}

DrawPoint 单个涂鸦礼物的位置

type EnterRoom

type EnterRoom DanmuCommon

EnterRoom 用户进入直播间的弹幕

func (*EnterRoom) GetSendTime

func (d *EnterRoom) GetSendTime() int64

GetSendTime 获取弹幕发送时间

func (*EnterRoom) GetUserInfo

func (d *EnterRoom) GetUserInfo() *UserInfo

GetUserInfo 获取弹幕的用户信息

type FollowAuthor

type FollowAuthor DanmuCommon

FollowAuthor 用户关注主播的弹幕

func (*FollowAuthor) GetSendTime

func (d *FollowAuthor) GetSendTime() int64

GetSendTime 获取弹幕发送时间

func (*FollowAuthor) GetUserInfo

func (d *FollowAuthor) GetUserInfo() *UserInfo

GetUserInfo 获取弹幕的用户信息

type Gift

type Gift struct {
	DanmuCommon         `json:"danmuInfo"`
	GiftDetail          `json:"giftDetail"`
	Count               int32        `json:"count"`               // 礼物单次赠送的数量,礼物总数是Count * Combo
	Combo               int32        `json:"combo"`               // 礼物连击数量,礼物总数是Count * Combo
	Value               int64        `json:"value"`               // 礼物价值,付费礼物时单位为AC币*1000,免费礼物(香蕉)时单位为礼物数量
	ComboID             string       `json:"comboID"`             // 礼物连击ID
	SlotDisplayDuration int64        `json:"slotDisplayDuration"` // 应该是礼物动画持续的时间,单位为毫秒,送礼物后在该时间内再送一次可以实现礼物连击
	ExpireDuration      int64        `json:"expireDuration"`
	DrawGiftInfo        DrawGiftInfo `json:"drawGiftInfo"` // 礼物涂鸦
}

Gift 用户赠送礼物的弹幕

func (*Gift) GetSendTime

func (d *Gift) GetSendTime() int64

GetSendTime 获取弹幕发送时间

func (*Gift) GetUserInfo

func (d *Gift) GetUserInfo() *UserInfo

GetUserInfo 获取弹幕的用户信息

type GiftDetail

type GiftDetail struct {
	GiftID                 int64  `json:"giftID"`                 // 礼物ID
	GiftName               string `json:"giftName"`               // 礼物名字
	ARLiveName             string `json:"arLiveName"`             // 不为空时礼物属于虚拟偶像区的特殊礼物
	PayWalletType          int    `json:"payWalletType"`          // 1为付费礼物,2为免费礼物
	Price                  int    `json:"price"`                  // 礼物价格,付费礼物时单位为AC币,免费礼物(香蕉)时为1
	WebpPic                string `json:"webpPic"`                // 礼物的webp格式图片(动图)
	PngPic                 string `json:"pngPic"`                 // 礼物的png格式图片(大)
	SmallPngPic            string `json:"smallPngPic"`            // 礼物的png格式图片(小)
	AllowBatchSendSizeList []int  `json:"allowBatchSendSizeList"` // 网页或APP单次能够赠送的礼物数量列表
	CanCombo               bool   `json:"canCombo"`               // 是否能连击
	CanDraw                bool   `json:"canDraw"`                // 是否能涂鸦
	MagicFaceID            int    `json:"magicFaceID"`
	VupArID                int    `json:"vupArID"`
	Description            string `json:"description"`  // 礼物的描述
	RedpackPrice           int    `json:"redpackPrice"` // 礼物红包价格总额,单位为AC币
	CornerMarkerText       string `json:"cornerMarkerText"`
}

GiftDetail 就是礼物的详细信息

type JoinClub

type JoinClub struct {
	JoinTime int64    `json:"joinTime"` // 用户加入守护团的时间,是以毫秒为单位的Unix时间
	FansInfo UserInfo `json:"fansInfo"` // 用户的信息
	UperInfo UserInfo `json:"uperInfo"` // 主播的信息
}

JoinClub 用户加入主播的守护团,FansInfo和UperInfo都没有Avatar、Medal和ManagerType

func (*JoinClub) GetSendTime

func (d *JoinClub) GetSendTime() int64

GetSendTime 获取弹幕发送时间,实际上返回的是用户加入守护团的时间

func (*JoinClub) GetUserInfo

func (d *JoinClub) GetUserInfo() *UserInfo

GetUserInfo 获取弹幕的用户信息,实际上返回的是加入守护团的用户的信息

type KickHistory

type KickHistory struct {
	UserID   int64  `json:"userID"`   // 被踢用户的uid
	Nickname string `json:"nickname"` // 被踢用户的名字
	KickTime int64  `json:"kickTime"` // 用户被踢的时间,是以毫秒为单位的Unix时间
}

KickHistory 就是踢人历史记录

type Like

type Like DanmuCommon

Like 用户点赞的弹幕

func (*Like) GetSendTime

func (d *Like) GetSendTime() int64

GetSendTime 获取弹幕发送时间

func (*Like) GetUserInfo

func (d *Like) GetUserInfo() *UserInfo

GetUserInfo 获取弹幕的用户信息

type LiveCutInfo

type LiveCutInfo struct {
	Status      bool   `json:"status"`      // 是否允许剪辑直播录像(主播允许观众剪辑观众才能剪辑,主播直播时总是能剪辑自己的直播)
	URL         string `json:"url"`         // 剪辑直播的地址,直接访问可能出现登陆问题,需要访问跳转地址
	RedirectURL string `json:"redirectURL"` // 跳转直播剪辑的地址,访问一次后链接里的token就会失效
}

LiveCutInfo 就是直播剪辑信息

type LiveData

type LiveData struct {
	BeginDate  string                  `json:"beginDate"`  // 统计开始的日期
	EndDate    string                  `json:"endDate"`    // 统计结束的日期
	Overview   LiveStat                `json:"overview"`   // 全部直播的统计概况
	LiveDetail map[string][]LiveDetail `json:"liveDetail"` // 单场直播统计数据,key为直播日期,格式类似"20210206"
	DailyData  []DailyData             `json:"dailyData"`  // 单日直播统计数据
}

LiveData 就是直播统计数据

type LiveDetail

type LiveDetail struct {
	LiveStartTime int64 `json:"liveStartTime"` // 直播开始的时间,是以毫秒为单位的Unix时间
	LiveEndTime   int64 `json:"liveEndTime"`   // 直播结束的时间,是以毫秒为单位的Unix时间
	LiveStat      `json:"liveStat"`
}

LiveDetail 就是单场直播统计数据

type LiveInfo

type LiveInfo struct {
	KickedOut        string       `json:"kickedOut"`        // 被踢理由?
	ViolationAlert   string       `json:"violationAlert"`   // 直播间警告?
	LiveManagerState ManagerState `json:"liveManagerState"` // 登陆帐号的房管状态
	AllBananaCount   string       `json:"allBananaCount"`   // 直播间香蕉总数
	DisplayInfo      `json:"displayInfo"`
	TopUsers         []TopUser `json:"topUsers"`      // 礼物榜在线前三
	RecentComment    []Comment `json:"recentComment"` // APP进直播间时显示的最近发的弹幕
	RedpackList      []Redpack `json:"redpackList"`   // 红包列表
}

LiveInfo 就是直播间的相关状态信息

type LiveSchedule

type LiveSchedule struct {
	ActivityID    int         `json:"activityID"`    // 活动ID
	Profile       UserProfile `json:"profile"`       // 主播的用户信息
	Title         string      `json:"title"`         // 预告标题
	Cover         string      `json:"cover"`         // 预告封面
	LiveStartTime int64       `json:"liveStartTime"` // 直播开始的时间,是以毫秒为单位的Unix时间
	LiveType      LiveType    `json:"liveType"`      // 直播分类
	Reserve       bool        `json:"reserve"`       // 登陆帐号是否预约了该直播
	ReserveNumber int         `json:"reserveNumber"` // 已预约用户的数量
}

LiveSchedule 就是直播预告

type LiveStat

type LiveStat struct {
	Duration           int64 `json:"duration"` // 直播时长,单位为毫秒
	MaxPopularityValue int   `json:"maxPopularityValue"`
	WatchCount         int   `json:"watchCount"`   // 观看过直播的人数总数
	DiamondCount       int   `json:"diamondCount"` // 直播收到的付费礼物对应的钻石数量,100钻石=1AC币
	CommentCount       int   `json:"commentCount"` // 直播弹幕数量
	BananaCount        int   `json:"bananaCount"`  // 直播收到的香蕉数量
}

LiveStat 就是直播统计数据

type LiveStatus

type LiveStatus struct {
	LiveID        string `json:"liveID"`        // 直播ID
	StreamName    string `json:"streamName"`    // 直播源名字
	Title         string `json:"title"`         // 直播间标题
	LiveCover     string `json:"liveCover"`     // 直播间封面
	LiveStartTime int64  `json:"liveStartTime"` // 直播开始的时间,是以毫秒为单位的Unix时间
	Panoramic     bool   `json:"panoramic"`     // 是否全景直播
	BizUnit       string `json:"bizUnit"`       // 通常是"acfun"
	BizCustomData string `json:"bizCustomData"` // 直播分类,格式是json
}

LiveStatus 就是直播状态

type LiveType

type LiveType struct {
	CategoryID      int    `json:"categoryID"`      // 直播主分类ID
	CategoryName    string `json:"categoryName"`    // 直播主分类名字
	SubCategoryID   int    `json:"subCategoryID"`   // 直播次分类ID
	SubCategoryName string `json:"subCategoryName"` // 直播次分类名字
}

LiveType 就是直播分类

type LuckyUser

type LuckyUser struct {
	UserInfo   `json:"userInfo"`
	GrabAmount int `json:"grabAmount"` // 抢红包抢到的AC币
}

LuckyUser 就是抢到红包的用户,没有Medal和ManagerType

type Manager

type Manager struct {
	UserInfo   `json:"userInfo"`
	CustomData string `json:"customData"` // 用户的一些额外信息,格式为json
	Online     bool   `json:"online"`     // 是否直播间在线?
}

Manager 就是房管的用户信息,目前没有Medal和ManagerType

type ManagerState

type ManagerState int32

ManagerState 就是房管状态

const (
	// ManagerStateUnknown 未知的房管状态,通常说明登陆用户不是房管
	ManagerStateUnknown ManagerState = iota
	// ManagerAdded 登陆用户被添加房管权限?
	ManagerAdded
	// ManagerRemoved 登陆用户被移除房管权限?
	ManagerRemoved
	// IsManager 登陆用户是房管
	IsManager
)

type ManagerType

type ManagerType int32

ManagerType 就是房管类型

const (
	// NotManager 不是房管
	NotManager ManagerType = iota
	// NormalManager 是房管
	NormalManager
)

type Medal

type Medal struct {
	MedalInfo          `json:"medalInfo"`
	UperName           string `json:"uperName"`           // UP主的名字
	UperAvatar         string `json:"uperAvatar"`         // UP主的头像
	WearMedal          bool   `json:"wearMedal"`          // 是否正在佩戴该守护徽章
	FriendshipDegree   int    `json:"friendshipDegree"`   // 目前守护徽章的亲密度
	JoinClubTime       int64  `json:"joinClubTime"`       // 加入守护团的时间,是以毫秒为单位的Unix时间
	CurrentDegreeLimit int    `json:"currentDegreeLimit"` // 守护徽章目前等级的亲密度的上限
	MedalCount         int    `json:"medalCount"`         // 指定用户拥有的守护徽章数量
}

Medal 就是指定用户的守护徽章信息

func GetUserMedal

func GetUserMedal(uid int64, deviceID string) (medal *Medal, e error)

GetUserMedal 返回uid指定用户正在佩戴的守护徽章信息,没有FriendshipDegree、JoinClubTime和CurrentDegreeLimit

type MedalDegree

type MedalDegree struct {
	UperID               int64 `json:"uperID"`               // UP主的uid
	GiftDegree           int   `json:"giftDegree"`           // 本日送直播礼物增加的亲密度
	GiftDegreeLimit      int   `json:"giftDegreeLimit"`      // 本日送直播礼物增加的亲密度上限
	PeachDegree          int   `json:"peachDegree"`          // 本日投桃增加的亲密度
	PeachDegreeLimit     int   `json:"peachDegreeLimit"`     // 本日投桃增加的亲密度上限
	LiveWatchDegree      int   `json:"liveWatchDegree"`      // 本日看直播时长增加的亲密度
	LiveWatchDegreeLimit int   `json:"liveWatchDegreeLimit"` // 本日看直播时长增加的亲密度上限
	BananaDegree         int   `json:"bananaDegree"`         // 本日投蕉增加的亲密度
	BananaDegreeLimit    int   `json:"bananaDegreeLimit"`    // 本日投蕉增加的亲密度上限
}

MedalDegree 就是守护徽章的亲密度信息

type MedalDetail

type MedalDetail struct {
	Medal       Medal       `json:"medal"`       // 守护徽章信息
	MedalDegree MedalDegree `json:"medalDegree"` // 守护徽章亲密度信息
	UserRank    string      `json:"userRank"`    // 登陆用户的主播守护徽章亲密度的排名
}

MedalDetail 就是登陆用户的守护徽章的详细信息

type MedalInfo

type MedalInfo struct {
	UperID   int64  `json:"uperID"`   // UP主的uid
	UserID   int64  `json:"userID"`   // 用户的uid
	ClubName string `json:"clubName"` // 守护徽章名字
	Level    int    `json:"level"`    // 守护徽章等级
}

MedalInfo 就是守护徽章信息

type MedalRankList

type MedalRankList struct {
	HasFansClub          bool            `json:"hasFansClub"`          // 主播是否有守护团
	RankList             []UserMedalInfo `json:"rankList"`             // 主播守护徽章等级列表
	ClubName             string          `json:"clubName"`             // 守护徽章名字
	MedalCount           int             `json:"medalCount"`           // 拥有主播守护徽章的用户的数量
	HasMedal             bool            `json:"hasMedal"`             // 登陆用户是否有主播的守护徽章
	UserFriendshipDegree int             `json:"userFriendshipDegree"` // 登陆用户的主播守护徽章的亲密度
	UserRank             string          `json:"userRank"`             // 登陆用户的主播守护徽章的排名
}

MedalRankList 就是主播守护徽章等级列表

func GetMedalRankList

func GetMedalRankList(uid int64, deviceID string) (medalRankList *MedalRankList, e error)

GetMedalRankList 返回uid指定主播的守护榜(守护徽章亲密度排名前50名的用户),可用于获取指定主播的守护徽章名字

type Option

type Option func(*AcFunLive)

Option 就是AcFunLive的选项

func SetCookies

func SetCookies(cookies Cookies) Option

SetCookies 设置AcFun帐号的cookies

func SetDanmuClient

func SetDanmuClient(client DanmuClient) Option

SetDanmuClient 设置弹幕客户端

func SetLiverUID

func SetLiverUID(uid int64) Option

SetLiverUID 设置主播uid

func SetTokenInfo

func SetTokenInfo(tokenInfo *TokenInfo) Option

SetTokenInfo 设置TokenInfo

type Playback

type Playback struct {
	Duration  int64  `json:"duration"`  // 录播视频时长,单位是毫秒
	URL       string `json:"url"`       // 录播源链接,目前分为阿里云和腾讯云两种,目前阿里云的下载速度比较快
	BackupURL string `json:"backupURL"` // 备份录播源链接
	M3U8Slice string `json:"m3u8Slice"` // m3u8
	Width     int    `json:"width"`     // 录播视频宽度
	Height    int    `json:"height"`    // 录播视频高度
}

Playback 就是直播回放的相关信息

func (*Playback) Distinguish

func (pb *Playback) Distinguish() (aliURL, txURL string)

Distinguish 返回阿里云和腾讯云链接,目前阿里云的下载速度比较快

type PushConfig

type PushConfig struct {
	StreamName        string   `json:"streamName"`        // 直播源名字(ID)
	StreamPullAddress string   `json:"streamPullAddress"` // 拉流地址,也就是直播源地址
	StreamPushAddress []string `json:"streamPushAddress"` // 推流地址,目前分为阿里云和腾讯云两种
	Panoramic         bool     `json:"panoramic"`         // 是否全景直播
	Interval          int64    `json:"interval"`          // 查询转码信息的时间间隔,单位为毫秒
	RTMPServer        string   `json:"rtmpServer"`        // RTMP服务器
	StreamKey         string   `json:"streamKey"`         // 直播码/串流密钥
}

PushConfig 就是推流设置

type Redpack

type Redpack struct {
	UserInfo           `json:"userInfo"`    // 发红包的用户
	DisplayStatus      RedpackDisplayStatus `json:"displayStatus"`      // 红包的状态
	GrabBeginTime      int64                `json:"grabBeginTime"`      // 开始抢红包的时间,是以毫秒为单位的Unix时间
	GetTokenLatestTime int64                `json:"getTokenLatestTime"` // 抢红包的用户获得token的最晚时间?是以毫秒为单位的Unix时间
	RedpackID          string               `json:"redpackID"`          // 红包ID
	RedpackBizUnit     string               `json:"redpackBizUnit"`     // "ztLiveAcfunRedpackGift"代表的是观众,"ztLiveAcfunRedpackAuthor"代表的是主播?
	RedpackAmount      int64                `json:"redpackAmount"`      // 红包的总价值,单位是AC币
	SettleBeginTime    int64                `json:"settleBeginTime"`    // 抢红包的结束时间,是以毫秒为单位的Unix时间
}

Redpack 红包信息

type RedpackDisplayStatus

type RedpackDisplayStatus int32

RedpackDisplayStatus 红包状态

const (
	// RedpackShow 红包出现?
	RedpackShow RedpackDisplayStatus = iota
	// RedpackGetToken 可以获取红包token?
	RedpackGetToken
	// RedpackGrab 可以抢红包
	RedpackGrab
)

type RichText

type RichText struct {
	SendTime int64             `json:"sendTime"` // 富文本的发送时间,是以毫秒为单位的Unix时间,可能为0
	Segments []RichTextSegment `json:"segments"` // 富文本各部分,类型是RichTextUserInfo、RichTextPlain或RichTextImage
}

RichText 富文本,目前是用于发红包和抢红包的相关消息

func (*RichText) GetSendTime

func (d *RichText) GetSendTime() int64

GetSendTime 获取弹幕发送时间

func (*RichText) GetUserInfo

func (d *RichText) GetUserInfo() *UserInfo

GetUserInfo 获取弹幕的用户信息,返回第一个RichTextUserInfo的UserInfo,否则返回nil

type RichTextImage

type RichTextImage struct {
	Pictures         []string `json:"pictures"`         // 图片
	AlternativeText  string   `json:"alternativeText"`  // 可选的文本?
	AlternativeColor string   `json:"alternativeColor"` // 可选的文本颜色?
}

RichTextImage 富文本里的图片

func (*RichTextImage) RichTextType

func (*RichTextImage) RichTextType() string

RichTextType 返回RichText的类型,也就是 "RichTextImage"

type RichTextPlain

type RichTextPlain struct {
	Text  string `json:"text"`  // 文字
	Color string `json:"color"` // 文字的颜色
}

RichTextPlain 富文本里的文字

func (*RichTextPlain) RichTextType

func (*RichTextPlain) RichTextType() string

RichTextType 返回RichText的类型,也就是 "RichTextPlain"

type RichTextSegment

type RichTextSegment interface {
	RichTextType() string
}

RichTextSegment 副文本片段的接口

type RichTextUserInfo

type RichTextUserInfo struct {
	UserInfo `json:"userInfo"`
	Color    string `json:"color"` // 用户信息的颜色
}

RichTextUserInfo 富文本里的用户信息

func (*RichTextUserInfo) RichTextType

func (*RichTextUserInfo) RichTextType() string

RichTextType 返回RichText的类型,也就是 "RichTextUserInfo"

type ShareLive

type ShareLive struct {
	DanmuCommon       `json:"danmuInfo"`
	SharePlatform     SharePlatformType `json:"sharePlatform"`     // 将直播间分享到的平台
	SharePlatformIcon string            `json:"sharePlatformIcon"` // 将直播间分享到的平台的图标
}

ShareLive 用户分享直播间

func (*ShareLive) GetSendTime

func (d *ShareLive) GetSendTime() int64

GetSendTime 获取弹幕发送时间

func (*ShareLive) GetUserInfo

func (d *ShareLive) GetUserInfo() *UserInfo

GetUserInfo 获取弹幕的用户信息

type SharePlatformType

type SharePlatformType int32

SharePlatformType 就是分享的平台类型

const (
	// PlatformUnknown 未知平台
	PlatformUnknown SharePlatformType = iota
	// PlatformQQ 分享给QQ好友或群
	PlatformQQ
	// PlatformQzone 分享到QQ空间
	PlatformQzone
	// PlatformWeibo 分享到新浪微博?
	PlatformWeibo
	// PlatformWeChat 分享给微信好友或群
	PlatformWeChat
	// PlatformWeChatMoments 分享到微信朋友圈
	PlatformWeChatMoments
	// PlatformAcFunMoment 分享到AcFun动态
	PlatformAcFunMoment
)

type SoundConfigChangeType

type SoundConfigChangeType int32

SoundConfigChangeType 声音设置更改的类型

const (
	// SoundConfigChangeUnknown 未知的声音设置更改的类型
	SoundConfigChangeUnknown SoundConfigChangeType = iota
	// SoundConfigChangeOpenSound 打开声音
	SoundConfigChangeOpenSound
	// SoundConfigChangeCloseSound 关闭声音
	SoundConfigChangeCloseSound
)

type StopPushInfo

type StopPushInfo struct {
	Duration  int64  `json:"duration"`  // 直播时长,单位为毫秒
	EndReason string `json:"endReason"` // 停止直播的原因
}

StopPushInfo 停止直播返回的信息

type StreamInfo

type StreamInfo struct {
	LiveID        string      `json:"liveID"`        // 直播ID
	Title         string      `json:"title"`         // 直播间标题
	LiveStartTime int64       `json:"liveStartTime"` // 直播开始的时间,是以毫秒为单位的Unix时间
	Panoramic     bool        `json:"panoramic"`     // 是否全景直播
	StreamList    []StreamURL `json:"streamList"`    // 直播源列表
	StreamName    string      `json:"streamName"`    // 直播源名字(ID)
}

StreamInfo 就是直播的直播源信息

type StreamURL

type StreamURL struct {
	URL         string `json:"url"`         // 直播源链接
	Bitrate     int    `json:"bitrate"`     // 直播源码率,不一定是实际码率
	QualityType string `json:"qualityType"` // 直播源类型,一般是"SMOOTH"、"STANDARD"、"HIGH"、"SUPER"、"BLUE_RAY"
	QualityName string `json:"qualityName"` // 直播源类型的中文名字,一般是"流畅"、"高清"、"超清"、"蓝光 4M"、"蓝光 5M"、"蓝光 6M"、"蓝光 7M"、"蓝光 8M"
}

StreamURL 就是直播源相关信息

type SubConfig

type SubConfig struct {
	Title     string `json:"title"`     // 字幕标题
	PlayResX  int    `json:"playResX"`  // 视频分辨率
	PlayResY  int    `json:"playResY"`  // 视频分辨率
	FontSize  int    `json:"fontSize"`  // 字体大小
	StartTime int64  `json:"startTime"` // 直播录播开始的时间,是以纳秒为单位的Unix时间
}

SubConfig 是字幕的详细设置

type Summary

type Summary struct {
	Duration     int64  `json:"duration"`     // 直播时长,单位为毫秒
	LikeCount    string `json:"likeCount"`    // 点赞总数
	WatchCount   string `json:"watchCount"`   // 观看过直播的人数总数
	GiftCount    int    `json:"giftCount"`    // 直播收到的付费礼物数量
	DiamondCount int    `json:"diamondCount"` // 主播收到的实际钻石数量(扣除平台相关费用),100钻石=1AC币
	BananaCount  int    `json:"bananaCount"`  // 直播收到的香蕉数量
}

Summary 就是直播的总结信息

type TCPDanmuClient

type TCPDanmuClient struct {
	// contains filtered or unexported fields
}

TCPDanmuClient 使用TCP连接的弹幕客户端

func (*TCPDanmuClient) Close

func (client *TCPDanmuClient) Close(message string) error

Close 关闭连接

func (*TCPDanmuClient) Dial

func (client *TCPDanmuClient) Dial(address string) error

Dial 连接弹幕服务器,address是地址

func (*TCPDanmuClient) NewDanmuClient

func (client *TCPDanmuClient) NewDanmuClient() DanmuClient

NewDanmuClient 返回新的TCPDanmuClient

func (*TCPDanmuClient) Read

func (client *TCPDanmuClient) Read(p []byte) (n int, err error)

Read 读数据

func (*TCPDanmuClient) Type

func (client *TCPDanmuClient) Type() DanmuClientType

Type 返回弹幕客户端类型TCPDanmuClientType

func (*TCPDanmuClient) Write

func (client *TCPDanmuClient) Write(p []byte) (n int, err error)

Write 写数据

type ThrowBanana

type ThrowBanana struct {
	DanmuCommon `json:"danmuInfo"`
	BananaCount int `json:"bananaCount"` // 投蕉数量
}

ThrowBanana 用户投蕉的弹幕,没有Avatar、Medal和ManagerType,现在基本不用这个,通常用Gift代替

func (*ThrowBanana) GetSendTime

func (d *ThrowBanana) GetSendTime() int64

GetSendTime 获取弹幕发送时间

func (*ThrowBanana) GetUserInfo

func (d *ThrowBanana) GetUserInfo() *UserInfo

GetUserInfo 获取弹幕的用户信息

type TokenInfo

type TokenInfo struct {
	UserID       int64   `json:"userID"`       // 登陆模式或游客模式的uid
	SecurityKey  string  `json:"securityKey"`  // 密钥,第一次发送ws信息时用
	ServiceToken string  `json:"serviceToken"` // 令牌
	DeviceID     string  `json:"deviceID"`     // 设备ID
	Cookies      Cookies `json:"cookies"`      // AcFun帐号的cookies
}

TokenInfo 就是AcFun直播的token相关信息

func GetTokenInfo

func GetTokenInfo(cookies Cookies) (*TokenInfo, error)

GetTokenInfo 返回TokenInfo,cookies可以利用Login()获取,为nil时为游客模式

type TopUser

type TopUser WatchingUser

TopUser 就是礼物榜在线前三,目前没有Medal和ManagerType

type TranscodeInfo

type TranscodeInfo struct {
	StreamURL  `json:"streamURL"`
	Resolution string `json:"resolution"` // 直播视频分辨率
	FrameRate  int    `json:"frameRate"`  // 直播视频FPS?
	Template   string `json:"template"`   // 直播模板?
}

TranscodeInfo 就是转码信息

type UserInfo

type UserInfo struct {
	UserID      int64       `json:"userID"`      // 用户uid
	Nickname    string      `json:"nickname"`    // 用户名字
	Avatar      string      `json:"avatar"`      // 用户头像
	Medal       MedalInfo   `json:"medal"`       // 用户正在佩戴的守护徽章
	ManagerType ManagerType `json:"managerType"` // 用户是否房管
}

UserInfo 就是用户信息

func NewUserInfo

func NewUserInfo(userInfo *acproto.ZtLiveUserInfo) *UserInfo

NewUserInfo 创建UserInfo

type UserLiveInfo

type UserLiveInfo struct {
	Profile               UserProfile `json:"profile"`               // 用户信息
	LiveType              LiveType    `json:"liveType"`              // 直播分类
	LiveID                string      `json:"liveID"`                // 直播ID
	StreamName            string      `json:"streamName"`            // 直播源名字(ID)
	Title                 string      `json:"title"`                 // 直播间标题
	LiveStartTime         int64       `json:"liveStartTime"`         // 直播开始的时间,是以毫秒为单位的Unix时间
	Portrait              bool        `json:"portrait"`              // 是否手机直播
	Panoramic             bool        `json:"panoramic"`             // 是否全景直播
	LiveCover             string      `json:"liveCover"`             // 直播间封面
	OnlineCount           int         `json:"onlineCount"`           // 直播间在线人数
	LikeCount             int         `json:"likeCount"`             // 直播间点赞总数
	HasFansClub           bool        `json:"hasFansClub"`           // 主播是否有守护团
	DisableDanmakuShow    bool        `json:"disableDanmakuShow"`    // 是否禁止显示弹幕?
	PaidShowUserBuyStatus bool        `json:"paidShowUserBuyStatus"` // 登陆帐号是否购买了付费直播?
}

UserLiveInfo 就是用户直播信息

func GetAllLiveList

func GetAllLiveList(deviceID string) ([]UserLiveInfo, error)

GetAllLiveList 返回全部正在直播的直播间列表

func GetLiveList

func GetLiveList(count, page int, deviceID string) (liveList []UserLiveInfo, lastPage bool, err error)

GetLiveList 返回正在直播的直播间列表,count为每页的直播间数量,page为第几页(从0开始数起),lastPage说明是否最后一页

func GetUserLiveInfo

func GetUserLiveInfo(uid int64, deviceID string) (*UserLiveInfo, error)

GetUserLiveInfo 返回uid指定用户的直播信息,可能会出现超时等各种网络原因的错误

type UserMedalInfo

type UserMedalInfo struct {
	UserProfile      `json:"profile"`
	FriendshipDegree int `json:"friendshipDegree"` // 用户守护徽章的亲密度
	Level            int `json:"level"`            // 用户守护徽章的等级
}

UserMedalInfo 就是用户的守护徽章信息

type UserProfile

type UserProfile struct {
	UserID          int64  `json:"userID"`          // 用户uid
	Nickname        string `json:"nickname"`        // 用户名字
	Avatar          string `json:"avatar"`          // 用户头像
	AvatarFrame     string `json:"avatarFrame"`     // 用户头像挂件
	FollowingCount  int    `json:"followingCount"`  // 用户关注数量
	FansCount       int    `json:"fansCount"`       // 用户粉丝数量
	ContributeCount int    `json:"contributeCount"` // 用户投稿数量
	Signature       string `json:"signature"`       // 用户签名
	VerifiedText    string `json:"verifiedText"`    // 用户认证信息
	IsJoinUpCollege bool   `json:"isJoinUpCollege"` // 用户是否加入阿普学院
	IsFollowing     bool   `json:"isFollowing"`     // 登陆帐号是否关注了用户
	IsFollowed      bool   `json:"isFollowed"`      // 用户是否关注了登陆帐号
}

UserProfile 就是用户信息

type UserProfileInfo

type UserProfileInfo struct {
	UserID          int64  `json:"userID"`          // 用户uid
	Nickname        string `json:"nickname"`        // 用户名字
	Avatar          string `json:"avatar"`          // 用户头像
	AvatarFrame     string `json:"avatarFrame"`     // 用户头像挂件
	FollowingCount  string `json:"followingCount"`  // 用户关注数量
	FansCount       string `json:"fansCount"`       // 用户粉丝数量
	ContributeCount string `json:"contributeCount"` // 用户投稿数量
	Signature       string `json:"signature"`       // 用户签名
	VerifiedText    string `json:"verifiedText"`    // 用户认证信息
	IsJoinUpCollege bool   `json:"isJoinUpCollege"` // 用户是否加入阿普学院
	IsFollowing     bool   `json:"isFollowing"`     // 登陆帐号是否关注了用户
	IsFollowed      bool   `json:"isFollowed"`      // 用户是否关注了登陆帐号
	LiveID          string `json:"liveID"`          // 直播ID
	LikeCount       int    `json:"likeCount"`       // 最近一次直播的点赞总数
}

UserProfileInfo 就是用户信息

func GetUserInfo

func GetUserInfo(uid int64, deviceID string) (*UserProfileInfo, error)

GetUserInfo 返回uid指定用户的信息

type WatchingUser

type WatchingUser struct {
	UserInfo          `json:"userInfo"`
	AnonymousUser     bool   `json:"anonymousUser"`     // 是否匿名用户
	DisplaySendAmount string `json:"displaySendAmount"` // 赠送的全部礼物的价值,单位是AC币,注意不一定是纯数字的字符串
	CustomData        string `json:"customData"`        // 用户的一些额外信息,格式为json
}

WatchingUser 就是观看直播的用户的信息,目前没有Medal

type WebSocketDanmuClient

type WebSocketDanmuClient struct {
	// contains filtered or unexported fields
}

WebSocketDanmuClient 使用WebSocket连接的弹幕客户端

func (*WebSocketDanmuClient) Close

func (client *WebSocketDanmuClient) Close(message string) error

Close 关闭连接

func (*WebSocketDanmuClient) Dial

func (client *WebSocketDanmuClient) Dial(address string) error

Dial 连接弹幕服务器,address是地址

func (*WebSocketDanmuClient) NewDanmuClient

func (client *WebSocketDanmuClient) NewDanmuClient() DanmuClient

NewDanmuClient 返回新的WebSocketDanmuClient

func (*WebSocketDanmuClient) Read

func (client *WebSocketDanmuClient) Read(p []byte) (n int, err error)

Read 读数据

func (*WebSocketDanmuClient) Type

func (client *WebSocketDanmuClient) Type() DanmuClientType

Type 返回弹幕客户端类型WebSocketDanmuClientType

func (*WebSocketDanmuClient) Write

func (client *WebSocketDanmuClient) Write(p []byte) (n int, err error)

Write 写数据

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL