Missing “statistics” from video list response

我的未来我决定 提交于 2019-12-11 05:46:51

问题


I am calling youtube api for videos.list(https://developers.google.com/youtube/v3/docs/videos/list) with part="snippet,contentDetails,status,statistics,topicDetails". On Apr 6 or 7 2017 something changed and for many videos I don't get field "statistics". I'm wondering, why this happens and how I can get publicly available counts, like viewCount, for them? Here are a couple of example videos: PiZEMoZ535I,vHw_drm5cRk


回答1:


This is likely a bug, it was working fine until April 7th. There's an Issue Tracker created for that, however Google still didn't say anything about this.

EDIT: This seems to finally be fixed




回答2:


You need to make a call to the API with the resource video.list with parameters : part: statistics id: "id of the video found in previous request"

If you have more than one video id you can specify the id of videos with a comma-separated list like :

id: "Xxsdw6zG1bg, Xxsdw6zG1bg,...." )

The request: https://www.googleapis.com/youtube/v3/videospart=statistics&id=UHdgXkkVyl0%2C+Xxsdw6zG1bg&key={YOUR_API_KEY}

The response will be like this :

{
 "kind": "youtube#videoListResponse",
 "etag": "\"MmqJLb8ZBOWRQIsg7xej7lrKLMI/rxvjZzq2nNqBg7Me5VQv1ToZm64\"",
 "pageInfo": {
  "totalResults": 2,
  "resultsPerPage": 2
 },
 "items": [
  {

   "kind": "youtube#video",
   "etag": "\"MmqJLb8ZBOWRQIsg7xej7lrKLMI/3fah-cngFxFOnytseMYZU1TK_-8\"",
   "id": "UHdgXkkVyl0",
   "statistics": {
    "viewCount": "3070836",
    "likeCount": "72140",
    "dislikeCount": "1132",
    "favoriteCount": "0",
    "commentCount": "7798"
   }
  },
  {

   "kind": "youtube#video",
   "etag": "\"MmqJLb8ZBOWRQIsg7xej7lrKLMI/J4xM7Dd23TGYU6on-PESyEIAE9A\"",
   "id": "Xxsdw6zG1bg",
   "statistics": {
    "viewCount": "131487",
    "likeCount": "1459",
    "dislikeCount": "25",
    "favoriteCount": "0",
    "commentCount": "39"
   }
  }
 ]
}

And you have the statistics !



来源:https://stackoverflow.com/questions/43339723/missing-statistics-from-video-list-response

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!