为什么在将视频文件上传到youtube和youtube.com网站时,我的程序拒绝了该文件,但是没有显示拒绝消息?

时间:2015-09-13 01:24:27

标签: c# .net winforms google-api youtube-api

这是我用来上传到youtube的上传方法:

private void UploadVideo(string FileName, string VideoTitle, string VideoDescription)
{
    try
    {
        var youtubeService = new YouTubeService(new BaseClientService.Initializer()
        {
            HttpClientInitializer = credential,
            ApplicationName = Assembly.GetExecutingAssembly().GetName().Name
        });

        video.Snippet = new VideoSnippet();
        video.Snippet.Title = VideoTitle;
        video.Snippet.Description = VideoDescription;
        video.Snippet.Tags = new string[] { "tag1", "tag2" };
        video.Status = new VideoStatus();
        video.Status.PrivacyStatus = "public";
        using (var fileStream = new FileStream(FileName, FileMode.Open))
        {
            const int KB = 0x400;
            var minimumChunkSize = 256 * KB;

            var videosInsertRequest = youtubeService.Videos.Insert(video,
                        "snippet,status", fileStream, "video/*");
            videosInsertRequest.ProgressChanged +=
                        videosInsertRequest_ProgressChanged;
            videosInsertRequest.ResponseReceived +=
                        videosInsertRequest_ResponseReceived;
            // The default chunk size is 10MB, here will use 1MB.
            videosInsertRequest.ChunkSize = minimumChunkSize * 3;
            dt = DateTime.Now;
            totalBytes = fileStream.Length;
            videosInsertRequest.Upload();
            //videosInsertRequest.UploadAsync();
        }
    }
    catch (Exception errors)
    {
        string errorss = errors.ToString();
    }
}

然后我举办了活动videosInsertRequest_ResponseReceived

private void videosInsertRequest_ResponseReceived(Video obj)
{
    uploadstatus = obj.Status.UploadStatus;
}

uploadstatus是字符串。

问题是当我上传一个重复的文件时,我在youtube.com上看到该文件被拒绝,因为它已被复制。

但在我的uploadstatus程序中,我看到“已上传” 我应该看到“拒绝”或类似的东西。

obj RejectionReason有一个属性,但是当我在做的时候:

uploadstatus = obj.Status.RejectionReason;

uploadstatus为空,但在youtube的网站上我再次看到上传被拒绝的消息。

RejectionReason财产解说中,它说:

仅当uploadStatus属性指示上载被拒绝时,才会显示此属性。 但是obj.Status.UploadStatus状态是“已上传”

我正在使用谷歌api v3.0

0 个答案:

没有答案