public string UploadVideo(FileInfo path, string name, Guid guid, Action <int> percentageUpdate) { var video = new Video(); video.Snippet = new VideoSnippet(); video.Snippet.Title = name; //video.Snippet.Description = info.Guid.ToString(); //maybe description will be //video.Snippet.Tags = new string[] { "tag1", "tag2" }; //maybe tags will be video.Snippet.CategoryId = "22"; video.Snippet.Description = YoutubeClip.GuidMarker(guid); video.Status = new VideoStatus(); video.Status.PrivacyStatus = "public"; var filePath = path.FullName; fileSize = path.Length; //нужно для расчета прогресса this.percentageUpdate = percentageUpdate; //"обновлятель" свойства string result = null; using (var fileStream = new FileStream(filePath, FileMode.Open)) { var videosInsertRequest = service.Videos.Insert(video, "snippet,status", fileStream, "video/*"); videosInsertRequest.ProgressChanged += OnProgressChanged; videosInsertRequest.ResponseReceived += v => { result = v.Id; }; videosInsertRequest.UploadAsync().RunSync(); } return(result); }
public void TestGuidDeletion(string before, string after, Guid guid) { var clip = new YoutubeClip { Description = before + "\n" + YoutubeClip.GuidMarker(guid) + "\n" + after }; clip.UpdateGuid(null); Assert.AreEqual(before + "\n\n" + after, clip.Description); }
public void TestGuidReplacement(string before, string after, Guid guid1, Guid guid2) { var clip = new YoutubeClip { Description = before + "\n" + YoutubeClip.GuidMarker(guid1) + "\n" + after }; clip.UpdateGuid(guid2); var expected = before + "\n" + YoutubeClip.GuidMarker(guid2) + "\n" + after; Assert.AreEqual(expected, clip.Description); }