如何使用Google Apps脚本插入YouTube频道横幅?

发布于 2025-02-01 17:34:04 字数 361 浏览 5 评论 0原文

您好Stackoverflow社区。

我想知道如何使用ChannelBanners更新频道横幅图像:Google Apps脚本上的YouTube数据API插入方法( https://developers.google.com/youtube/v3/docs/channelbanners/insert/insert

任何人都可以帮助我创建应用程序脚本代码来做到这一点吗?

感谢您的帮助!

Hello stackoverflow community.

I want to know how to update my channels banner image with the ChannelBanners: insert method from the YouTube Data API on Google Apps Script (https://developers.google.com/youtube/v3/docs/channelBanners/insert)

Can anybody help me to create an Apps Script code to do this?

Thanks for your help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

自演自醉 2025-02-08 17:34:04

我相信您的目标如下。

  • 您想使用Google Apps脚本将横幅插入YouTube频道。

在这种情况下,以下示例脚本怎么样?

请将要使用的图像文件放在Google驱动器中,然后检索文件ID。

示例脚本:

在使用此脚本之前Google服务。并且,请在Google驱动器上设置您的频道ID和图像文件的文件ID。

function myFunction() {
  const channelId = "###"; // Please set your channel ID.
  const fileId = "###"; // Please set the file ID of the image file on Google Drive.

  const blob = DriveApp.getFileById(fileId).getBlob();
  YouTube.ChannelBanners.insert(null, blob, { channelId });
}
  • 运行此脚本时,将检索的图像设置为频道的横幅。

  • 关于图像大小,官方文件显示如下。请小心。

    调用channelbanners.intert方法将二进制图像数据上传到YouTube。该图像必须具有16:9的纵横比,并且至少为2048x1152像素。我们建议在1440px图像上上传2560px。

参考:

I believe your goal is as follows.

  • You want to insert a banner to your YouTube channel using Google Apps Script.

In this case, how about the following sample script?

Please put an image file you want to use to your Google Drive, and retrieve the file ID.

Sample script:

Before you use this script, please enable YouTube Data API at Advanced Google services. And, please set your channel ID and the file ID of the image file on your Google Drive.

function myFunction() {
  const channelId = "###"; // Please set your channel ID.
  const fileId = "###"; // Please set the file ID of the image file on Google Drive.

  const blob = DriveApp.getFileById(fileId).getBlob();
  YouTube.ChannelBanners.insert(null, blob, { channelId });
}
  • When this script is run, the retrieved image is set as the banner of the channel.

  • About the image size, the official document says as follows. Please be careful about this.

    Call the channelBanners.insert method to upload the binary image data to YouTube. The image must have a 16:9 aspect ratio and be at least 2048x1152 pixels. We recommend uploading a 2560px by 1440px image.

Reference:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文