2017-02-11 3 views
0

YouTube API v3를 사용하여 YouTube에 비디오를 업로드하고 있습니다. 현재 제목과 설명을 업데이트하는 동영상을 업로드 할 수 있지만 나에게 매우 중요한 점은 NotifySubscribers 속성을 선택 취소 (부울 false)하는 것입니다.C# YouTube의 NotifySubscribers 설정 .Videos.Years API v3로 삽입

문서 herehere을 찾을 수 있었지만 구현 예가 없어도 나는 매우 분실했습니다.

다음 코드입니다 저는 현재 해당 false로 NotifySubscribers을 설정하지 않고, 성공적으로 업로드 할 수 있습니다

내가 그 값을 설정하면 제목을 설정하는 것만 큼 간단했을 것이다라고 생각했을 것이다
 private async Task Run() 
     { 
      UserCredential credential; 
      using (var stream = new FileStream("youtube_client_secret.json", FileMode.Open, FileAccess.Read)) 
      { 
       credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
        GoogleClientSecrets.Load(stream).Secrets, 
        // This OAuth 2.0 access scope allows an application to upload files to the 
        // authenticated user's YouTube channel, but doesn't allow other types of access. 
        new[] { YouTubeService.Scope.YoutubeUpload }, 
        "user", 
        CancellationToken.None 
       ); 
      } 

      var youtubeService = new YouTubeService(new BaseClientService.Initializer() 
      { 
       HttpClientInitializer = credential, 
       ApplicationName = Assembly.GetExecutingAssembly().GetName().Name 
      }); 

      var video = new Video(); 
      video.Snippet = new VideoSnippet(); 
      video.Snippet.Title = "test"; 
      video.Snippet.Description = "test description"; 
      video.Status = new VideoStatus(); 
      video.Status.PrivacyStatus = "unlisted"; // or "private" or "public" 
      var filePath = @"D:\directory\YoutubeUploader\2017-02-05_02-01-32.mp4"; 
      using (var fileStream = new FileStream(filePath, FileMode.Open)) 
      { 
       var videosInsertRequest = youtubeService.Videos.Insert(video, "snippet,status", fileStream, "video/*"); 
       videosInsertRequest.ProgressChanged += videosInsertRequest_ProgressChanged; 
       videosInsertRequest.ResponseReceived += videosInsertRequest_ResponseReceived; 

       await videosInsertRequest.UploadAsync(); 
      } 
     } 

     void videosInsertRequest_ProgressChanged(Google.Apis.Upload.IUploadProgress progress) 
     { 
      switch (progress.Status) 
      { 
       case UploadStatus.Uploading: 
        Console.WriteLine("{0} bytes sent.", progress.BytesSent); 
        break; 

       case UploadStatus.Failed: 
        Console.WriteLine("An error prevented the upload from completing.\n{0}", progress.Exception); 
        break; 
      } 
     } 

, 개인 정보 보호를 상태 및 다른 것들이 있었지만 이것이 사실 인 것처럼 보이지는 않습니다. 나는 진짜 깊이있는 C# 코딩을 한 번도 해 본 적이 없기 때문에 이러한 개념 중 일부는 나에게 새롭다.

+0

가 대중에게 개인 정보 보호 상태를 변경 시도를,이 [포럼] (https://productforums.google.com/forum/# ! topic/youtube/GjIoVHR3f7M; context-place = topicsearchin/youtube/category $ 3Asafari)는 비공개/미등록으로 업로드 한 모든 동영상이 구독자에게 알림을 보내지 않을 수 있다고 설명했습니다. 또한 모든 업로드에 대해 알림 구독자를 수동으로 선택했으면 YouTube 채널을 확인하십시오. 기본적으로 [notifySubscribers] (https://developers.google.com/youtube/v3/docs/videos/insert#parameters)는 ** True **로 설정됩니다. –

답변

0

현재 Google.Apis.YouTube.v3 NuGet 패키지 (1.21.0.760)에서는 불가능합니다. .dll에서 많은 메소드를 남긴 것처럼 보이므로 매우 제한적인 기능을 제공합니다. 이 문제를 해결하기 위해 GitHub 저장소 this에서 코드를 가져 와서 .cs 파일에 저장했습니다. 그런 다음이 파일의 모든 메소드를 호출 할 수있었습니다. 이 작업이 완료되자, 나는이 설정을 변경해야했다 모두가 다음이었다

videosInsertRequest.NotifySubscribers = false;