go - Youtube API get premium views amount - Stack Overflow

I am working on an application to retrieve information about viewing Youtube videos, the application is

I am working on an application to retrieve information about viewing Youtube videos, the application is used by a "Content Manager" type user.

Today I access data like number of views, watch duration, etc. But also the estimated revenues, the number of ad impressions. But I can't find how getting views from Youtube Premium accounts (and many others datas).

I am using Golang and Youtube dedicated libs, youtubeanalytics in that precice case. Here's my fetching function:

import (
    ...
    "google.golang/api/youtubeanalytics/v2"
    ...
)
func (f *Fetcher) GetData(ownerID, videoID, startDate, endDate string, metrics []string) {

    metricsString := strings.Join(metrics, ",")

    call := f.ytaService.Reports.Query().
        Ids(fmt.Sprintf("contentOwner==%s", ownerID)).
        StartDate(startDate).
        EndDate(endDate).
        Filters("video==" + videoID).
        Metrics(metricsString)

    response, err := call.Do()
    if err != nil {
        if apiErr, ok := err.(*googleapi.Error); ok {
            fmt.Printf("API error: %v\n", apiErr)
            if apiErr.Code == 400 {
                fmt.Println("Erreur 400: Check metrics and dimessions asked.")
            }
        }
        fmt.Printf("Error when getting statistics for video %s: %v\n", videoID, err)
    } else {
        for _, row := range response.Rows {
            for i, v := range row {
                fmt.Printf("- %s: %v\n", metrics[i], v)
            }
        }
    }
}

I searched on Google documentation, libs source code and forums, discuted with AI bots. I didn't try downloading and parse csv reports, hoping there's a pure API way to do that.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742416111a4439776.html

相关推荐

  • go - Youtube API get premium views amount - Stack Overflow

    I am working on an application to retrieve information about viewing Youtube videos, the application is

    4小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信