Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pos = InStr(st(i), thecode, ending)
- Imports System.Net
- Private Sub btndown_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndown.Click
- dlgsav.FileName = vbNullString
- dlgsav.ShowDialog()
- If dlgsav.FileName <> vbNullString Then
- My.Computer.Network.DownloadFile(listvids.SelectedItems(0).Text, dlgsav.FileName, vbNullString, vbNullString, True, 5000, True)
- End If
- End Sub
- Private Function parselink(ByVal url As String) As String
- Dim i As Long
- Dim toreplace As String
- Dim tmp As String
- Dim thechar As String
- For i = 1 To Len(url) - 1
- tmp = Mid(url, 1, 1)
- If tmp = ("%") Then
- tmp = Mid(url, 1 + 1, 2)
- tmp = "&H" + tmp
- thechar = Chr(Val(tmp))
- toreplace = Mid(url, 1, 3)
- url = Replace(url, toreplace, thechar)
- End If
- Next
- parselink = url
- End Function
- Private Function getvalues(ByVal thecode As String, ByVal begining As String, ByVal ending As String)
- Dim st() As Integer
- Dim en() As Integer
- Dim result() As String
- Dim pos As Integer
- Dim i As Integer
- pos = InStr(thecode, begining)
- While pos > 0
- ReDim Preserve st(i)
- pos += Len(begining)
- st(i) = pos
- i += i
- pos = InStr(pos, thecode, begining)
- End While
- ReDim en(i)
- i = 0
- pos = InStr(st(i), thecode, ending)
- en(0) = pos
- For i = 1 To UBound(st)
- pos = InStr(st(i), thecode, ending)
- en(i) = pos
- Next
- ReDim result(i)
- For i = 0 To UBound(st)
- result(i) = parselink(Mid(thecode, st(i), en(i) - st(i)))
- Next
- getvalues = result
- End Function
- Private Function getbetween(ByVal asearch As String, ByVal astart As String, ByVal astop As String, Optional ByVal lsearch As Integer = 1)
- Dim ltemp As Long
- lsearch = InStr(lsearch, asearch, astart)
- If lsearch > 0 Then
- lsearch += Len(astart)
- ltemp = InStr(lsearch, asearch, astop)
- If ltemp > lsearch Then
- getbetween = Trim(Mid(asearch, lsearch, ltemp - lsearch))
- End If
- End If
- End Function
- Private 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
- Debug.WriteLine("ERROR :" + ex.Message)
- End Try
- Return s
- End Function
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- listvids.Columns.Add("URL", CInt(listvids.Width / 3))
- listvids.Columns.Add("Type", CInt(listvids.Width / 3))
- listvids.Columns.Add("Quality", CInt(listvids.Width / 3))
- listvids.View = View.Details
- End Sub
- Private Sub btngo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btngo.Click
- Dim objitem As ListViewItem
- Dim thesection As String
- Dim url() As String
- Dim type() As String
- Dim qual() As String
- Dim i As Integer
- Dim page As String = getpage(txtim.Text)
- thesection = getbetween(page, "yt.playerconfig = ", "):")
- url = getvalues(thesection, "url=", "")
- type = getvalues(thesection, "type=", "")
- qual = getvalues(thesection, "quality=", "")
- For i = 0 To UBound(url) - 1
- objitem = listvids.Items.Add(url(1))
- objitem.SubItems.Add(type(1))
- objitem.SubItems.Add(qual(1))
- Next
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement