2023-04-09 09:31:16 +02:00
|
|
|
|
Imports System.IO
|
|
|
|
|
Imports System.Text
|
|
|
|
|
|
|
|
|
|
Module GetData
|
|
|
|
|
|
|
|
|
|
#Region "curl"
|
|
|
|
|
|
|
|
|
|
Public Function Curl(ByVal Url As String) As String
|
|
|
|
|
|
2023-06-03 15:57:13 +02:00
|
|
|
|
'MsgBox(Url)
|
|
|
|
|
|
2023-04-09 09:31:16 +02:00
|
|
|
|
Dim exepath As String = Path.Combine(Application.StartupPath, "lib", "curl.exe")
|
|
|
|
|
Dim startinfo As New System.Diagnostics.ProcessStartInfo
|
|
|
|
|
Dim sr As StreamReader
|
|
|
|
|
Dim sr2 As StreamReader
|
|
|
|
|
Dim cmd As String = ""
|
|
|
|
|
If Main.Curl_insecure = True Then
|
|
|
|
|
cmd = "--insecure "
|
|
|
|
|
End If
|
2023-04-21 17:03:00 +02:00
|
|
|
|
cmd = cmd + "--no-alpn -fsSLm 15 -A " + My.Settings.User_Agend.Replace("User-Agent: ", "") + " " + Chr(34) + Url + Chr(34)
|
2023-04-09 09:31:16 +02:00
|
|
|
|
Dim Proc As New Process
|
|
|
|
|
'MsgBox(cmd)
|
|
|
|
|
Dim CurlOutput As String = Nothing
|
|
|
|
|
Dim CurlError As String = Nothing
|
|
|
|
|
' all parameters required to run the process
|
|
|
|
|
startinfo.FileName = exepath
|
|
|
|
|
startinfo.Arguments = cmd
|
|
|
|
|
startinfo.UseShellExecute = False
|
|
|
|
|
startinfo.WindowStyle = ProcessWindowStyle.Normal
|
|
|
|
|
startinfo.RedirectStandardError = True
|
|
|
|
|
startinfo.RedirectStandardOutput = True
|
|
|
|
|
startinfo.CreateNoWindow = True
|
|
|
|
|
startinfo.StandardOutputEncoding = Encoding.UTF8
|
|
|
|
|
startinfo.StandardErrorEncoding = Encoding.UTF8
|
|
|
|
|
Proc.StartInfo = startinfo
|
|
|
|
|
Proc.Start() ' start the process
|
|
|
|
|
sr = Proc.StandardOutput 'standard error is used by ffmpeg
|
|
|
|
|
sr2 = Proc.StandardError
|
|
|
|
|
'sw = proc.StandardInput
|
|
|
|
|
|
|
|
|
|
Dim start, finish, pau As Double
|
|
|
|
|
start = CSng(Microsoft.VisualBasic.DateAndTime.Timer)
|
|
|
|
|
pau = 5
|
|
|
|
|
finish = start + pau
|
|
|
|
|
|
|
|
|
|
Do
|
|
|
|
|
CurlOutput = CurlOutput + sr.ReadToEnd
|
|
|
|
|
CurlError = CurlError + sr2.ReadToEnd
|
|
|
|
|
'ffmpegOutput2 = sr.ReadLine
|
|
|
|
|
'Debug.WriteLine(CurlOutput)
|
|
|
|
|
|
|
|
|
|
Loop Until Proc.HasExited Or Microsoft.VisualBasic.DateAndTime.Timer < finish
|
|
|
|
|
|
|
|
|
|
|
2023-07-11 18:53:50 +02:00
|
|
|
|
If CBool(InStr(CurlError, "curl:")) Then
|
2024-03-15 18:04:55 +01:00
|
|
|
|
Debug.WriteLine("CurlError: " + CurlError)
|
2023-06-03 15:57:13 +02:00
|
|
|
|
Throw New System.Exception("Error - Getting" + vbNewLine + CurlError)
|
|
|
|
|
Return Nothing
|
2023-07-11 18:53:50 +02:00
|
|
|
|
ElseIf CBool(InStr(CurlOutput, "curl:")) Then
|
2024-03-15 18:04:55 +01:00
|
|
|
|
Debug.WriteLine("CurlOutput: " + CurlOutput)
|
2023-06-03 15:57:13 +02:00
|
|
|
|
Throw New System.Exception("Error - Getting" + vbNewLine + CurlError)
|
|
|
|
|
Return Nothing
|
2023-04-09 09:31:16 +02:00
|
|
|
|
Else
|
2023-06-03 15:57:13 +02:00
|
|
|
|
Return CurlOutput
|
2023-04-09 09:31:16 +02:00
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
End Function
|
|
|
|
|
|
2023-07-15 20:54:20 +02:00
|
|
|
|
Public Function CurlPost(ByVal Url As String, ByVal Cookies As String, ByVal Auth As String, ByVal Post As String, ByVal Sender As String) As String
|
2023-04-09 09:31:16 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dim exepath As String = Path.Combine(Application.StartupPath, "lib", "curl.exe")
|
|
|
|
|
|
|
|
|
|
Dim startinfo As New System.Diagnostics.ProcessStartInfo
|
|
|
|
|
Dim sr As StreamReader
|
|
|
|
|
Dim sr2 As StreamReader
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dim cmd As String = ""
|
|
|
|
|
If Main.Curl_insecure = True Then
|
|
|
|
|
cmd = "--insecure "
|
2024-04-21 18:03:13 +02:00
|
|
|
|
End If '-fsSLm
|
2024-05-23 18:20:36 +02:00
|
|
|
|
cmd = cmd + "--no-alpn -sSLm 15 -w " + Chr(34) + "\nHTTP Status: %{http_code}\n" + Chr(34) + " -A " + My.Settings.User_Agend.Replace("User-Agent: ", "") + Cookies + Auth + Post + " " + Chr(34) + Url + Chr(34)
|
2023-04-09 09:31:16 +02:00
|
|
|
|
Dim Proc As New Process
|
|
|
|
|
'Debug.WriteLine("CurlPost: " + cmd)
|
|
|
|
|
Dim CurlOutput As String = Nothing
|
|
|
|
|
Dim CurlError As String = Nothing
|
|
|
|
|
' all parameters required to run the process
|
|
|
|
|
startinfo.FileName = exepath
|
|
|
|
|
startinfo.Arguments = cmd
|
|
|
|
|
startinfo.UseShellExecute = False
|
|
|
|
|
startinfo.WindowStyle = ProcessWindowStyle.Normal
|
|
|
|
|
startinfo.RedirectStandardError = True
|
|
|
|
|
startinfo.RedirectStandardOutput = True
|
|
|
|
|
startinfo.CreateNoWindow = True
|
|
|
|
|
startinfo.StandardOutputEncoding = Encoding.UTF8
|
|
|
|
|
startinfo.StandardErrorEncoding = Encoding.UTF8
|
|
|
|
|
Proc.StartInfo = startinfo
|
|
|
|
|
Proc.Start() ' start the process
|
|
|
|
|
sr = Proc.StandardOutput 'standard error is used by ffmpeg
|
|
|
|
|
sr2 = Proc.StandardError
|
|
|
|
|
'sw = proc.StandardInput
|
|
|
|
|
Dim start, finish, pau As Double
|
|
|
|
|
start = CSng(Microsoft.VisualBasic.DateAndTime.Timer)
|
|
|
|
|
pau = 5
|
|
|
|
|
finish = start + pau
|
|
|
|
|
|
|
|
|
|
Do
|
|
|
|
|
CurlOutput = CurlOutput + sr.ReadToEnd
|
|
|
|
|
CurlError = CurlError + sr2.ReadToEnd
|
|
|
|
|
'ffmpegOutput2 = sr.ReadLine
|
|
|
|
|
'Debug.WriteLine(CurlOutput)
|
|
|
|
|
|
|
|
|
|
Loop Until Proc.HasExited Or Microsoft.VisualBasic.DateAndTime.Timer < finish
|
|
|
|
|
|
2024-05-23 18:20:36 +02:00
|
|
|
|
If CurlOutput = Nothing And CurlError = Nothing Then
|
2024-01-28 12:09:00 +01:00
|
|
|
|
Throw New System.Exception("Error - Getting" + Sender + vbNewLine + CurlError)
|
2023-06-03 15:57:13 +02:00
|
|
|
|
Return Nothing
|
2024-05-23 18:32:31 +02:00
|
|
|
|
ElseIf CBool(InStr(CurlOutput, "HTTP Status: 4")) Then
|
|
|
|
|
Return CurlOutput
|
|
|
|
|
ElseIf CBool(InStr(CurlError, "HTTP Status: 4")) Then
|
|
|
|
|
Return CurlError
|
2024-05-23 18:20:36 +02:00
|
|
|
|
ElseIf CurlError = Nothing Then
|
|
|
|
|
Dim OutputBody() As String = CurlOutput.Split(New String() {"HTTP Status:"}, System.StringSplitOptions.RemoveEmptyEntries)
|
2024-05-23 18:32:31 +02:00
|
|
|
|
Dim Output As String = OutputBody(0)
|
|
|
|
|
Return Output
|
2023-04-09 09:31:16 +02:00
|
|
|
|
Else
|
2024-05-23 18:20:36 +02:00
|
|
|
|
Return CurlError
|
2023-04-09 09:31:16 +02:00
|
|
|
|
End If
|
|
|
|
|
|
2024-05-23 18:20:36 +02:00
|
|
|
|
|
2023-04-09 09:31:16 +02:00
|
|
|
|
End Function
|
|
|
|
|
|
|
|
|
|
|
2024-05-23 18:20:36 +02:00
|
|
|
|
Public Function CurlAuthNew(ByVal Url As String, ByVal Cookies As String, ByVal Auth As String, Optional ByVal Test As Boolean = False, Optional ByVal UserAgent As String = Chr(34) + "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/20100101 Firefox/126.0" + Chr(34)) As String
|
2023-06-03 15:57:13 +02:00
|
|
|
|
If Test = True Then
|
|
|
|
|
Throw New System.Exception("Error - Getting" + vbNewLine + "Test")
|
2023-04-09 09:31:16 +02:00
|
|
|
|
|
2023-06-03 15:57:13 +02:00
|
|
|
|
End If
|
2023-04-09 09:31:16 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dim exepath As String = Path.Combine(Application.StartupPath, "lib", "curl.exe")
|
|
|
|
|
|
|
|
|
|
Dim startinfo As New System.Diagnostics.ProcessStartInfo
|
|
|
|
|
Dim sr As StreamReader
|
|
|
|
|
Dim sr2 As StreamReader
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dim cmd As String = ""
|
|
|
|
|
If Main.Curl_insecure = True Then
|
|
|
|
|
cmd = "--insecure "
|
|
|
|
|
End If
|
2024-05-23 18:20:36 +02:00
|
|
|
|
cmd = cmd + "--no-alpn -sSLm 15 -w " + Chr(34) + "\nHTTP Status: %{http_code}\n" + Chr(34) + " -A " + UserAgent + Cookies + Auth + " " + Chr(34) + Url + Chr(34)
|
2023-04-09 09:31:16 +02:00
|
|
|
|
Dim Proc As New Process
|
|
|
|
|
'MsgBox(cmd)
|
|
|
|
|
Dim CurlOutput As String = Nothing
|
|
|
|
|
Dim CurlError As String = Nothing
|
|
|
|
|
' all parameters required to run the process
|
|
|
|
|
startinfo.FileName = exepath
|
|
|
|
|
startinfo.Arguments = cmd
|
|
|
|
|
startinfo.UseShellExecute = False
|
|
|
|
|
startinfo.WindowStyle = ProcessWindowStyle.Normal
|
|
|
|
|
startinfo.RedirectStandardError = True
|
|
|
|
|
startinfo.RedirectStandardOutput = True
|
|
|
|
|
startinfo.CreateNoWindow = True
|
|
|
|
|
startinfo.StandardOutputEncoding = Encoding.UTF8
|
|
|
|
|
startinfo.StandardErrorEncoding = Encoding.UTF8
|
|
|
|
|
Proc.StartInfo = startinfo
|
|
|
|
|
Proc.Start() ' start the process
|
|
|
|
|
sr = Proc.StandardOutput 'standard error is used by ffmpeg
|
|
|
|
|
sr2 = Proc.StandardError
|
|
|
|
|
'sw = proc.StandardInput
|
|
|
|
|
|
|
|
|
|
Dim start, finish, pau As Double
|
|
|
|
|
start = CSng(Microsoft.VisualBasic.DateAndTime.Timer)
|
|
|
|
|
pau = 5
|
|
|
|
|
finish = start + pau
|
|
|
|
|
|
|
|
|
|
Do
|
|
|
|
|
CurlOutput = CurlOutput + sr.ReadToEnd
|
|
|
|
|
CurlError = CurlError + sr2.ReadToEnd
|
|
|
|
|
'ffmpegOutput2 = sr.ReadLine
|
|
|
|
|
'Debug.WriteLine(CurlOutput)
|
|
|
|
|
|
|
|
|
|
Loop Until Proc.HasExited Or Microsoft.VisualBasic.DateAndTime.Timer < finish
|
|
|
|
|
|
|
|
|
|
|
2024-05-23 18:20:36 +02:00
|
|
|
|
If CBool(InStr(CurlError, "HTTP Status: 420")) Then
|
|
|
|
|
Return CurlError
|
|
|
|
|
ElseIf CBool(InStr(CurlOutput, "HTTP Status: 420")) Then
|
|
|
|
|
Return CurlOutput
|
|
|
|
|
ElseIf CBool(InStr(CurlError, "HTTP Status: 4")) Then
|
|
|
|
|
Debug.WriteLine(CurlError)
|
|
|
|
|
Throw New System.Exception("Error - Getting" + vbNewLine + CurlError)
|
|
|
|
|
Return Nothing
|
|
|
|
|
ElseIf CBool(InStr(CurlOutput, "HTTP Status: 4")) Then
|
|
|
|
|
Debug.WriteLine(CurlOutput)
|
|
|
|
|
Throw New System.Exception("Error - Getting" + vbNewLine + CurlOutput)
|
|
|
|
|
Return Nothing
|
|
|
|
|
Else
|
|
|
|
|
Dim OutputBody() As String = CurlOutput.Split(New String() {"HTTP Status:"}, System.StringSplitOptions.RemoveEmptyEntries)
|
|
|
|
|
Dim Output As String = OutputBody(0)
|
|
|
|
|
Return Output
|
|
|
|
|
End If
|
2023-05-04 18:48:37 +02:00
|
|
|
|
|
2024-05-23 18:20:36 +02:00
|
|
|
|
End Function
|
|
|
|
|
|
2024-05-29 22:57:59 +02:00
|
|
|
|
Public Function CurlDeleteNew(ByVal Url As String, ByVal Auth As String, Optional ByVal UserAgent As String = Chr(34) + "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/20100101 Firefox/126.0" + Chr(34)) As String
|
2024-05-23 18:20:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dim exepath As String = Path.Combine(Application.StartupPath, "lib", "curl.exe")
|
|
|
|
|
|
|
|
|
|
Dim startinfo As New System.Diagnostics.ProcessStartInfo
|
|
|
|
|
Dim sr As StreamReader
|
|
|
|
|
Dim sr2 As StreamReader
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dim cmd As String = ""
|
|
|
|
|
If Main.Curl_insecure = True Then
|
|
|
|
|
cmd = "--insecure "
|
|
|
|
|
End If
|
|
|
|
|
cmd = cmd + "--no-alpn -sSLm 15 -w " + Chr(34) + "\nHTTP Status: %{http_code}\n" + Chr(34) + " -A " + UserAgent + Auth + " -X DELETE " + Chr(34) + Url + Chr(34)
|
|
|
|
|
Dim Proc As New Process
|
|
|
|
|
'MsgBox(cmd)
|
|
|
|
|
Dim CurlOutput As String = Nothing
|
|
|
|
|
Dim CurlError As String = Nothing
|
|
|
|
|
' all parameters required to run the process
|
|
|
|
|
startinfo.FileName = exepath
|
|
|
|
|
startinfo.Arguments = cmd
|
|
|
|
|
startinfo.UseShellExecute = False
|
|
|
|
|
startinfo.WindowStyle = ProcessWindowStyle.Normal
|
|
|
|
|
startinfo.RedirectStandardError = True
|
|
|
|
|
startinfo.RedirectStandardOutput = True
|
|
|
|
|
startinfo.CreateNoWindow = True
|
|
|
|
|
startinfo.StandardOutputEncoding = Encoding.UTF8
|
|
|
|
|
startinfo.StandardErrorEncoding = Encoding.UTF8
|
|
|
|
|
Proc.StartInfo = startinfo
|
|
|
|
|
Proc.Start() ' start the process
|
|
|
|
|
sr = Proc.StandardOutput 'standard error is used by ffmpeg
|
|
|
|
|
sr2 = Proc.StandardError
|
|
|
|
|
'sw = proc.StandardInput
|
|
|
|
|
|
|
|
|
|
Dim start, finish, pau As Double
|
|
|
|
|
start = CSng(Microsoft.VisualBasic.DateAndTime.Timer)
|
|
|
|
|
pau = 5
|
|
|
|
|
finish = start + pau
|
|
|
|
|
|
|
|
|
|
Do
|
|
|
|
|
CurlOutput = CurlOutput + sr.ReadToEnd
|
|
|
|
|
CurlError = CurlError + sr2.ReadToEnd
|
|
|
|
|
'ffmpegOutput2 = sr.ReadLine
|
|
|
|
|
'Debug.WriteLine(CurlOutput)
|
|
|
|
|
|
|
|
|
|
Loop Until Proc.HasExited Or Microsoft.VisualBasic.DateAndTime.Timer < finish
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
If CBool(InStr(CurlError, "HTTP Status: 4")) Then
|
2023-06-03 15:57:13 +02:00
|
|
|
|
Debug.WriteLine(CurlError)
|
|
|
|
|
Throw New System.Exception("Error - Getting" + vbNewLine + CurlError)
|
2023-04-09 09:31:16 +02:00
|
|
|
|
Return Nothing
|
2024-05-23 18:20:36 +02:00
|
|
|
|
ElseIf CBool(InStr(CurlOutput, "HTTP Status: 4")) Then
|
2023-06-03 15:57:13 +02:00
|
|
|
|
Debug.WriteLine(CurlOutput)
|
2024-05-23 18:32:31 +02:00
|
|
|
|
Throw New System.Exception("Error - Getting" + vbNewLine + CurlOutput)
|
2023-04-09 09:31:16 +02:00
|
|
|
|
Return Nothing
|
|
|
|
|
Else
|
|
|
|
|
Return CurlOutput
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
End Function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#End Region
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Function FindExistingVideo(ByVal rootPath As String, ByVal searchString As String, ByVal original As String) As String
|
|
|
|
|
Dim Tracks As Integer = 0
|
|
|
|
|
Dim File As String = original
|
|
|
|
|
' Durchsuchen aller Dateien im angegebenen Verzeichnis und seinen Unterverzeichnissen
|
|
|
|
|
For Each filePath As String In Directory.GetFiles(rootPath, "*", SearchOption.AllDirectories)
|
|
|
|
|
' Überprüfen, ob der Dateiname den gesuchten Text enthält
|
|
|
|
|
If Path.GetFileName(filePath).Contains(searchString) Then
|
|
|
|
|
|
|
|
|
|
If FFMPEG_Audio(filePath) > Tracks Then
|
|
|
|
|
File = filePath
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
End If
|
|
|
|
|
Next
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Return File
|
|
|
|
|
End Function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
End Module
|