原始文件始终是“未知的";通过 Youtube API v3 上传时 [英] Raw File is always "unknown" when uploaded through Youtube API v3

查看:17
本文介绍了原始文件始终是“未知的";通过 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 上传时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆