You can actually use the sdk or some youtube library relevant to the language you are using to write API's.
(实际上,您可以使用与您用于编写API的语言相关的sdk或某些youtube库。)
In the documentation, it isn't clear what to specify for passing both at same time. (在文档中,不清楚要为同时传递两者指定什么内容。)
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 = "Default Video Title";
video.Snippet.Description = "Default Video Description";
video.Snippet.Tags = new string[] { "tag1", "tag2" };
video.Snippet.CategoryId = "22"; // See https://developers.google.com/youtube/v3/docs/videoCategories/list
video.Status = new VideoStatus();
video.Status.PrivacyStatus = "unlisted"; // or "private" or "public"
var filePath = @"REPLACE_ME.mp4"; // Replace with path to actual movie file.
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();
}
}
Here, we are passing both the file stream and the metadata in the same function.
(在这里,我们将文件流和元数据传递到同一函数中。)
You can also use the library provided by google to do the same. (您也可以使用Google提供的库来执行相同的操作。)
I hope this helps.
(我希望这有帮助。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…