Raw File is always quot;unknownquot; when uploaded through Youtube API v3(原始文件始终是“未知的;通过 Youtube API v3 上传时)
问题描述
任何使用 .Net Youtube API v3 C# 上传的视频,在您查看上传文件(Raw 文件)的原始文件名时,始终被视为未知".
Any video that is uploaded using .Net Youtube API v3 C# is always regarded as "unknown" when you check the original file name of the uploaded file (Raw file).
我搜索了很多,可以找到一些相同的问题但没有解决方案,所以我不知道是否每个人都得到了它,这不是一件大事,或者人们是否知道解决方案.
I have searched a lot and can find some with same issues but no solution, so i don't know if everyone got it and it's just not a big thing or if ppl know of a solution.
上传的代码是原始示例代码(我尝试修改东西以了解是否有用).
The code for uploading is the original sample code (i tried modifying stuff to know avail).
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 循环.
That code is same as the sample code except that i got a for loop for getting the videos.
我不知道这个问题是只在C#上,还是我只是瞎了,解决方法很明显.
I don't know if this problem is only on C#, or if i am just blind and the solution is obvious.
为了以防万一,我在他们的错误跟踪器上发布了一个问题:https://code.google.com/p/gdata-issues/issues/detail?id=7140&can=6&sort=-id&colspec=API%20ID%20Type%20Status%20Priority%20Stars%20Summary
I have issued an issue at their bug tracker just in case: https://code.google.com/p/gdata-issues/issues/detail?id=7140&can=6&sort=-id&colspec=API%20ID%20Type%20Status%20Priority%20Stars%20Summary
谢谢.
推荐答案
要设置 RAW 文件名,添加到 HTTP 侦听器:
To set RAW filename, add to HTTP Hearder:
"Slug:"+ 你的文件名.
"Slug: "+ your filename.
我不使用谷歌库,所以我不知道如何使用 .Net Youtube API v3 C# 进行设置
I don't use google library, so I don't know how to set this using .Net Youtube API v3 C#
这篇关于原始文件始终是“未知的";通过 Youtube API v3 上传时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:原始文件始终是“未知的";通过 Youtube API v3 上传时


- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- 输入按键事件处理程序 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01