有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java通过在Youtube API上插入设置公共统计信息

我正在使用Java API将视频上传到YouTube,如下所示:

    YouTube.Videos.Insert videoInsert = youTube.videos().insert("snippet,statistics,status", video, videoInputStreamContent);

videoInsert.getMediaHttpUploader().setDirectUploadEnabled(false);
videoInsert.getMediaHttpUploader().setProgressListener(new UploadProcessListener());

uploadedVideo = videoInsert.execute();

现在,客户想让我预先设置选项“公开观看页面上的视频统计信息”,但我在插入的文档中找不到该选项。 有人知道如何设置这个值吗

Setting I want to change on the Yoututbe Page after it was updated by the API

致意


共 (1) 个答案

  1. # 1 楼答案

    我相信您正在寻找status.publicStatsViewable,它包含在videos.insert parameters中。参数在Overview page上有更详细的描述:

    This value indicates whether the extended video statistics on the video's watch page are publicly viewable. By default, those statistics are viewable, and statistics like a video's viewcount and ratings will still be publicly visible even if this property's value is set to false.

    在Java代码中,我相信您需要创建一个^{}对象并调用setPublicStatsViewable(),然后设置video对象的状态:

    VideoStatus status = new VideoStatus();
    status.setPublicStatsViewable(true);
    video.setStatus(status);
    
    // (your existing code)
    YouTube.Videos.Insert videoInsert = 
        youTube.videos().insert("snippet,statistics,status", video, videoInputStreamContent);
    ...