Results 1 to 12 of 12

Hybrid View

  1. #1
    Blubb1337's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Germany
    Posts
    5,915
    Reputation
    161
    Thanks
    3,108
    Selfwritten?

    Thanks for sharing.



  2. #2
    MJLover's Avatar
    Join Date
    Feb 2010
    Gender
    male
    Location
    Neverland
    Posts
    759
    Reputation
    33
    Thanks
    110
    My Mood
    Cheerful

    Re: Self Written ?

    Encoder/Decoder is self written.

    The API tutorials aren't mine !!

    And you're welcome !

  3. #3
    MJLover's Avatar
    Join Date
    Feb 2010
    Gender
    male
    Location
    Neverland
    Posts
    759
    Reputation
    33
    Thanks
    110
    My Mood
    Cheerful

    Extract Youtube Title and Download Link

    This is how we can extract the Youtube Title:

    First we need to import the following namespaces:
    Code:
    Imports System.Net
    Imports System.IO
    Then add this function to the application. This function gets the source code of any webpage.

    Code:
    Function GetPage(ByVal pageUrl As String) As String
    Dim s As String = ""
    Try
    Dim request As HttpWebRequest = WebRequest.Create(pageUrl)
    Dim response As HttpWebResponse = request.GetResponse()
    Using reader As StreamReader = New StreamReader(response.GetResponseStream())
    s = reader.ReadToEnd()
    End Using
    Catch ex As Exception
    Throw New Exception("Failed to get source code !!!")
    End Try
    Return s
    Now we need to parse the source code to extract the data we need:

    First we extract the Video Title using the following function:
    'This function is optional and is not needed if you want to just download the video.

    Code:
    Function GetTitle(ByVal URL As String)
    Dim result As String = "Couldn't extract title !!"
    Try
    If Not URL = vbNullString Then
    Dim c As String = GetPage(URL)
    Dim a1 As Integer = c.IndexOf("<title>") + 8
    Dim a2 As Integer = c.IndexOf("</title>", a1)
    Dim title As String = Mid(c, a1, a2 - a1).Replace("YouTube", "")
    title = title.Trim
    title = title.Remove(0, 2)
    result = title
    End If
    Catch ex As Exception
    End Try
    Return result
    End Function
    Then we use the following function to extract the video's download link:

    Code:
    Function getDownloadLink(ByVal URL As String)
    Dim result As String = "Couldn't extract link !!"
    Try
    If Not URL = vbNullString Then
    Dim c As String = GetPage(URL)
    Dim a1 As Integer = c.IndexOf("'VIDEO_ID': '") + 14
    Dim a2 As Integer = c.IndexOf("'", a1) + 1
    Dim id As String = Mid(c, a1, a2 - a1)
    Dim a3 As Integer = c.IndexOf("""t"": """) + 7
    Dim a4 As Integer = c.IndexOf("""", a3) + 1
    Dim t As String = Mid(c, a3, a4 - a3)
    result = id & "&t=" & t
    End If
    Catch ex As Exception
    End Try
    Return result
    End Function
    This is all the code.

    Example:

    Code:
    System.Diagnostics.Process.Start("https://www.youtube.com/get_video?video_id=" & getDownloadLink("https://www.youtube.com/watch?v=u_0q0kL03Lg"))
    If you want to download the video in high quality, insert "&fmt=18" or in HD then insert "&fmt=22" at the end of the Video URL.

    Hope this helps !!

    Regards

  4. #4
    MJLover's Avatar
    Join Date
    Feb 2010
    Gender
    male
    Location
    Neverland
    Posts
    759
    Reputation
    33
    Thanks
    110
    My Mood
    Cheerful

    RE: Give Credits

    I googled all these functions long time ago so I don't know to whom these actually belong. I think originally they belong to Microsoft. If so, credits for API tutorials goes to Microsoft !!

Similar Threads

  1. Visual Basic Tutorials
    By NextGen1 in forum Programming Tutorials
    Replies: 1
    Last Post: 04-12-2012, 09:56 PM
  2. [Help] Visual Basic Tutorials
    By ¥øµñg&Ðång£r in forum CrossFire Hack Coding / Programming / Source Code
    Replies: 9
    Last Post: 05-02-2011, 08:27 PM
  3. [Tutorials] Mega Post of Visual Basic Tutorials !
    By Noxit in forum Visual Basic Programming
    Replies: 30
    Last Post: 09-02-2009, 09:09 PM
  4. C++ And Visual Basics Tutorial Vote
    By GG2GG in forum Programming Tutorials
    Replies: 6
    Last Post: 08-11-2009, 03:49 PM
  5. [Tutorial]Visual Basic 6 Many Options Tutorial by Yogilek.
    By yogilek in forum WarRock - International Hacks
    Replies: 4
    Last Post: 10-05-2007, 07:34 AM

Tags for this Thread