【问题标题】:Extract youtube stats for nerds through an API通过 API 为书呆子提取 youtube 统计信息
【发布时间】:2018-03-30 21:43:14
【问题描述】:

是否有任何可用的 youtube API 来获取书呆子的统计信息?

我四处寻找统计数据,但他们指出 viewCount、likeCount 等。我特别在寻找右击视频时可用的 nerds 数据的统计数据。

   URL: https://www.googleapis.com/youtube/v3/videos?id=7lCDEYXw3mM&key=YOUR_API_KEY
     &part=snippet,statistics&fields=items(id,snippet,statistics)

Description: This example adds the fields parameter to remove all
             kind and etag properties from the API response.

API response:

{
 "videos": [
  {
   "id": "7lCDEYXw3mM",
   "snippet": {
    "publishedAt": "2012-06-20T22:45:24.000Z",
    "channelId": "UC_x5XG1OV2P6uZZ5FSM9Ttw",
    "title": "Google I/O 101: Q&A On Using Google APIs",
    "description": "Antonio Fuentes speaks to us and takes questions on working with Google APIs and OAuth 2.0.",
    "thumbnails": {
     "default": {
      "url": "https://i.ytimg.com/vi/7lCDEYXw3mM/default.jpg"
     },
     "medium": {
      "url": "https://i.ytimg.com/vi/7lCDEYXw3mM/mqdefault.jpg"
     },
     "high": {
      "url": "https://i.ytimg.com/vi/7lCDEYXw3mM/hqdefault.jpg"
     }
    },
    "categoryId": "28"
   },
   "statistics": {
    "viewCount": "3057",
    "likeCount": "25",
    "dislikeCount": "0",
    "favoriteCount": "17",
    "commentCount": "12"
   }
  }
 ]
}

【问题讨论】:

    标签: javascript python youtube youtube-api youtube-data-api


    【解决方案1】:

    玩家通过内部 Youtube API (InnerTube) 检索书呆子的统计数据。

    网址:https://www.youtube.com/youtubei/v1/player?key=[DERIVATED_API_KEY]

    与网络开发者一起玩以获取派生的 API 密钥并通过“--web-security”禁用 CORS 以允许跨域 ajax 调用。

    响度信息:

          function getLoudness(videoId) {
            $.ajax({
              type: "POST",
              url: "https://www.youtube.com/youtubei/v1/player?key="+ytApiKeyV1,
              contentType: "application/json; charset=utf-8",
              dataType: "json",
              data: JSON.stringify({
                "videoId": videoId,
                "context": {
                  "client": {
                    "clientName": "WEB_EMBEDDED_PLAYER",
                    "clientVersion": "1.20211110.01.01"
                  },
                  "thirdParty": {
                    "embedUrl": "https://xxx.xxxxx.tld/"
                  }
                }
              }),
              success: function(response) {
                if(response.playerConfig.audioConfig) {
                  setLoudness(response.playerConfig.audioConfig);
                }
              }
            })
          }
    

    【讨论】:

      【解决方案2】:

      如果您正在寻找书呆子的统计数据,请查看Resource representation of Videos。可以得到以下数据:

      {
        "kind": "youtube#video",
        "etag": etag,
        "id": string,
        ...
        "fileDetails": {
          "fileName": string,
          "fileSize": unsigned long,
          "fileType": string,
          "container": string,
          "videoStreams": [
            {
              "widthPixels": unsigned integer,
              "heightPixels": unsigned integer,
              "frameRateFps": double,
              "aspectRatio": double,
              "codec": string,
              "bitrateBps": unsigned long,
              "rotation": string,
              "vendor": string
            }
          ],
          "audioStreams": [
            {
              "channelCount": unsigned integer,
              "codec": string,
              "bitrateBps": unsigned long,
              "vendor": string
            }
          ],
          "durationMs": unsigned long,
          "bitrateBps": unsigned long,
          "creationTime": string
        },
        "processingDetails": {
          "processingStatus": string,
          "processingProgress": {
            "partsTotal": unsigned long,
            "partsProcessed": unsigned long,
            "timeLeftMs": unsigned long
          },
          "processingFailureReason": string,
          "fileDetailsAvailability": string,
          "processingIssuesAvailability": string,
          "tagSuggestionsAvailability": string,
          "editorSuggestionsAvailability": string,
          "thumbnailsAvailability": string
        },
        ...
      }
      

      【讨论】:

        猜你喜欢
        • 2018-08-05
        • 1970-01-01
        • 2013-09-03
        • 2021-02-18
        • 1970-01-01
        • 2017-01-20
        • 1970-01-01
        • 2019-03-26
        • 2018-11-24
        相关资源
        最近更新 更多