Youtubeexplode: Please write the program for me

Created on 9 May 2018  路  5Comments  路  Source: Tyrrrz/YoutubeExplode

Hey, first of all i would thank you for such a great work!
So i used VideoLibrary but since i faced some trouble with downloading exact video i came here...
Please can u edit the following code to download only the sound as mp3 and to save it on desktop, i want to download a video in the fastest way to play it's sound (i would prefer to download it at 480p quality or something near) Thanks in advance!

var url = "https://www.youtube.com/watch?v=Euz1F0MG494"; var id = YoutubeClient.ParseVideoId(url); // "bnsUkE8i0tU" var client = new YoutubeClient(); var streamInfoSet = await client.GetVideoMediaStreamInfosAsync("bnsUkE8i0tU"); var streamInfo = streamInfoSet.Muxed.WithHighestVideoQuality(); var ext = streamInfo.Container.GetFileExtension(); await client.DownloadMediaStreamAsync(streamInfo, $"downloaded_video.{ext}"); MessageBox.Show("Done");

question

Most helpful comment

One last thing, how can i save it on desktop (it would be better if i can play it without any need to wait for that), i nearly figured that but it says access to path is denied!

All 5 comments

If you only want audio, use streamInfoSet.Audio.WithHighestBitrate() instead.

I'm working on this project for 3 hours, and I haven't tried to change the quality of the video. But this Issue seems to be interesting, I want to know how to change quality too...

One last thing, how can i save it on desktop (it would be better if i can play it without any need to wait for that), i nearly figured that but it says access to path is denied!

  1. You can save it by replacing this:

await client.DownloadMediaStreamAsync(streamInfo, Environment.SpecialFolder.Desktop + $".{ext}");

  1. If you can't do that way, then go and add from toolbox: 1 Textbox, 1 FolderBrowserDialog, 1 Button

When you click button then:

     private void button1_Click(object sender, EventArgs e)
    {
        DialogResult result = folderBrowserDialog1.ShowDialog(); //Locate to Dekstop

        if (result == DialogResult.OK)
        {
            textBox1.Text = folderBrowserDialog1.SelectedPath;
        }
    }

Then replace it like this:

await client.DownloadMediaStreamAsync(streamInfo, textBox1.Text + $".{ext}");

You can filter by stream qualities using LINQ, e.g. streamInfoSet.Video.Where(s => s.VideoQuality > VideoQuality.Medium360).Where(s => s.VideoQuality <= VideoQuality.High1080) will filter the video streams to those of quality between 480p and 1080p inclusively.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dev45 picture dev45  路  5Comments

vsjtechnologies picture vsjtechnologies  路  7Comments

Tyrrrz picture Tyrrrz  路  3Comments

KrSiddharth picture KrSiddharth  路  5Comments

ac-lap picture ac-lap  路  7Comments