Wednesday, 12 December 2012

Create your own YouTube Video Downloader in Visual Basic.NET.

 [Image: sSvXx.png]
 In this tutorial, I'll be showing you how to create a YouTube Video Downloader using the webbrowser control in VB.NET.



Right, so this tutorial might be big, but it's easy...very easy.
Let's get started.
We're going to be using the website: http://www.fromyoutubemp4.com/ in our program.


[ Adding and positioning controls to your form. ]

First thing's first, open up Visual Studio, Visual Basic and create a new WindowsFormsApplication. Name it whatever you like.
Add one TextBox, a WebBrowser and 3 buttons to the form.
The TextBox is where the user will be inputting the YouTube video link.

Now, you should position the controls and rename the text on your buttons to the following (it doesn't really affect the program but it helps the user understand what each button is for.):

[Image: sSvXx.png]

[ Getting started with the coding. ]

Once you've done that, double click on "Navigate" and add the following code.
Code:
WebBrowser1.Navigate("http://www.fromyoutubemp4.com/")

Next, double click on "Enter" and add the following code.

WebBrowser1.Document.GetElementById("Form").SetAttribute("value", TextBox1.Text)
  Dim AllElements As HtmlElementCollection = WebBrowser1.Document.All
  For Each webpagelement As HtmlElement In AllElements
    'value of the button is Go
    If webpagelement.GetAttribute("value") = "Go" Then
    webpagelement.InvokeMember("click")
    End If
  Next
As you can see, the website textbox has a "name", and hence the value of TextBox1 can easily be attributed to it using the WebBrowser1.Document.GetElementById method. Unfortunately, this is not the case for the two buttons. We are therefore using a different method for the two of them.
Once that's done, double click on the final button, "Download", and add the following code.

WebBrowser1.Document.GetElementById("Form").SetAttribute("value", TextBox1.Text)
  Dim AllElements As HtmlElementCollection = WebBrowser1.Document.All
  For Each webpagelement As HtmlElement In AllElements
    'value="Download"
    If webpagelement.GetAttribute("value") = "Download" Then
    webpagelement.InvokeMember("click")
    End If

  Next



You can reduce the number of buttons to 1 using a few timers. I will not be explaining that in this tutorial, though.
Your YouTube video downloader is pretty much done. Of course, this is just to give you an understanding of how it works, it's a long way from being a completed program.

If you have any suggestions or questions, you can leave a reply here or you can just send me a private message.
Almost forgot, if you find this very difficult to do and just want the direct download link to the program:

**** my feet thrice and quit leeching.

Thanks for reading,
Arcane.cfg
 

All the posts found in this blog are meant either for educational purposes or are the personal opinions of myself (Arcanecfg). I do not condone any illegal activities whatsoever. I cannot be held responsible for any actions the readers of this blog may perform with the knowledge attained from here (Wasted Wolf). These Terms and Conditions of Use apply to you when you view, access or otherwise use the blog located at www.WastedWolf.com.

Theme designed by mono-lab / Edited by Arcanecfg.

DMCA.com Protection Status
/ Wasted Wolf /