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
|
2023-06-03 15:57:13 +02:00
|
|
|
|
Debug.WriteLine(CurlError)
|
|
|
|
|
Throw New System.Exception("Error - Getting" + vbNewLine + CurlError)
|
|
|
|
|
Return Nothing
|
2023-07-11 18:53:50 +02:00
|
|
|
|
ElseIf CBool(InStr(CurlOutput, "curl:")) Then
|
2023-06-03 15:57:13 +02:00
|
|
|
|
Debug.WriteLine(CurlOutput)
|
|
|
|
|
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 "
|
|
|
|
|
End If
|
2023-04-21 17:03:00 +02:00
|
|
|
|
cmd = cmd + "--no-alpn -fsSLm 15 -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
|
|
|
|
|
|
2023-07-15 20:54:20 +02:00
|
|
|
|
If CBool(InStr(CurlOutput, "curl:")) = True And CBool(InStr(CurlOutput, "400")) = True Then
|
|
|
|
|
Return CurlOutput
|
|
|
|
|
ElseIf CBool(InStr(CurlError, "curl:")) = True And CBool(InStr(CurlError, "400")) = True Then
|
|
|
|
|
Return CurlError
|
|
|
|
|
ElseIf CBool(InStr(CurlError, "curl:")) Then
|
2023-06-03 15:57:13 +02:00
|
|
|
|
Debug.WriteLine(CurlError)
|
|
|
|
|
Throw New System.Exception("Error - Getting" + vbNewLine + CurlError)
|
|
|
|
|
Return Nothing
|
2023-07-15 20:54:20 +02:00
|
|
|
|
|
2023-07-11 18:53:50 +02:00
|
|
|
|
ElseIf CBool(InStr(CurlOutput, "curl:")) Then
|
2023-06-03 15:57:13 +02:00
|
|
|
|
Debug.WriteLine(CurlOutput)
|
|
|
|
|
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-06-03 15:57:13 +02:00
|
|
|
|
Public Function CurlAuthNew(ByVal Url As String, ByVal Cookies As String, ByVal Auth As String, Optional ByVal Test As Boolean = False) As String
|
|
|
|
|
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
|
2023-04-21 17:03:00 +02:00
|
|
|
|
cmd = cmd + "--no-alpn -fsSLm 15 -A " + My.Settings.User_Agend.Replace("User-Agent: ", "") + 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
|
|
|
|
|
|
|
|
|
|
|
2023-05-04 18:48:37 +02:00
|
|
|
|
|
2023-07-11 18:53:50 +02:00
|
|
|
|
If CBool(InStr(CurlError, "curl:")) 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
|
2023-07-11 18:53:50 +02:00
|
|
|
|
ElseIf CBool(InStr(CurlOutput, "curl:")) Then
|
2023-06-03 15:57:13 +02:00
|
|
|
|
Debug.WriteLine(CurlOutput)
|
2023-04-09 09:31:16 +02:00
|
|
|
|
Throw New System.Exception("Error - Getting" + vbNewLine + CurlError)
|
|
|
|
|
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
|