0
正在使用的.Net的Youtube API V3 C#上傳一直被認爲是「未知」當您檢查上傳的文件的原始文件名(原始文件)的任何視頻。原始文件始終是「未知」
我尋覓了很多,可以找到一些具有相同的問題,但沒有解決辦法,所以我不知道如果每個人都得到它,它只是沒有一個大的事情,或者脂肪酶知道解決辦法的。
用於上載的代碼是原始樣本代碼(我試圖修改東西知道無濟於事)。
async void Upload()
{
_lastBytes = 0;
_currentItem = -1;
for (_currentItem = 0; _currentItem < WorkList.Count; _currentItem++)
{
var videoSource = WorkList[_currentItem];
UserCredential credential;
using (var stream = new FileStream("YourJsonFile", 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 = videoSource.Title;
if (videoSource.Description != null)
video.Snippet.Description = videoSource.Description;
if (videoSource.Tags != null)
video.Snippet.Tags = videoSource.Tags.Split(',');
video.Snippet.CategoryId = "22";
// See https://developers.google.com/youtube/v3/docs/videoCategories/list
video.Status = new VideoStatus();
video.Status.PrivacyStatus = "private"; // or "private" or "public"
var filePath = videoSource.Path; // Replace with path to actual movie file.
using (var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
{
_size = fileStream.Length;
var videosInsertRequest = youtubeService.Videos.Insert(video, "snippet,status,contentDetails",
fileStream, "video/*");
videosInsertRequest.ProgressChanged += videosInsertRequest_ProgressChanged;
videosInsertRequest.ResponseReceived += videosInsertRequest_ResponseReceived;
await videosInsertRequest.UploadAsync();
}
}
}
該代碼與示例代碼相同,只是我得到了用於獲取視頻的for循環。
我不知道這個問題只在C#,或者如果我只是盲目和解決方案是顯而易見的。
我剛纔的情況下發出的一個問題,在他們的bug跟蹤系統:https://code.google.com/p/gdata-issues/issues/detail?id=7140&can=6&sort=-id&colspec=API%20ID%20Type%20Status%20Priority%20Stars%20Summary
感謝。
你有沒有找到一個解決辦法? – tehAnswer