Exemplo n.º 1
0
        public async Task YoutubeClient_DownloadClosedCaptionTrackAsync_Normal_Test()
        {
            var client    = new YoutubeClient();
            var videoInfo = await client.GetVideoInfoAsync("_QdPW8JrYzQ");

            var streamInfo = videoInfo.ClosedCaptionTracks.First();

            string outputFilePath = "DownloadClosedCaptionTrackAsync_Normal_Test_Output.bin";

            await client.DownloadClosedCaptionTrackAsync(streamInfo, outputFilePath);

            var fi = new FileInfo(outputFilePath);

            Assert.IsTrue(fi.Exists);
            Assert.AreNotEqual(0, fi.Length);
            fi.Delete();
        }
Exemplo n.º 2
0
        public async Task YoutubeClient_DownloadClosedCaptionTrackAsync_Test(string videoId)
        {
            var client = new YoutubeClient();

            var closedCaptionTrackInfos = await client.GetVideoClosedCaptionTrackInfosAsync(videoId);

            var trackInfo      = closedCaptionTrackInfos.First();
            var outputFilePath = Path.Combine(_tempDirPath, Guid.NewGuid().ToString());

            Directory.CreateDirectory(_tempDirPath);
            await client.DownloadClosedCaptionTrackAsync(trackInfo, outputFilePath);

            var fileInfo = new FileInfo(outputFilePath);

            Assert.That(fileInfo.Exists, Is.True);
            Assert.That(fileInfo.Length, Is.GreaterThan(0));
        }
Exemplo n.º 3
0
        public async Task YoutubeClient_DownloadClosedCaptionTrackAsync_Test()
        {
            string id = (string)TestContext.DataRow["Id"];

            var client    = new YoutubeClient();
            var videoInfo = await client.GetVideoInfoAsync(id);

            var    streamInfo     = videoInfo.ClosedCaptionTracks.First();
            string outputFilePath = Path.Combine(Shared.TempDirectoryPath, Guid.NewGuid().ToString());

            Directory.CreateDirectory(Shared.TempDirectoryPath);
            await client.DownloadClosedCaptionTrackAsync(streamInfo, outputFilePath);

            var fileInfo = new FileInfo(outputFilePath);

            Assert.IsTrue(fileInfo.Exists);
            Assert.IsTrue(0 < fileInfo.Length);
        }