wxchannels

package module
v0.0.0-...-7832c53 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

README

微信视频号后端接口模拟

视频号后端接口模拟,用于获取直播数据与回放地址下载

补充测试用例

需要设置环境变量 wxuin 与 sessionid 用于真实环境登录

1. 直播回放视频列表

go test -v -run TestGetLiveReplayPostList

2. 直播记录

go test -v -run TestGetLiveReplayList

3. 直播单场数据

go test -v -run TestGetLiveHistory

4. 直播回放生成

objId="" liveId="" go test -v -run TestLiveCreateReplay

5. 设置直播回放可见范围

objId="" go test -v -run TestLiveUpdateVisible

Documentation

Index

Constants

View Source
const (
	WX_VIDEO_ADMIN_HOST                    = `https://channels.weixin.qq.com`
	WX_VIDEO_ADMIN_URI_REPLAY_LIST         = `/micro/live/cgi-bin/mmfinderassistant-bin/live/get_live_replay_list_v2`            //直播记录
	WX_VIDEO_ADMIN_URI_REPLAY_FRAGMENT     = `/micro/live/cgi-bin/mmfinderassistant-bin/live/get_live_replay_wonderful_fragment` //直播回放详情,用于获取视频下载地址
	WX_VIDEO_ADMIN_URI_REPLAY_CREATE       = `/micro/live/cgi-bin/mmfinderassistant-bin/live/set_live_mod_replay`                // 创建回放
	WX_VIDEO_ADMIN_URI_LIVE_HISTORY        = `/micro/statistic/cgi-bin/mmfinderassistant-bin/live/get_live_history`              //获取直播单场数据
	WX_VIDEO_ADMIN_URI_POST_UPDATE_VISIBLE = `/micro/live/cgi-bin/mmfinderassistant-bin/post/post_update_visible`                // 更新视频号回放可见范围
	WX_VIDEO_ADMIN_URI_REPLAY_POST_LIST    = `/micro/live/cgi-bin/mmfinderassistant-bin/post/post_list`                          //获取直播回放视频

	WX_VIDEO_ADMIN_REPLAY_CREATE_SUCCESS = 3 //回访创建成功
	WX_ADMIN_SCENE_DEFAULT               = 7
	WX_ADMIN_REPLAY_INFO_FRAGMENT_DOWN   = 0 //所有视频分片都已处理成功
)
View Source
const (
	UA_MAC_FIREFOX = `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36`
)

Variables

This section is empty.

Functions

This section is empty.

Types

type LiveReplayPostListObject

type LiveReplayPostListObject struct {
	CreatetimeUnix int64  `json:"createTime"` //回放生成时间
	ExportId       string `json:"exportId"`
	ObjectId       string `json:"objectId"`
	LiveObjectId   string `json:"liveObjectId"`
	VisibleType    int64  `json:"visibleType"` //可见类型, 3: 仅自己可见
	Status         int64  `json:"status"`      //状态
}

type ReqLiveHistoryList

type ReqLiveHistoryList struct {
	ReqScene          int32  `json:"reqScene"` // reqScene、scene 默认都是7
	Scene             int32  `json:"scene"`
	ReqType           int32  `json:"reqType"` //默认2
	UxTimesStart      int64  `json:"filterStartTime"`
	UxTimesEnd        int64  `json:"filterEndTime"`
	PageIndex         int32  `json:"currentPage"` //从1开始
	PageSize          int32  `json:"pageSize"`
	TimestampUixMilli string `json:"timestamp"`
	// contains filtered or unexported fields
}

func NewReqLiveHistoryList

func NewReqLiveHistoryList(pageIndex, pageSize int32) ReqLiveHistoryList

type ReqLivePlayInfo

type ReqLivePlayInfo struct {
	ObjectId          string `json:"objectId"`
	ReqScene          int32  `json:"reqScene"` // reqScene、scene 默认都是7
	Scene             int32  `json:"scene"`
	TimestampUixMilli string `json:"timestamp"`
	// contains filtered or unexported fields
}

func NewReqLiveReplayInfo

func NewReqLiveReplayInfo(id string) ReqLivePlayInfo

type ReqLiveReplayList

type ReqLiveReplayList struct {
	TimeFilter        ReqTimeFilter `json:"reqFilter"` //默认是0
	PageFilter        ReqPage       `json:"reqPage"`
	ReqScene          int32         `json:"reqScene"` // reqScene、scene 默认都是7
	Scene             int32         `json:"scene"`
	TimestampUixMilli string        `json:"timestamp"`
	// contains filtered or unexported fields
}

func NewReqLiveReplayList

func NewReqLiveReplayList(pageIndex, pageSize int32) ReqLiveReplayList

type ReqLiveReplayPostList

type ReqLiveReplayPostList struct {
	ReqScene          int32  `json:"reqScene"` // reqScene、scene 默认都是7
	Scene             int32  `json:"scene"`
	UserpageType      int32  `json:"userpageType"` //默认5
	PageIndex         int32  `json:"currentPage"`  //当前页面
	PageSize          int32  `json:"pageSize"`     //每页数量
	TimestampUixMilli string `json:"timestamp"`
	// contains filtered or unexported fields
}

func NewReqLiveReplayPostList

func NewReqLiveReplayPostList(pageIndex, pageSize int32) ReqLiveReplayPostList

type ReqLiveReplayPostUpdateVisible

type ReqLiveReplayPostUpdateVisible struct {
	ReqScene          int32  `json:"reqScene"` // reqScene、scene 默认都是7
	Scene             int32  `json:"scene"`
	ObjectId          string `json:"objectId"`    //导出任务ID
	VisibleType       int64  `json:"visibleType"` //可见类型, 3: 仅自己可见
	TimestampUixMilli string `json:"timestamp"`
	// contains filtered or unexported fields
}

func NewReqLiveReplayPostUpdateVisible

func NewReqLiveReplayPostUpdateVisible(objectId string) ReqLiveReplayPostUpdateVisible

type ReqLiveSetReplay

type ReqLiveSetReplay struct {
	EnableDumpDanmu   int64  `json:"enableDumpDanmu"` //是否导出弹幕 1:是,0:否
	EnableReplay      int64  `json:"enableReplay"`    //是否生成回放 1:是,0:否
	LiveId            string `json:"liveId"`
	ObjectId          string `json:"objectId"`
	ReqScene          int32  `json:"reqScene"` // reqScene、scene 默认都是7
	Scene             int32  `json:"scene"`
	TimestampUixMilli string `json:"timestamp"`
	// contains filtered or unexported fields
}

func NewReqLiveSetReplay

func NewReqLiveSetReplay(liveId, objectId string) ReqLiveSetReplay

type ReqPage

type ReqPage struct {
	Index int32 `json:"pageIndex"` //当前位置,从1开始
	Size  int32 `json:"pageSize"`  //分页大小
}

type ReqTimeFilter

type ReqTimeFilter struct {
	Begin string `json:"startTimeBegin"` //都是timestamp
	End   string `json:"startTimeEnd"`
}

type RespLiveCommon

type RespLiveCommon struct {
	PluginSessionId *string     `json:"pluginSessionId"`
	RawKeyBuff      *string     `json:"rawKeyBuff"`
	Code            int32       `json:"errCode"`
	Msg             string      `json:"errMsg"`
	Data            interface{} `json:"data"`
}

func (RespLiveCommon) UnMarshalData

func (d RespLiveCommon) UnMarshalData(out any) (err error)

type RespLiveHistoryItem

type RespLiveHistoryItem struct {
	LiveObjectId       string             `json:"liveObjectId"`
	LiveData           RespLiveObjectStat `json:"liveStats"`
	Description        string             `json:"description"` //直播标题
	UxCreateTime       int64              `json:"createTime"`
	MaxOnlineCount     int64              `json:"maxOnlineCount"`     //最大在线人数
	AuthorReplayStatus int64              `json:"authorReplayStatus"` //直播回放状态: 20:已生成, 0: 未生成状态
}

type RespLiveHistoryList

type RespLiveHistoryList struct {
	TotalCount *int32                `json:"totalLiveCount"`
	Items      []RespLiveHistoryItem `json:"liveObjectList"`
}

type RespLiveObject

type RespLiveObject struct {
	LiveId           string              `json:"liveId"`
	ChargeType       int32               `json:"chargeType"` //收费类型
	DurationSecs     int64               `json:"duration"`
	ObjectId         string              `json:"objectId"`
	Media            RespLiveObjectMedia `json:"media"`
	ReplayCreateTime string              `json:"replayCreateTime"` //回放创建时间
	ReplayStatus     int32               `json:"replayStatus"`     //回放状态 1: 可以生成 2:生成中 3: 已生成
	StartTime        string              `json:"startTime"`        //开播时间
}

type RespLiveObjectMedia

type RespLiveObjectMedia struct {
	Description    string `json:"description"`
	OriginCoverUrl string `json:"originCoverUrl"`
	ThumbUrl       string `json:"thumbUrl"`
}

type RespLiveObjectStat

type RespLiveObjectStat struct {
	LiveDurationInSeconds int64 `json:"liveDurationInSeconds"`
	TotalAudienceCount    int64 `json:"totalAudienceCount"`
}

type RespLivePlayInfo

type RespLivePlayInfo struct {
	CreatetimeUnix         int64  `json:"createtime"`
	Description            string `json:"description"`
	DurationSeconds        int64  `json:"duration"`
	Height                 int64  `json:"height"`
	Width                  int64  `json:"width"`
	HlsUri                 string `json:"hlsUrl"`
	ReplayUri              string `json:"replayUrl"`
	ThumbUri               string `json:"thumbUrl"` //封面
	FragmentStatus         int64  `json:"wonderfulFragmentStatus"`
	EnableReplayInUserpage *int64 `json:"enableReplayInUserpage"` // 1: 允许在用户主页展示。如何是已设置仅在用户中心展示,默认不会有该字段

}

func (RespLivePlayInfo) GetQa

func (d RespLivePlayInfo) GetQa() (qa string, err error)

func (RespLivePlayInfo) IsReadyForDownload

func (d RespLivePlayInfo) IsReadyForDownload() bool

是否已准备好

type RespLiveReplayList

type RespLiveReplayList struct {
	TotalCount *int32           `json:"totalCount"`
	LivePlays  []RespLiveObject `json:"replayObjects"`
}

type RespLiveReplayPostList

type RespLiveReplayPostList struct {
	TotalCount *int32                     `json:"totalCount"`
	Posts      []LiveReplayPostListObject `json:"list"`
}

type WxChannelLiveAdmin

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

腾讯视频号助手管理端相关接口

func NewWxChannelLiveAdmin

func NewWxChannelLiveAdmin(logger log.Logger) *WxChannelLiveAdmin

func (*WxChannelLiveAdmin) GetLiveHistory

func (r *WxChannelLiveAdmin) GetLiveHistory(req ReqLiveHistoryList) (res []RespLiveHistoryItem, allCount int32, err error)

func (*WxChannelLiveAdmin) GetLiveReplayInfo

func (r *WxChannelLiveAdmin) GetLiveReplayInfo(req ReqLivePlayInfo) (info RespLivePlayInfo, err error)

获取回放下载地址

func (*WxChannelLiveAdmin) GetLiveReplayList

func (r *WxChannelLiveAdmin) GetLiveReplayList(req ReqLiveReplayList) (livePlays []RespLiveObject, allCount int32, err error)

获取直播回放列表,注意返回结果中会从全部结果中过滤部分造成返回数据与总的数据量对不上

func (*WxChannelLiveAdmin) GetLiveReplayPostList

func (r *WxChannelLiveAdmin) GetLiveReplayPostList(req ReqLiveReplayPostList) (livePlays []LiveReplayPostListObject, allCount int32, err error)

直播回放视频

func (*WxChannelLiveAdmin) GetReqClient

func (b *WxChannelLiveAdmin) GetReqClient(_headers map[string]string) *req.Client

func (*WxChannelLiveAdmin) GetUADefault

func (b *WxChannelLiveAdmin) GetUADefault() string

func (*WxChannelLiveAdmin) GetWxChannelAccount

func (r *WxChannelLiveAdmin) GetWxChannelAccount() WxLiveAccount

func (*WxChannelLiveAdmin) LiveCreateReplay

func (r *WxChannelLiveAdmin) LiveCreateReplay(req ReqLiveSetReplay) (err error)

func (*WxChannelLiveAdmin) LiveUpdateVisible

func (r *WxChannelLiveAdmin) LiveUpdateVisible(req ReqLiveReplayPostUpdateVisible) (err error)

func (*WxChannelLiveAdmin) LoginAccount

func (r *WxChannelLiveAdmin) LoginAccount(cs []*http.Cookie) (err error)

func (*WxChannelLiveAdmin) SetAdminCookie

func (b *WxChannelLiveAdmin) SetAdminCookie(cs []*http.Cookie) (err error)

func (*WxChannelLiveAdmin) SetUa

func (b *WxChannelLiveAdmin) SetUa(ua string)

type WxLiveAccount

type WxLiveAccount struct {
	Uid             string // finderUsername,长字符串
	Nickname        string
	Avatar          string
	XAuthHeaderUin  string //登录人微信账号ID
	UniqId          string //视频号ID,后台可见
	FansCount       int64  //粉丝数
	AuthCompanyName string //认证公司名
}

支持函数: LoginAccount, GetLiveReplayList ,GetLiveReplayInfo ,GetLiveReplayPostList

func (WxLiveAccount) GetHeaderWechatUin

func (d WxLiveAccount) GetHeaderWechatUin() string

Jump to

Keyboard shortcuts

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