mirror of
https://github.com/hama3254/Crunchyroll-Downloader-v3.0.git
synced 2024-11-15 04:35:06 +01:00
c50ec6454c
reorganized some code parts
234 lines
8.1 KiB
VB.net
234 lines
8.1 KiB
VB.net
Imports System.IO
|
|
Imports System.Text
|
|
|
|
Module GetData
|
|
|
|
#Region "curl"
|
|
|
|
Public Function Curl(ByVal Url As String) As String
|
|
|
|
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 -fsSLm 15 -A " + My.Resources.ffmpeg_user_agend.Replace("User-Agent: ", "") + " " + 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 CurlOutput = Nothing And CurlError = Nothing Then
|
|
Debug.WriteLine("curl-E: " + "curl: ")
|
|
Return CurlError
|
|
ElseIf CurlOutput = Nothing And CurlError IsNot Nothing Then
|
|
Debug.WriteLine("curl-E: " + CurlError)
|
|
Return CurlError
|
|
ElseIf CurlOutput IsNot Nothing And CurlError = Nothing Then
|
|
Debug.WriteLine("curl-O: " + CurlOutput)
|
|
Return CurlOutput
|
|
ElseIf CurlOutput IsNot Nothing And CurlError IsNot Nothing Then
|
|
Debug.WriteLine("curl-O: " + CurlOutput)
|
|
Return CurlOutput
|
|
Else
|
|
Debug.WriteLine("curl-E: " + "curl: ")
|
|
Return CurlError
|
|
End If
|
|
|
|
|
|
End Function
|
|
|
|
Public Function CurlPost(ByVal Url As String, ByVal Cookies As String, ByVal Auth As String, ByVal Post As String) As String
|
|
|
|
|
|
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 -fsSLm 15 -A " + My.Resources.ffmpeg_user_agend.Replace("User-Agent: ", "") + Cookies + Auth + Post + " " + Chr(34) + Url + Chr(34)
|
|
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
|
|
|
|
|
|
If CurlOutput = Nothing And CurlError = Nothing Then
|
|
Debug.WriteLine("CurlPost-E: " + "curl: ")
|
|
Return CurlError
|
|
ElseIf CurlOutput = Nothing And CurlError IsNot Nothing Then
|
|
Debug.WriteLine("CurlPost-E: " + CurlError)
|
|
Return CurlError
|
|
ElseIf CurlOutput IsNot Nothing And CurlError = Nothing Then
|
|
Debug.WriteLine("CurlPost-O: " + CurlOutput)
|
|
Return CurlOutput
|
|
ElseIf CurlOutput IsNot Nothing And CurlError IsNot Nothing Then
|
|
Debug.WriteLine("CurlPost-O: " + CurlOutput)
|
|
Return CurlOutput
|
|
Else
|
|
Debug.WriteLine("CurlPost-E: " + "curl: ")
|
|
Return CurlError
|
|
End If
|
|
|
|
End Function
|
|
|
|
|
|
Public Function CurlAuthNew(ByVal Url As String, ByVal Cookies As String, ByVal Auth As String) As String
|
|
|
|
|
|
|
|
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 -fsSLm 15 -A " + My.Resources.ffmpeg_user_agend.Replace("User-Agent: ", "") + Cookies + Auth + " " + 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 CurlOutput = Nothing Or CBool(InStr(CurlOutput, "curl")) Then
|
|
Throw New System.Exception("Error - Getting ObjectJson data" + vbNewLine + CurlOutput)
|
|
Return Nothing
|
|
ElseIf CBool(InStr(CurlError, "curl")) Then
|
|
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
|