Beispiel #1
0
    public async Task User_can_download_a_video_with_subtitles_into_a_single_webm_file()
    {
        // Arrange
        var youtube        = new YoutubeClient();
        var outputFilePath = _tempOutputFixture.GetTempFilePath();

        var streamManifest = await youtube.Videos.Streams.GetManifestAsync("YltHGKX80Y8");

        var trackManifest = await youtube.Videos.ClosedCaptions.GetManifestAsync("YltHGKX80Y8");

        var streamInfos = new[]
        {
            streamManifest.GetVideoStreams().OrderBy(s => s.Size).First(s => s.Container == Container.WebM)
        };

        var trackInfos = trackManifest.Tracks;

        // Act
        await youtube.Videos.DownloadAsync(
            streamInfos,
            trackInfos,
            new ConversionRequestBuilder(outputFilePath)
            .SetFFmpegPath(_ffmpegFixture.FilePath)
            .SetContainer("webm")
            .Build()
            );

        // Assert
        MediaFormat.IsWebMFile(outputFilePath).Should().BeTrue();

        foreach (var trackInfo in trackInfos)
        {
            FileEx.ContainsBytes(outputFilePath, Encoding.ASCII.GetBytes(trackInfo.Language.Name)).Should().BeTrue();
        }
    }
Beispiel #2
0
    public async Task User_can_download_a_video_by_merging_best_streams_into_a_single_webm_file()
    {
        // Arrange
        var youtube        = new YoutubeClient();
        var outputFilePath = Path.ChangeExtension(_tempOutputFixture.GetTempFilePath(), "webm");

        // Act
        await youtube.Videos.DownloadAsync("5NmxuoNyDss", outputFilePath);

        // Assert
        MediaFormat.IsWebMFile(outputFilePath).Should().BeTrue();
    }