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 TestPrefix(string prefix, string result) { var clip = new YoutubeClip { Name = prefix + result }; Assert.AreEqual(result, clip.GetProperName()); }
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 UpdateVideoThumbnail(YoutubeClip clip, FileInfo image) { // Create an API request that specifies that the mediaContent // object is the thumbnail of the specified video. using (var stream = File.Open(image.FullName, FileMode.Open)) { var thumbnailSet = service.Thumbnails.Set(clip.Id, stream, "image/png"); thumbnailSet.Upload(); } }
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); }
public void TestGuidAddition(string desc, Guid guid) { var clip = new YoutubeClip { Description = desc }; clip.UpdateGuid(guid); string expected = desc + "\n" + "[GUID: " + guid + "]"; Assert.AreEqual(expected, clip.Description); }
public void UpdateVideo(YoutubeClip clip) { var listRq = service.Videos.List("snippet"); listRq.Id = clip.Id; var video = listRq.Execute().Items[0]; video.Snippet.Title = clip.Name; video.Snippet.Description = clip.Description; video.Snippet.Tags = null; service.Videos.Update(video, "snippet").Execute(); }