goacfun

package module
v0.0.0-...-11fa8aa Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2024 License: GPL-3.0 Imports: 19 Imported by: 0

README

acfun-API-Go版本

本项目是基于Go语言编写的acfun API调用。

本项目不会编写单元测试代码。一则因为各项数据会频繁变动,难以写成固定的结果;二则因为每次单元测试都要大量请求A站API,会对其产生不必要的压力。 如果你发现有接口bug或者有你需要但是本库尚未实现的接口,可以提交issue或者提交pull request。 如果因为A站修改了接口导致接口突然不可用,不一定能够及时更新,很大程度上需要依赖各位的告知。

如果你觉得本项目对你有帮助,点亮右上角的↗ ⭐ 不迷路

声明

  1. 本项目遵守 AGPL 开源协议。
  2. 禁止一切商业使用。
  3. 请勿滥用,本项目仅用于学习和测试!利用本项目提供的接口、文档等造成不良影响及后果与本人无关。
  4. 由于本项目的特殊性,可能随时停止开发或删档
  5. 本项目为开源项目,不接受任何形式的催单和索取行为,更不容许存在付费内容

Documentation

Index

Constants

View Source
const (
	QRURL = "https://scan.acfun.cn/rest/pc-direct/qr/"
)
View Source
const (
	UploadEndpoint = "https://mediacloud.kuaishou.com/api/upload/fragment"
)

Variables

This section is empty.

Functions

func GetFileInfo

func GetFileInfo(path string) (os.FileInfo, error)

Types

type BuyParam

type BuyParam struct {
	// 对应上面的产品 ID
	ProductId uint64 `request:"query"`
	Count     uint16 `request:"query,default=1"`
	// 1香蕉,2金香蕉 除了AC药丸都是金香蕉了
	PayType uint8 `request:"query,default=2"`
	// 收货人姓名
	Name string `request:"query"`
	//手机号码
	Tel string `request:"query"`
	// 地址
	Address string `request:"query"`
	// 备注
	Remark string `request:"query"`
}

type ChannelList

type ChannelList struct {
	Children []struct {
		// 视频 type 2返回没 Realms 字段
		Realms []struct {
			Introduction string `json:"introduction"`
			RealmID      string `json:"realmId"`
			RealmName    string `json:"realmName"`
		} `json:"realms"`
		ChannelID   string `json:"channelId"`
		ChannelType uint8  `json:"channelType"`
		Name        string `json:"name"`
	} `json:"children"`
	ChannelID   string `json:"channelId"`
	ChannelType uint8  `json:"channelType"`
	Name        string `json:"name"`
}

type Client

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

func New

func New() (*Client, error)

func NewWithClient

func NewWithClient(restyClient *resty.Client) (*Client, error)

func (*Client) BuyProduct

func (c *Client) BuyProduct(param *BuyParam) (*CommonResult, error)

func (*Client) Comment

func (c *Client) Comment(param CommentParam) (*CommentResult, error)

func (*Client) CreateArticle

func (c *Client) CreateArticle(param CreateArticleParam) (uint64, error)

文章区投稿

func (*Client) DeleteComment

func (c *Client) DeleteComment(param CommentParam) (*CommonResult, error)

func (*Client) GetChannelList

func (c *Client) GetChannelList(ChannelType uint8) ([]ChannelList, error)

列出分区 1是文章区 2是视频 0是老文章区list

func (*Client) GetContributeList

func (c *Client) GetContributeList(param GetUserContributeListParam) (*ContributeListResult, error)

查询视频和文章投稿,可指定用户,指定类型

func (*Client) GetCookies

func (c *Client) GetCookies() []*http.Cookie

GetCookies 获取当前的cookies

func (*Client) GetCookiesString

func (c *Client) GetCookiesString() string

GetCookiesString 获取字符串格式的cookies,方便自行存储后下次使用。配合下面的 SetCookiesString 使用。

func (*Client) GetOrderList

func (c *Client) GetOrderList(pageNo, pageSize int) (*OrderList, error)

列出我的订单

func (*Client) GetPersonalInfo

func (c *Client) GetPersonalInfo(uid ...uint64) (*UserInfo, error)

GetPersonalInfo获取用户信息

func (*Client) GetProductList

func (c *Client) GetProductList(pageNo, pageSize int) (*ProductListResult, error)

列出香蕉商城

func (*Client) GetQRCode

func (c *Client) GetQRCode() (*QRCode, error)

GetQRCode 申请二维码

func (*Client) GetUID

func (c *Client) GetUID() uint64

从 cookie 里获取 uid

func (*Client) LoginWithPassword

func (c *Client) LoginWithPassword(param LoginWithPasswordParam) (*LoginWithPasswordResult, error)

LoginWithPassword 账号密码登录,其中validate, seccode字段需要在极验人机验证后获取

func (*Client) LoginWithQRCode

func (c *Client) LoginWithQRCode(QRinfo QRCode) error

func (*Client) Resty

func (c *Client) Resty() *resty.Client

func (*Client) SetCookies

func (c *Client) SetCookies(cookies []*http.Cookie)

SetCookies 设置cookies

func (*Client) SetCookiesString

func (c *Client) SetCookiesString(cookiesString string)

SetCookiesString 设置Cookies,但是是字符串格式,配合 GetCookiesString 使用。有些功能必须登录或设置Cookies后才能使用。

func (*Client) SetRawCookies

func (c *Client) SetRawCookies(rawCookies string)

SetRawCookies 如果你是从浏览器request的header中直接复制出来的cookies,调用这个函数。

func (*Client) ThrowBanana

func (c *Client) ThrowBanana(param ThrowBananaParam) (uint8, error)

投蕉

func (*Client) UploadPic

func (c *Client) UploadPic(picPath string) (string, error)

type CommentParam

type CommentParam struct {
	// 对应上面的产品 ID
	SourceId uint64 `request:"query,field=sourceId"`
	// 评论类型
	SourceType uint8 `request:"query,field=sourceType,default=3"`
	// 内容,为空给删除评论参数使用
	Content string `request:"query,field=content,omitempty"`
	// 回复指定评论
	ReplyToId uint64 `request:"query,field=replyToCommentId"`
}

type CommentResult

type CommentResult struct {
	SourceID uint64 `json:"sourceId"`
	// HeadURL  []struct {
	// 	Cdn        string `json:"cdn"`
	// 	URL        string `json:"url"`
	// 	URLPattern string `json:"urlPattern"`
	// } `json:"headUrl"`
	LikeCount int    `json:"likeCount"`
	Content   string `json:"content"`
	// Result            int         `json:"result"`
	IsUp            bool   `json:"isUp"`
	ReplyToUserName string `json:"replyToUserName"`
	// ImageURL          interface{} `json:"imageUrl"`
	// AvatarFrame       int         `json:"avatarFrame"`
	SelfComment bool   `json:"selfComment"`
	Floor       uint64 `json:"floor"`
	// VerifiedText      string `json:"verifiedText"`
	// Timestamp         int64  `json:"timestamp"`
	// NameRed           int    `json:"nameRed"`
	// NameColor         int    `json:"nameColor"`
	// IsSignedUpCollege bool   `json:"isSignedUpCollege"`
	// Verified          int    `json:"verified"`
	// IsLiked           bool   `json:"isLiked"`
	// ContentUbbVersion string `json:"contentUbbVersion"`
	// VerifiedType      int    `json:"verifiedType"`
	// HostName          string `json:"host-name"`
	// UserName          string `json:"userName"`
	// UserID            int    `json:"userId"`
	// 3一般
	SourceType uint8 `json:"sourceType"`
	// VerifiedTypes     []int  `json:"verifiedTypes"`
	// AvatarImage       string `json:"avatarImage"`
	ReplyTo   int    `json:"replyTo"`
	CommentID uint64 `json:"commentId"`
}

type CommonResult

type CommonResult struct {
	Result int    `json:"result"`
	Err    string `json:"error_msg"`
	// https://member.acfun.cn/list/api/queryContributeList 错误会返回下面俩属性
	ErrMsg struct {
		Result   int    `json:"result"`
		ErrorMsg string `json:"error_msg"`
	} `json:"errMsg"`
	IsError bool `json:"isError"`
}

快手的 result 是 1 正常 -401 "user not login"

type Contribute

type Contribute struct {
	GroupID     string `json:"groupId"`
	IsFollowing bool   `json:"isFollowing"`
	// pc android
	SourcePlatform string `json:"sourcePlatform"`
	FansCount      uint   `json:"fansCount"`
	ChannelID      uint   `json:"channelId"`
	// 访问量
	ViewCount    uint64 `json:"viewCount"`
	CommentCount uint   `json:"commentCount"`
	BananaCount  uint   `json:"bananaCount"`
	UserImg      string `json:"userImg"`
	// 和下面 ContentID 一样
	ResourceID int `json:"resourceId"`
	// CONTENT_ARTICLE
	// ResourceType string `json:"resourceType"`
	ChannelName string `json:"channelName"`
	// 稿件ID
	// ContentID int   `json:"contentId"`
	TagList []Tag `json:"tagList"`
	// 就是 uid
	// AuthorID uint64 `json:"authorId"`
	UserID uint64 `json:"userId"`
	// UserHeadImgInfo struct {
	// 	Width          int  `json:"width"`
	// 	Height         int  `json:"height"`
	// 	Size           int  `json:"size"`
	// 	Type           int  `json:"type"`
	// 	Animated       bool `json:"animated"`
	// 	ThumbnailImage struct {
	// 		CdnUrls []struct {
	// 			URL            string `json:"url"`
	// 			FreeTrafficCdn bool   `json:"freeTrafficCdn"`
	// 		} `json:"cdnUrls"`
	// 	} `json:"thumbnailImage"`
	// 	ThumbnailImageCdnURL string `json:"thumbnailImageCdnUrl"`
	// } `json:"userHeadImgInfo"`
	CommentCountTenThousandShow string `json:"commentCountTenThousandShow"`
	// 投稿时间,毫秒时间戳
	ContributeTime uint64 `json:"contributeTime"`
	ContentTitle   string `json:"contentTitle"`
	// 封面
	VideoCover string `json:"videoCover"`
	// 用户个性签名
	UserSignature string `json:"userSignature"`
	// 视频和文章稿件
	ContributionCount uint `json:"contributionCount"`
	// 弹幕数量
	DanmuCount uint64 `json:"danmuCount"`
	UserName   string `json:"userName"`
	// 封面
	CoverImgInfo struct {
		Width          int  `json:"width"`
		Height         int  `json:"height"`
		Size           int  `json:"size"`
		Type           int  `json:"type"`
		Animated       bool `json:"animated"`
		ThumbnailImage struct {
			CdnUrls []struct {
				URL            string `json:"url"`
				FreeTrafficCdn bool   `json:"freeTrafficCdn"`
			} `json:"cdnUrls"`
		} `json:"thumbnailImage"`
		ThumbnailImageCdnURL string `json:"thumbnailImageCdnUrl"`
	} `json:"coverImgInfo"`
	ShareURL         string `json:"shareUrl"`
	ViewCountShow    string `json:"viewCountShow"`
	DanmakuCountShow string `json:"danmakuCountShow"`
	BananaCountShow  string `json:"bananaCountShow"`
	ContentType      int    `json:"contentType"`
	Status           int    `json:"status"`
	Channel          struct {
		ParentID   int    `json:"parentId"`
		ParentName string `json:"parentName"`
		Name       string `json:"name"`
		ID         int    `json:"id"`
	} `json:"channel"`
}

type ContributeListResult

type ContributeListResult struct {
	Feed     []Contribute `json:"feed"`
	TotalNum uint         `json:"totalNum"`
}

type CreateArticleParam

type CreateArticleParam struct {
	// 标题
	Title string
	// 描述
	Description string
	// 内容,{"bodyList":[{"orderId":1,"title":"","txt":"xxx"}]}
	Detail string
	//视频标签,最多4个
	TagNames []string
	// 1转载 3原创
	CreationType uint8

	// RealmID 是 ChannelId 下的子类目,例如 生活下的 爽文/吐槽
	// 频道 86生活娱乐 139音乐-综合音乐 110 综合杂谈/资讯
	ChannelId string
	// 5 13 34
	RealmID string

	// 封面
	CoverURL string
}

func (*CreateArticleParam) Body

func (a *CreateArticleParam) Body() any

type GetUserContributeListParam

type GetUserContributeListParam struct {
	// 前一页数字
	Pcursor uint `json:"pcursor" request:"body,default=0"`

	// 2是视频 3 是文章
	ResourceType uint8 `json:"resourceType" request:"body,default=3"`

	// https://member.acfun.cn/list/api/getSortList 带 resourceType=3 查询
	// 3 最新发布,1 最多阅读, 2 最多香蕉
	SortType uint8  `json:"sortType" request:"body,default=3"`
	AuthorId uint64 `json:"authorId" request:"body"`
	Keyword  string `json:"keyword" request:"body"`
	// 1 已通过 2发布中 3已退回
	Status uint8 `json:"status" request:"body,default=0"`
}

type LoginWithPasswordParam

type LoginWithPasswordParam struct {
	Username string `request:"query,field=username"` // 用户登录账号。手机号或邮箱地址
	Password string `request:"query,field=password"` // 参数传入原密码,下文会自动转为加密后的带盐密码
	Key      string `request:"query,field=key"`      // rsa 公钥。PEM 格式编码。加密密码时需要使用
	Captcha  string `request:"query,field=captcha"`
}

type LoginWithPasswordResult

type LoginWithPasswordResult struct {
	Img      string `json:"img"`
	UserID   uint64 `json:"userId"`
	Username string `json:"username"`
}

type Order

type Order struct {
	Count uint   `json:"count"`
	Name  string `json:"name"`
	// 订单号
	ID string `json:"id"`
	// finish
	State string `json:"state"`
	// 1
	PayType uint8 `json:"payType"`
	// 商品ID
	ProductID uint64 `json:"productId"`
	// 2虚拟
	ProductType uint8 `json:"productType"`
	//Image       string `json:"image"`
	BuyTime int64 `json:"buyTime"`
	// 1香蕉 666金香蕉
	PayAmount string `json:"payAmount"`
}

type OrderList

type OrderList struct {
	// Result uint    `json:"result"`
	Total  uint    `json:"total"`
	Orders []Order `json:"orders"`
}

type Product

type Product struct {
	// 数量
	Amount uint64 `json:"amount"`
	// 销量
	Sales uint64 `json:"sales"`
	// 1为真实需要写地址的商品, 2 为虚拟用品
	Type uint8 `json:"type"`

	CoolDownDay int    `json:"coolDownDay"`
	MaxAllowBuy int    `json:"maxAllowBuy"`
	LevelLimit  uint   `json:"levelLimit"`
	Title       string `json:"title"`
	PriceInfo   []struct {
		// 价格
		Count uint64 `json:"count"`
		// 金香蕉
		PayTypeInfo string `json:"payTypeInfo"`
		// 1是香蕉,2是金香蕉
		PayType uint8 `json:"payType"`
	} `json:"priceInfo"`
	//ImagePCURL  string `json:"imagePCUrl"`
	//ImageAppURL string `json:"imageAppUrl"`
	//ImageURL    string `json:"imageUrl"`
	ProductID uint64 `json:"productId"`
	// 过期时间
	ExpireTime int64 `json:"expireTime"`
	// 1
	Status int `json:"status"`
	// 描述
	Description string `json:"description"`
}

type ProductListResult

type ProductListResult struct {
	// HostName string    `json:"host-name"`
	List     []Product `json:"list"`
	TotalNum uint8     `json:"totalNum"`
	// no_more 或者 字符串数字
	NextPage string `json:"nextPage"`
}

type QRCode

type QRCode struct {
	// 第一次 scanResult 再请求是 acceptResult succ
	Next             string `json:"next" request:"omitempty"`
	ExpireTime       int    `json:"expireTime" request:"omitempty"`
	QrLoginSignature string `json:"qrLoginSignature" request:"query"`
	// 二维码被base64后的字符串
	ImageData    string `json:"imageData" request:"omitempty"`
	QrLoginToken string `json:"qrLoginToken" request:"query"`
	// SCANNED
	Status string `json:"status" request:"omitempty"`
}

func (*QRCode) Print

func (result *QRCode) Print()

Print the QRCode in the console

type Tag

type Tag struct {
	Name string `json:"name"`
	ID   int    `json:"id"`
}

type ThrowBananaParam

type ThrowBananaParam struct {
	ResourceId uint64 `json:"resourceId" request:"body"`
	Count      uint8  `json:"count" request:"body"`
	// 3 文章
	ResourceType uint8 `json:"resourceType" request:"body"`
}

type UploadPart

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

type UserInfo

type UserInfo struct {
	Name       string `json:"userName"`
	Uid        uint64 `json:"userId"`
	Level      uint16 `json:"level"`
	Mobile     string `json:"mobile"`
	Email      string `json:"email"`
	Banana     uint64 `json:"banana"`
	GoldBanana uint64 `json:"goldBanana"`
	// 粉丝
	// Followed    string `json:"followed"`
	FollowedNum uint64 `json:"followedNum"`
	// 性别,男1,未知-1
	Gender int8 `json:"gender"`

	RegisterTime int64 `json:"registerTime"`
	// 稿件数量
	ContentCount string `json:"contentCount"`
	// 关注别人数量
	Following string `json:"following"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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