【问题标题】:I get a 500 error when I add 'madeForKids' parameter to 'youtube.liveBroadcasts.insert' API将“madeForKids”参数添加到“youtube.liveBroadcasts.insert”API 时出现 500 错误
【发布时间】:2020-07-04 13:41:22
【问题描述】:

我有一个关于如何在“youtube.liveBroadcasts.insert”API 中使用“madeForKids”的问题。

当我不使用这个参数时,youtube的用户界面会弹出一个窗口让我选择它是否是为孩子制作的。我不希望它显示这个窗口。我想用 API 设置这个值。 但是当我添加这个参数时,它总是会响应一个 500 错误。

我的代码基于JS如下:

    this.youtube.liveBroadcasts.insert(
      {
        auth: this.oauth2Client,
        part: "snippet,contentDetails,status",
        resource: {
          snippet: {
            title: title,
            scheduledStartTime: scheduledStartTime
          },
          status: {
            madeForKids: "false",
            selfDeclaredMadeForKids: "false",
            lifeCycleStatus: "live",
            privacyStatus: "public"
          },
          contentDetails: {
            rojection: "360",
            monitorStream: {
              enableMonitorStream: false
            }
          }
        }
      },
      function (err, response) {
        if (err) {
          console.log("The API:createLiveBroadCast returned an error: " + err);
          reject(new Error(err));
        } else {
          console.log(response);
          resolve(response);
        }
      }
    );

另外,我使用的是最新的googleapis:“^48.0.0”。

谁能帮帮我?非常感谢!

【问题讨论】:

  • 确保将“```”添加到代码块的末尾以关闭它。

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


【解决方案1】:

您不能在直播中设置状态属性。 插入 LiveBroadcast 后,您必须更新视频资产并在其中设置状态属性。使用您刚刚添加的 LiveBroadcast.ID。您必须同时重置标题和描述,否则它们将被设置为空。

像这样:

       var videoRequest = youtubeService.Videos.Update(
            new Video {
                Id = "xxxxxx",
                Kind = "youtube#video",
                Snippet = new VideoSnippet
                {
                    Title = "updated title",
                    CategoryId = "28"
                },
                Status = new VideoStatus
                {
                    PrivacyStatus = "unlisted",
                    SelfDeclaredMadeForKids = false
                }
            },
            "snippet,status"
        );
        var videoResponse = videoRequest.Execute();

【讨论】:

    【解决方案2】:

    当调用liveBroadcasts.insert 端点时,如果想将相应的广播指定为child-directed,则不应使用makeForKids 属性,而应使用this one

    status.selfDeclaredMadeForKids布尔值

    在 liveBroadcasts.insert 请求中,此属性允许频道所有者将广播指定为面向儿童的。在 liveBroadcasts.list 请求中,仅当频道所有者授权 API 请求时才返回属性值。

    查看此端点允许使用的list of properties。它提到了selfDeclaredMadeForKids,但没有提到madeForKids

    【讨论】:

      猜你喜欢
      • 2019-11-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-22
      • 2022-01-08
      相关资源
      最近更新 更多