123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- package youngee_talent_service
- import (
- "encoding/json"
- "fmt"
- "github.com/lin-jim-leon/kuaishou/util"
- )
- const (
- //快手
- VideoCountUrl = "https://open.kuaishou.com/openapi/photo/count?app_id=%s&access_token=%s"
- VideoListUrl = "https://open.kuaishou.com/openapi/photo/count?app_id=%s&access_token=%s?count=200"
- //抖音
- DyVideoList = "https://open.douyin.com/api/douyin/v1/video/video_list?count=20&open_id=%s&cursor=%d"
- )
- type Videoresponse struct {
- Result int `json:"result"`
- PublicCount int `json:"public_count"`
- FriendCount int `json:"friend_count"`
- PrivateCount int `json:"private_count"`
- AllCount int `json:"all_count"`
- }
- type VideoListResponse struct {
- Result int `json:"result"`
- VideoList []VideoInfo `json:"video_list"`
- }
- type VideoInfo struct {
- PhotoID int `json:"photo_id"`
- Caption int `json:"caption"`
- Cover int `json:"cover"`
- PlayURL int `json:"play_url"`
- CreateTime int `json:"create_time"`
- LikeCount int `json:"like_count"`
- CommentCount int `json:"comment_count"`
- ViewCount int `json:"view_count"`
- Pending int `json:"pending"`
- }
- // 获取快手总作品数
- func GetVideoCount(appid string, accesstoken string) (info Videoresponse, err error) {
- uri := fmt.Sprintf(VideoCountUrl, appid, accesstoken)
- var response []byte
- response, err = util.HTTPGet(uri)
- if err != nil {
- return Videoresponse{}, err
- }
- var result Videoresponse
- err = json.Unmarshal(response, &result)
- if err != nil {
- return Videoresponse{}, err
- }
- return result, nil
- }
- // 获取快手视频列表(暂时最多统计200个视频)
- func GetVideoList(appid string, accesstoken string) (info VideoListResponse, err error) {
- uri := fmt.Sprintf(VideoListUrl, appid, accesstoken)
- var response []byte
- response, err = util.HTTPGet(uri)
- if err != nil {
- return VideoListResponse{}, err
- }
- var result VideoListResponse
- err = json.Unmarshal(response, &result)
- if err != nil {
- return VideoListResponse{}, err
- }
- return result, nil
- }
- // 获取快手总点赞数(暂时最多统计200个视频)
- func GetLikeCount(appid string, accesstoken string) (int, error) {
- videoListResponse, err := GetVideoList(appid, accesstoken)
- if err != nil {
- return 0, err
- }
- totalLikes := 0
- for _, video := range videoListResponse.VideoList {
- totalLikes += video.LikeCount
- }
- return totalLikes, nil
- }
- // 获取抖音视频列表
- // 获取快手视频列表(暂时最多统计200个视频)
- func GetDyVideoList(openid string, accesstoken string) (info VideoListResponse, err error) {
- }
- //获取抖音总点赞数
- //获取抖音总评论数
|