• Earn real money by being active: Hello Guest, earn real money by simply being active on the forum — post quality content, get reactions, and help the community. Once you reach the minimum credit amount, you’ll be able to withdraw your balance directly. Learn how it works.

.NET [VB.Net] YouTube Video Downloader

Status
Not open for further replies.

sQuo

~ KillmeMories ~
Shadow
User
Joined
Oct 16, 2011
Messages
5,851
Reputation
0
Reaction score
22,904
Points
688
Credits
0
‎13 Years of Service‎
24%
Coded by Soul Collector + Resource

Code:
>'Coded by Soul Collector + Resource ;)

Imports System.Net

Public Class frmMain

   Private WithEvents download As WebClient
   Private Sub TheLink()
       Dim i As Integer
       Dim l As Integer
       Dim string1 As String
       i = rtb.Find("watch_fullscreen")
       l = rtb.Find("&title")
       rtb.Select(i, rtb.Text.Length)
       txturl.Text = rtb.SelectedText.ToString
       rtb.Select(l, rtb.Text.Length)
       string1 = rtb.SelectedText.ToString
       txturl.Text = txturl.Text.Replace(string1, "&")
       txturl.Text = txturl.Text.Insert(0, "http://www.youtube.com/get_video?")
   End Sub
   Private Sub done()
       lblDld.Text = "Downloaded: 0 Bytes"
       lblTitle.Text = "Video Title: "
       lblProgress.Text = "0%"
       ProgressBar1.Value = 0

   End Sub
   Private Sub download_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles download.DownloadProgressChanged
       ProgressBar1.Value = e.ProgressPercentage
       lblProgress.Text = e.ProgressPercentage & " %"
       lblDld.Text = e.BytesReceived & "Downloaded: " & e.TotalBytesToReceive & " Bytes"
       done()
       MsgBox("The video is downloaded.", MsgBoxStyle.Information, "")
 End Sub
   Private Sub WebBrowser1_Navigated(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles WebBrowser1.Navigated
       If WebBrowser1.Url.ToString.Contains("http://www.youtube.com/") Then
           lblTitle.Text = "Video Title: " & WebBrowser1.DocumentTitle
           lblTitle.Text = lblTitle.Text.Replace("YouTube - ", "")
           rtb.Text = WebBrowser1.DocumentText
           WebBrowser1.Navigate("about:blank")
       End If
   End Sub
   Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
       If MessageBox.Show("Do you really want to quit progress?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
           End
       Else
           Exit Sub
       End If
   End Sub
   Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
       If Not txturl.Text = "" Then
           If txturl.Text.Contains("http://www.youtube.com/watch?v") Then
               WebBrowser1.Navigate(TextBox1.Text)
           Else
               MsgBox("Please type in valid YouTube URL.", MsgBoxStyle.Exclamation, "")
               Exit Sub
           End If
       Else
           MsgBox("Please type in valid YouTube URL.", MsgBoxStyle.Exclamation, "")
           Exit Sub
       End If
   End Sub
   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       If txturl.Text.Contains("youtube.com") = False Then
           MsgBox("Please type in valid YouTube URL.", MsgBoxStyle.Exclamation, "")
           Exit Sub
       End If

       TheLink()
       Dim sdlg As New SaveFileDialog
       sdlg.Filter = "Flv Files |*.flv"
       sdlg.FileName = lblTitle.Text & ".flv"
       sdlg.ShowDialog()

       download = New WebClient
       Dim link = txturl.Text
       Dim SavePath = sdlg.FileName
       ProgressBar1.Value = 0
       ProgressBar1.Maximum = 100
       Try
           download.DownloadFileAsync(New Uri(link), (SavePath))
       Catch ex As Exception
           MsgBox("Cannot download the video, please check your URL.", MsgBoxStyle.Exclamation, "")
           Exit Sub
       End Try
   End Sub
End Class
 
Status
Not open for further replies.
Back
Top