Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. Option Strict On
  2. Imports System.IO
  3. Imports MultiUpload_Uploader.Utility.Http
  4. Imports System.Text.RegularExpressions
  5. Imports System.Collections.Specialized
  6.  
  7. Namespace API
  8.     ''' <summary>
  9.     ''' For uploading files to http://www.multiupload.nl
  10.     ''' Coded By: loyalty
  11.     '''  Contact: loyalty.exe@gmail.com
  12.     '''  Website: http://loyaltyHF.blogspot.com
  13.     '''  Credits: idb for his HTTP Class (http://s.olution.cc)
  14.     ''' </summary>
  15.     Public Class MultiUpload
  16.         Implements IDisposable
  17.  
  18. #Region "Debug Const"
  19. #Const DEBUG = False
  20. #End Region
  21.  
  22. #Region "Declerations"
  23.         Private Http As Utility.Http = Nothing
  24. #End Region
  25.  
  26. #Region "Structures"
  27.         Public Structure Result
  28.             Dim Success As Boolean
  29.             Dim ErrMsg As String
  30.             Dim Link As String
  31.             Dim Info As String
  32.         End Structure
  33. #End Region
  34.  
  35. #Region "Constructor"
  36.         Sub New()
  37.             NewSession()
  38.         End Sub
  39. #End Region
  40.  
  41. #Region "Private Methods"
  42.         Private Sub NewSession()
  43.             If Not IsNothing(Http) Then Http.Dispose()
  44.             Http = New Utility.Http
  45.         End Sub
  46.  
  47.         Private Function GetInfo() As String()
  48.             Dim res As HttpResponse = Http.GetResponse(Verb.GET, "http://www.multiupload.nl/")
  49.             If IsNothing(res.Error) Then
  50.                 Dim Mat As Match = Regex.Match(res.Html, "action=""(?<url>http://.*?)/progress/\?id=(?<id>.*?)""")
  51.                 Return New String() {Mat.Groups("url").Value, Mat.Groups("id").Value}
  52.             Else
  53.                 Return New String() {}
  54.             End If
  55.         End Function
  56.  
  57.         Private Function UploadData(ByVal path As String) As UploadData()
  58.             Dim UploadArgs As New List(Of UploadData)
  59.             UploadArgs.Add(New UploadData(File.ReadAllBytes(path), path.Substring(path.LastIndexOf("\") + 1), "file_0"))
  60.             For i = 1 To 9
  61.                 UploadArgs.Add(New UploadData(Nothing, "", "file_" & i))
  62.             Next
  63.             Return UploadArgs.ToArray
  64.         End Function
  65.  
  66.         Private Function FieldsInfo(ByVal Description As String, ByVal id As String) As NameValueCollection
  67.             Dim Fields As New NameValueCollection
  68.             Fields.Add("UPLOAD_IDENTIFIER", id)
  69.             Fields.Add("u", "")
  70.             Fields.Add("description_0", Description)
  71.             Fields.Add("fetchfield0", "")
  72.             Fields.Add("fetchdesc0", "")
  73.             For i = 1 To 9
  74.                 Fields.Add("description_" & i, "")
  75.             Next
  76.             For i = 1 To 9
  77.                 Fields.Add("fetchfield" & i, "http://")
  78.                 Fields.Add("fetchdesc" & i, "")
  79.             Next
  80.             Fields.Add("service_7", "1")
  81.             Fields.Add("service_19", "1")
  82.             Fields.Add("service_27", "1")
  83.             Fields.Add("service_24", "1")
  84.             Fields.Add("service_26", "1")
  85.             Fields.Add("service_28", "1")
  86.             Fields.Add("fromemail", "")
  87.             Fields.Add("toemail", "")
  88.             Fields.Add("username_7", "")
  89.             Fields.Add("password_7", "")
  90.             Fields.Add("remember_7", "1")
  91.             Return Fields
  92.         End Function
  93.  
  94. #End Region
  95.  
  96. #Region "Public Methods"
  97.         Public Function Upload(ByVal path As String, ByVal Description As String) As Result
  98.             Dim Result As New Result
  99.             Try
  100.                 If Not String.IsNullOrEmpty(path) Then
  101.                     Dim Info As String() = GetInfo()
  102.                     If Info.Length = 2 Then
  103.                         Dim URL As String = Info(0)
  104.                         Dim ID As String = Info(1)
  105. #If DEBUG Then
  106.                         Debug.WriteLine(ID)
  107.                         Debug.WriteLine(URL)
  108. #End If
  109.  
  110.  
  111.  
  112.                         With Http
  113.                             .Referer = "http://wwww.multiupload.nl/"
  114.                             Dim res As HttpResponse = .GetResponse(Verb.POST, String.Format("{0}/progress/?id={1}", URL, ID), String.Format("random={0}&t=", TimeStampLong))
  115.                             If IsNothing(res.Error) Then
  116.                                 res = .GetResponse(Verb.POST, String.Format("{0}/upload/?UPLOAD_IDENTIFIER={1}", URL, ID), Nothing, FieldsInfo(Description, ID), UploadData(path))
  117.                                 If IsNothing(res.Error) Then
  118.                                     Dim m As Match = Regex.Match(res.Html, """downloadid"":""(?<download>.*?)"",""filesize"":""(?<size>.*?)"",""filename"":""(?<name>.*?)""")
  119.                                     Result.Link = "http://wwww.multiupload.nl/" & m.Groups("download").Value
  120.                                     Result.Info = String.Format("Name: {0}{1}Size: {2}", m.Groups("name").Value, vbCrLf, m.Groups("size").Value)
  121.                                     If Result.Link.Length > "http://wwww.multiupload.nl/".Length Then
  122.                                         Result.Success = True
  123.                                     End If
  124. #If DEBUG Then
  125.                                     Debug.WriteLine(res.Html)
  126. #End If
  127.                                 Else
  128. #If DEBUG Then
  129.                                     Debug.WriteLine(res.Error.Message)
  130.                                     Debug.WriteLine(res.Error.Html)
  131. #End If
  132.                                 End If
  133.                             Else
  134.                                 Result.ErrMsg = res.Error.Message
  135. #If DEBUG Then
  136.                                 Debug.WriteLine(res.Error.Message)
  137.                                 Debug.WriteLine(res.Error.Html)
  138. #End If
  139.                             End If
  140.                         End With
  141.                     Else
  142.                         Result.ErrMsg = "Unable to get the UID"
  143.                     End If
  144.                 Else
  145.                     Result.ErrMsg = "Invalid Path!"
  146.                 End If
  147.             Catch ex As Exception
  148.                 Result.ErrMsg = ex.Message
  149.             End Try
  150.             Return Result
  151.         End Function
  152. #End Region
  153.  
  154. #Region "Destructor"
  155.  
  156.         Private disposedValue As Boolean
  157.         Protected Overridable Sub Dispose(ByVal disposing As Boolean)
  158.             If Not Me.disposedValue Then
  159.                 If disposing Then
  160.                     If Not IsNothing(Http) Then Http.Dispose()
  161.                     Http = Nothing
  162.                 End If
  163.             End If
  164.             Me.disposedValue = True
  165.         End Sub
  166.  
  167.         Public Sub Dispose() Implements IDisposable.Dispose
  168.             Dispose(True)
  169.             GC.SuppressFinalize(Me)
  170.         End Sub
  171. #End Region
  172.  
  173.     End Class
  174. End Namespace