如何为使用 YouTube Data API v3 上传的视频启用货币化? [英] How to enable monetization for videos uploaded with YouTube Data API v3?

查看:26
本文介绍了如何为使用 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 合作伙伴计划与成为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(文档)

对于您需要使用范围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 上传的视频启用货币化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆