YouTube API v3を使用してYouTubeに動画をアップロードしています。私は現在、ビデオをアップロードしてタイトルと説明を更新できますが、私にとって非常に重要なことはNotifySubscribersプロパティのチェックを外すことです(ブール値false)。C#YouTubeのNotifySubscribersを設定する.Videos.YouTube API v3の挿入
ドキュメントhereとhereを見つけることができましたが、実装例はありませんが、私はかなり迷っています。
は、次のコードで私は現在、それが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#コーディングを行ったことがないので、これらのコンセプトのいくつかはかなり新しいものです。
を公開し、プライバシーのステータスを変更してみてください、この[フォーラム](https://productforums.google.com/forum/# !topic/youtube/GjIoVHR3f7M; context-place = topicsearchin/youtube/category $ 3Asafari)は、非公開/非公開の動画アップロードでは、また、あなたが行ったすべてのアップロードに対してNotify Subscriberを手動でチェックした場合は、あなたのYouTubeチャンネルをチェックしてください。デフォルトでは[notifySubscribers](https://developers.google.com/youtube/v3/docs/videos/insert#parameters)は** True **に設定されています。 –