2

I want to give a videoId to Youtube API and get thumbnails to save in my folder.

http://img.youtube.com/vi/VideoId/3.jpg gives us thumbnail but how can save it?

That is to say; I have a textbox which I will write YoutubevideoId and after that by clicking a button I want to get thumbnail and save it to a physical folder.

UserStackk
  • 75
  • 1
  • 2
  • 7
  • Welcome to Stack Overflow! Please show us what you've tried so far. – germi Dec 18 '13 at 07:46
  • Take a look at http://stackoverflow.com/questions/15702031/get-thumbnail-image-of-video-file-in-c-sharp and http://stackoverflow.com/questions/10131693/how-can-i-get-thumbnail-of-youtube-video-on-my-application-in-windows-phone-7 – Soner Gönül Dec 18 '13 at 07:49
  • possible duplicate of [How to get thumbnail of YouTube video link using YouTube API?](http://stackoverflow.com/questions/2068344/how-to-get-thumbnail-of-youtube-video-link-using-youtube-api) – N K Dec 18 '13 at 07:54
  • Are there any c# function which takes jpg link and save it to the physical foldeR? – UserStackk Dec 18 '13 at 07:56

1 Answers1

3

Here you go my friend

WebClient cli = new WebClient();

var imgBytes = cli.DownloadData("http://img.youtube.com/vi/VideoId/3.jpg");

File.WriteAllBytes(@"C:\Folder\file.jpg", imgBytes);

C# has a class named WebClient, it has a method DownloadData which allows you to download content from the internet...

So, by creating an instance of it and calling DownloadData passing the URL I want to download the bytes you can get the bytes you need.

Now, you can use File.WriteAllBytes which will write the bytes to a file in your disk.

BrunoLM
  • 97,872
  • 84
  • 296
  • 452
  • Note that http://img.youtube.com/vi/VideoId/3.jpg is NOT returning a valid thumbnail. To get the REAL thumbnail of the video use replace the ``3.jpg`` with ``hqdefault.jpg``. So it looks like this: http://img.youtube.com/vi/VideoId/hqdefault.jpg – Fido_de07 Jul 12 '23 at 12:58