Advertisement
Guest User

Untitled

a guest
Oct 25th, 2014
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.54 KB | None | 0 0
  1. pos = InStr(st(i), thecode, ending)
  2.  
  3. Imports System.Net
  4.  
  5. Private Sub btndown_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndown.Click
  6. dlgsav.FileName = vbNullString
  7. dlgsav.ShowDialog()
  8. If dlgsav.FileName <> vbNullString Then
  9. My.Computer.Network.DownloadFile(listvids.SelectedItems(0).Text, dlgsav.FileName, vbNullString, vbNullString, True, 5000, True)
  10.  
  11. End If
  12. End Sub
  13. Private Function parselink(ByVal url As String) As String
  14. Dim i As Long
  15. Dim toreplace As String
  16. Dim tmp As String
  17. Dim thechar As String
  18. For i = 1 To Len(url) - 1
  19. tmp = Mid(url, 1, 1)
  20. If tmp = ("%") Then
  21. tmp = Mid(url, 1 + 1, 2)
  22. tmp = "&H" + tmp
  23. thechar = Chr(Val(tmp))
  24. toreplace = Mid(url, 1, 3)
  25. url = Replace(url, toreplace, thechar)
  26.  
  27. End If
  28. Next
  29. parselink = url
  30. End Function
  31. Private Function getvalues(ByVal thecode As String, ByVal begining As String, ByVal ending As String)
  32. Dim st() As Integer
  33. Dim en() As Integer
  34. Dim result() As String
  35. Dim pos As Integer
  36. Dim i As Integer
  37.  
  38. pos = InStr(thecode, begining)
  39. While pos > 0
  40. ReDim Preserve st(i)
  41. pos += Len(begining)
  42. st(i) = pos
  43. i += i
  44. pos = InStr(pos, thecode, begining)
  45. End While
  46.  
  47. ReDim en(i)
  48. i = 0
  49. pos = InStr(st(i), thecode, ending)
  50. en(0) = pos
  51. For i = 1 To UBound(st)
  52. pos = InStr(st(i), thecode, ending)
  53. en(i) = pos
  54. Next
  55.  
  56. ReDim result(i)
  57. For i = 0 To UBound(st)
  58. result(i) = parselink(Mid(thecode, st(i), en(i) - st(i)))
  59.  
  60. Next
  61. getvalues = result
  62. End Function
  63.  
  64. Private Function getbetween(ByVal asearch As String, ByVal astart As String, ByVal astop As String, Optional ByVal lsearch As Integer = 1)
  65. Dim ltemp As Long
  66. lsearch = InStr(lsearch, asearch, astart)
  67. If lsearch > 0 Then
  68. lsearch += Len(astart)
  69. ltemp = InStr(lsearch, asearch, astop)
  70. If ltemp > lsearch Then
  71. getbetween = Trim(Mid(asearch, lsearch, ltemp - lsearch))
  72. End If
  73. End If
  74. End Function
  75.  
  76. Private Function getpage(ByVal pageurl As String) As String
  77. Dim s As String = ""
  78. Try
  79. Dim request As HttpWebRequest = WebRequest.Create(pageurl)
  80. Dim response As HttpWebResponse = request.GetResponse()
  81. Using reader As StreamReader = New StreamReader(response.GetResponseStream)
  82. s = reader.ReadToEnd
  83. End Using
  84.  
  85.  
  86.  
  87.  
  88. Catch ex As Exception
  89. Debug.WriteLine("ERROR :" + ex.Message)
  90.  
  91. End Try
  92. Return s
  93. End Function
  94.  
  95. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  96. listvids.Columns.Add("URL", CInt(listvids.Width / 3))
  97. listvids.Columns.Add("Type", CInt(listvids.Width / 3))
  98. listvids.Columns.Add("Quality", CInt(listvids.Width / 3))
  99. listvids.View = View.Details
  100. End Sub
  101.  
  102. Private Sub btngo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btngo.Click
  103. Dim objitem As ListViewItem
  104. Dim thesection As String
  105. Dim url() As String
  106. Dim type() As String
  107. Dim qual() As String
  108. Dim i As Integer
  109. Dim page As String = getpage(txtim.Text)
  110.  
  111. thesection = getbetween(page, "yt.playerconfig = ", "):")
  112. url = getvalues(thesection, "url=", "")
  113. type = getvalues(thesection, "type=", "")
  114. qual = getvalues(thesection, "quality=", "")
  115.  
  116. For i = 0 To UBound(url) - 1
  117. objitem = listvids.Items.Add(url(1))
  118. objitem.SubItems.Add(type(1))
  119. objitem.SubItems.Add(qual(1))
  120.  
  121. Next
  122.  
  123. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement