本文介绍了如何为使用 YouTube Data API v3 上传的视频启用获利功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 YouTube 上有一个经过验证的合作伙伴频道,我正在尝试为通过 YouTube 数据 API (v3) 上传的视频启用获利功能.

I have a verified partner channel on YouTube, and I'm trying to enable monetization for videos uploaded via the YouTube Data API (v3).

频道已经启用了获利功能,我已经在频道设置→默认值中启用了获利功能(尽管我感觉此页面仅用于在标准手动上传页面上设置默认值).我查看了 API 参考,但根本找不到任何与获利相关的内容.

The channel is already enabled for monetization, and I've enabled monetization in Channel Settings → Defaults (although I have a feeling that this page is only for setting the defaults on the standard manual upload page). I've looked in the API reference, but can't find anything related to monetization at all.

是否有其他方法可以自动使通过任何方式上传的新视频获利,或者我可以在 API 中启用它?

Is there some other way to automatically make new videos uploaded by any means monetized, or some way I can enable it in the API?

推荐答案

Tareq 提供的链接是正确的,但不幸的是它只显示了一些 python 代码,而不是使用 HTTP 的情况.因为我想做同样的事情,所以这就是我想出的和对我有用的.再次注意,您需要访问 ContentID API(投票给 这张票 来解决这个问题),这意味着您需要访问 CMS 帐户的所有者.令人困惑的是,存在一个与成为YouTube 合作伙伴".您需要访问 CMS 帐户,例如如果您正在运行多通道网络 (MCN),则属于这种情况.此外,我的印象是文档实际上隐藏得很好,因为即使我确切地知道我在寻找什么,我总是很难再次找到文档页面.

The link that Tareq supplied is correct, but unfortunately it only shows some python code instead of what is going on using HTTP. Since I wanted to do the same, here is what I have figured out and what works for me. Note again that you need access to the ContentID API (vote for this ticket to get this fixed) which means you need to have access to a owners of an CMS Account. Confusingly there exists a YouTube Partner Program which has nothing to do with being a "YouTube Partner". You need access to a CMS account which is e.g. the case if you are running an multi channel network (MCN). Additionally I get the impression that the documentation is actually quite well hidden because even if I know exactly what I am looking for I always have a hard time to find the documentation pages again.

无论如何:这是东西:

首先您需要创建资产(docs):

First you need to create an asset (docs):

POST https://www.googleapis.com/youtube/partner/v1/assets?onBehalfOfContentOwner=CONTENT_OWNER_ID
Authorization: Bearer ...

{
  "type": "web",
  "metadata": {
    "title": "some title, typically the same as the video title",
    "customId": "optional, but typically the same as the videoId"
  }
}

在响应正文中,您会发现:

In the response body you'll find:

{
  ...
  "id": "ASSET_ID"
  ...
}

保存 ASSET_ID 以备后用.

Save the ASSET_ID for later.

现在我们告诉 YouTube,我们在全球范围内 100% 独家拥有与资产相关的所有内容 (文档):

Now we tell YouTube that we exclusively own everything connected with the asset to 100% exclusively and worldwide (docs):

PUT https://www.googleapis.com/youtube/partner/v1/assets/ASSET_ID/ownership?onBehalfOfContentOwner=CONTENT_OWNER_ID
Authorization: Bearer ...

{
  "general": {
    "owner": "CONTENT_OWNER_ID",
    "ratio": 100,
    "type": "exclude"
  }
}

请注意,这是一个 PUT 请求,而不是一个 POST!

Note that this is a PUT request and not a POST!

现在我们将视频、资产和政策相互关联起来 (文档)

Now we connect the video, the asset and a policy whith each other (docs)

POST https://www.googleapis.com/youtube/partner/v1/claims?onBehalfOfContentOwner=CONTENT_OWNER_ID
Authorization: Bearer ...

{
  "assetId": "ASSET_ID",
  "videoId": "VIDEO_ID",
  "policy": {
    "id": "POLICY_ID"
  },
  "contentType": "audiovisual"
}

现在您的视频将根据某些政策获利.

Now your video should will be monetized according to some policy.

在我的示例中,您当然需要用大写字母替换我留在其中的变量:

In my examples you will of course need to replace the variables I left in there in capital letters:

  • CONTENT_OWNER_ID:使用 GET https://www.googleapis.com/youtube/partner/v1/contentOwners?fetchMine=true (docs)
  • ASSET_ID:在创建资产调用的responseBody中返回
  • POLICY_ID:通过对 GET https://www.googleapis.com/youtube/partner/v1/policies?onBehalfOfContentOwner=CONTENT_OWNER_ID (docs)
  • CONTENT_OWNER_ID: Find out your id using and authenticated call to GET https://www.googleapis.com/youtube/partner/v1/contentOwners?fetchMine=true (docs)
  • ASSET_ID: It is returned in the responseBody of the create asset call
  • POLICY_ID: Find out what policies with which ids you have with an authenticated call to GET https://www.googleapis.com/youtube/partner/v1/policies?onBehalfOfContentOwner=CONTENT_OWNER_ID (docs)

对于您需要使用范围 https://www.googleapis.com/auth/youtubepartner

这只是应用获利的一种方式和选项集.我展示的 API 端点有更多不同的选项.请参阅文档.

This is just one way and option set of applying monetizations. The API endpoints that I showed have more and different options. Refer to the docs.

  • 这张票投票,以便默认获利政策也适用于通过 API 上传的视频.
  • 这张票投票,以便我们获得无需访问 CMS 帐户即可在上传期间指定获利设置
  • Vote for this ticket so that default monetization policies are also applied for videos uploaded through the API.
  • Vote for this ticket so that we get the ability to specify monetization settings during upload without the need to have access to a CMS account

这篇关于如何为使用 YouTube Data API v3 上传的视频启用获利功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 11:39
查看更多