Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[VB.Net] YouTube Video Downloader
#1

YouTube video Downloader - Fixed


Hello everyone. This is just simple example of YouTube Downloader, coded in Visual Basic .NET aka. Visual Basic 2008. Enjoy Cool

What we need:
RichTextBox1 - Name: rtb
RichTextBox2 - Name: txturl
WebBrowser1
Proggressbar1
TextBox1
Button1 (Text: Validate)
Button2 (Text: Download)
Button3 (Text: Cancel)

Screnshot:
[Image: 23kqfee.jpg]


Source Codes:
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

Download Source:
http://www.multiupload.com/S4S3V9W7CK
Reply
#2
thanks for the source code, shall give this a go, looks great to use
[Image: Navineous.gif]
Reply
#3
i had another program YouTube Downloader but this is nice too! Confusedmile:
[Image: gameoverp.png]
Reply
#4
Thanks for the source. It will come in handy.
Reply
#5
Very nice! Alot of people have been searching for like this program for long time. If someone wants to download a song from youtube. I Will recommend http://www.video2mp3.net/index.php its a very nice site that is downloading the video and converting the video into a mp3 file Big Grin
Reply
#6
Thanks for the source, I'll try an built it later, I like this one cause it has a progress bar, an I'll be able to customize it.
Reply
#7
Thanks for the source code sc.
Reply
#8
Hmm , tried it it doesn't work for me.. Maybe i did something wrong..?
Reply
#9
thanks For Sharing Smile
If you are willing to join SF Webmasters.
Reply
#10
Thank's for sharing the source mate..
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [VB.Net][SRC] YouTube Bot HF~Legend 5 3,379 11-25-2012, 05:54 AM
Last Post: Ixam
  [Preview/] YouTube Downloader and Converter full FFMPEG, Massive conversion list 2012 FizzyMentos 3 2,039 02-04-2012, 02:35 PM
Last Post: Denny Crane
  [TUT]$hareCash Downloader[NEW] Prominent 41 10,596 10-11-2011, 04:27 PM
Last Post: Genuine
  Help Coding A Downloader? Fragma 9 2,768 08-25-2011, 06:10 PM
Last Post: LiveModz
  [VB] File Downloader With ProgressBar[VB] Coding Support 16 7,325 07-30-2011, 09:13 AM
Last Post: Trustable

Forum Jump:


Users browsing this thread: 1 Guest(s)