static async Task Main(string[] args) { var httpClientForYoutubeClient = new HttpClient(); var youtubeClient = new YoutubeClient(httpClientForYoutubeClient); var videoId = VideoId.Parse("https://www.youtube.com/watch?v=spVJOzF0EJ0"); var streams = await youtubeClient.Videos.Streams.GetManifestAsync(videoId); var streamInfo = streams.GetAudioOnlyStreams().TryGetWithHighestBitrate(); if (streamInfo is null) { Console.WriteLine("This video has no AudioOnlyStreams"); } else { Console.WriteLine(streamInfo.Bitrate); Console.WriteLine(streamInfo.Url); Console.WriteLine("DownloadAsync start " + DateTime.Now); await youtubeClient.Videos.Streams.DownloadAsync(streamInfo, "c:\\temp\\x.webm"); Console.WriteLine("DownloadAsync end " + DateTime.Now); } }
public void Video_ID_can_be_parsed_from_a_URL_string(string videoUrl, string expectedVideoId) { // Act var parsed = VideoId.Parse(videoUrl); // Assert parsed.Value.Should().Be(expectedVideoId); }
public void Video_ID_can_be_parsed_from_an_ID_string(string videoId) { // Act var parsed = VideoId.Parse(videoId); // Assert parsed.Value.Should().Be(videoId); }
public async ValueTask <Video> GetVideoByLink(string link) { VideoId videoId = VideoId.Parse(link); var valueTask = _client.Videos.GetAsync(videoId); await valueTask; Video video = valueTask.Result; return(video); }
public static async Task <int> Main() { Console.Title = "YoutubeExplode Demo"; var youtube = new YoutubeClient(); // Read the video ID Console.Write("Enter YouTube video ID or URL: "); var videoId = VideoId.Parse(Console.ReadLine() ?? ""); // Get available streams and choose the best muxed (audio + video) stream var streamManifest = await youtube.Videos.Streams.GetManifestAsync(videoId); var streamInfo = streamManifest.GetMuxedStreams().TryGetWithHighestVideoQuality(); if (streamInfo is null) { // Available streams vary depending on the video and // it's possible there may not be any muxed streams. Console.Error.WriteLine("This video has no muxed streams."); return(1); } // Download the stream Console.Write( $"Downloading stream: {streamInfo.VideoQuality.Label} / {streamInfo.Container.Name}... " ); var fileName = $"{videoId}.{streamInfo.Container.Name}"; using (var progress = new InlineProgress()) // display progress in console await youtube.Videos.Streams.DownloadAsync(streamInfo, fileName, progress); Console.WriteLine($"Video saved to '{fileName}'"); return(0); }
public void Video_ID_cannot_be_parsed_from_an_invalid_string(string videoId) { // Act & assert Assert.Throws <ArgumentException>(() => VideoId.Parse(videoId)); }
public async Task <Utils.ExtendedVideo> GetExtendedVideo(string url) { VideoId videoId = VideoId.Parse(url); return(new Utils.ExtendedVideo(await client.Videos.GetAsync(videoId), GetVideoSettings(videoId))); }
public async Task <Video> GetVideo(string url) { return(await client.Videos.GetAsync(VideoId.Parse(url))); }
private async void onManualPrompt(string SpotifyTrackID, string YoutubeTrackID) { MusixSongResult result = new MusixSongResult() { SpotifyTrack = MainWindow.Instance.Client.GetTrackByID(SpotifyTrackID), YoutubeVideo = await MainWindow.Instance.Client.YouTube.Videos.GetAsync(VideoId.Parse(YoutubeTrackID)) }; AddMusixEntry(result); }