将 'madeForKids' 参数添加到 'youtube.liveBroadcasts.insert' API 时出现 500 错误 [英] I get a 500 error when I add 'madeForKids' parameter to 'youtube.liveBroadcasts.insert' API

查看:21
本文介绍了将 'madeForKids' 参数添加到 'youtube.liveBroadcasts.insert' API 时出现 500 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have one question about how to use 'madeForKids' in 'youtube.liveBroadcasts.insert' API.

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

When I don't use this parameter, the user interface of youtube will pop up a window to let me choose wether it is made for kids. I don't want it to show this window. I want to set this value with API. But when I added this parameter, it will always response a 500 error.

我的代码基于JS如下:

My codes is based on JS as follows:

    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".

Additionally, I am using the latest googleapis: "^48.0.0".

谁能帮帮我?非常感谢!

Can anyone help me ? Thanks a lot !

推荐答案

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

You cannot set the status attribute in LiveBroadcast. After you insert LiveBroadcast, you must update the video asset and set the status attributes there. Use the LiveBroadcast.ID you just added. You must reset the title and description at the same time or they will get set to null.

像这样:

       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();

这篇关于将 'madeForKids' 参数添加到 'youtube.liveBroadcasts.insert' API 时出现 500 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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