Skip to content
This repository has been archived by the owner on Jul 13, 2024. It is now read-only.

Commit

Permalink
added token deletion
Browse files Browse the repository at this point in the history
added token deletion #959
changed error messages
  • Loading branch information
hama3254 committed May 23, 2024
1 parent 5c5925b commit ad4d869
Show file tree
Hide file tree
Showing 5 changed files with 188 additions and 57 deletions.
Binary file modified .vs/Crunchyroll Downloader/v17/.suo
Binary file not shown.
36 changes: 27 additions & 9 deletions Crunchyroll Downloader/Crunchyroll Downloader.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -155,20 +155,28 @@
<Compile Include="LoginForm.Designer.vb">
<DependentUpon>LoginForm.vb</DependentUpon>
</Compile>
<Compile Include="LoginForm.vb" />
<Compile Include="LoginForm.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="ffmpeg_option.Designer.vb">
<DependentUpon>ffmpeg_option.vb</DependentUpon>
</Compile>
<Compile Include="ffmpeg_option.vb" />
<Compile Include="ffmpeg_option.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="CheckBoxComboBox.Designer.vb">
<DependentUpon>CheckBoxComboBox.vb</DependentUpon>
</Compile>
<Compile Include="CheckBoxComboBox.vb" />
<Compile Include="CheckBoxComboBox.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="GetData.vb" />
<Compile Include="queue.Designer.vb">
<DependentUpon>queue.vb</DependentUpon>
</Compile>
<Compile Include="queue.vb" />
<Compile Include="queue.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="Settings.vb" />
<Compile Include="Trackbar.Designer.vb">
<DependentUpon>Trackbar.vb</DependentUpon>
Expand All @@ -185,11 +193,15 @@
<Compile Include="Anime_Add.Designer.vb">
<DependentUpon>Anime_Add.vb</DependentUpon>
</Compile>
<Compile Include="Anime_Add.vb" />
<Compile Include="Anime_Add.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="einstellungen.Designer.vb">
<DependentUpon>einstellungen.vb</DependentUpon>
</Compile>
<Compile Include="einstellungen.vb" />
<Compile Include="einstellungen.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="Browser.Designer.vb">
<DependentUpon>Browser.vb</DependentUpon>
</Compile>
Expand All @@ -200,11 +212,15 @@
<Compile Include="ErrorDialog.Designer.vb">
<DependentUpon>ErrorDialog.vb</DependentUpon>
</Compile>
<Compile Include="ErrorDialog.vb" />
<Compile Include="ErrorDialog.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="Main.designer.vb">
<DependentUpon>Main.vb</DependentUpon>
</Compile>
<Compile Include="Main.vb" />
<Compile Include="Main.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="My Project\AssemblyInfo.vb" />
<Compile Include="My Project\Application.Designer.vb">
<AutoGen>True</AutoGen>
Expand All @@ -219,7 +235,9 @@
<Compile Include="CRD_List_Item.Designer.vb">
<DependentUpon>CRD_List_Item.vb</DependentUpon>
</Compile>
<Compile Include="CRD_List_Item.vb" />
<Compile Include="CRD_List_Item.vb">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Subfolder.vb" />
</ItemGroup>
<ItemGroup>
Expand Down
106 changes: 83 additions & 23 deletions Crunchyroll Downloader/GetData.vb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Module GetData
If Main.Curl_insecure = True Then
cmd = "--insecure "
End If '-fsSLm
cmd = cmd + "--no-alpn -fsSLm 15 -A " + My.Settings.User_Agend.Replace("User-Agent: ", "") + Cookies + Auth + Post + " " + Chr(34) + Url + Chr(34)
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)
Dim Proc As New Process
'Debug.WriteLine("CurlPost: " + cmd)
Dim CurlOutput As String = Nothing
Expand Down Expand Up @@ -114,31 +114,22 @@ Module GetData

Loop Until Proc.HasExited Or Microsoft.VisualBasic.DateAndTime.Timer < finish

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, "401")) = True Then
Return CurlError
ElseIf CBool(InStr(CurlOutput, "curl:")) = True And CBool(InStr(CurlOutput, "401")) = 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
Debug.WriteLine(CurlError)
Throw New System.Exception("Error - Getting" + Sender + vbNewLine + CurlError)
Return Nothing

ElseIf CBool(InStr(CurlOutput, "curl:")) Then
Debug.WriteLine(CurlOutput)
If CurlOutput = Nothing And CurlError = Nothing Then
Throw New System.Exception("Error - Getting" + Sender + vbNewLine + CurlError)
Return Nothing
ElseIf CurlError = Nothing Then
Dim OutputBody() As String = CurlOutput.Split(New String() {"HTTP Status:"}, System.StringSplitOptions.RemoveEmptyEntries)
Return OutputBody(0)
'Return CurlOutput
Else
Return CurlOutput
Return CurlError
End If


End Function


Public Function CurlAuthNew(ByVal Url As String, ByVal Cookies As String, ByVal Auth As String, Optional ByVal Test As Boolean = False) As String
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
If Test = True Then
Throw New System.Exception("Error - Getting" + vbNewLine + "Test")

Expand All @@ -157,7 +148,7 @@ Module GetData
If Main.Curl_insecure = True Then
cmd = "--insecure "
End If
cmd = cmd + "--no-alpn -fsSLm 15 -A " + My.Settings.User_Agend.Replace("User-Agent: ", "") + Cookies + Auth + " " + Chr(34) + Url + Chr(34)
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)
Dim Proc As New Process
'MsgBox(cmd)
Dim CurlOutput As String = Nothing
Expand Down Expand Up @@ -192,12 +183,83 @@ Module GetData
Loop Until Proc.HasExited Or Microsoft.VisualBasic.DateAndTime.Timer < finish


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

If CBool(InStr(CurlError, "curl:")) Then
End Function

Public Function CurlDeleteNew(ByVal Url As String, ByVal Auth As String, Optional ByVal UserAgent As String = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/20100101 Firefox/126.0") 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 -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
Debug.WriteLine(CurlError)
Throw New System.Exception("Error - Getting" + vbNewLine + CurlError)
Return Nothing
ElseIf CBool(InStr(CurlOutput, "curl:")) Then
ElseIf CBool(InStr(CurlOutput, "HTTP Status: 4")) Then
Debug.WriteLine(CurlOutput)
Throw New System.Exception("Error - Getting" + vbNewLine + CurlError)
Return Nothing
Expand All @@ -208,8 +270,6 @@ Module GetData
End Function




#End Region


Expand Down
Loading

0 comments on commit ad4d869

Please sign in to comment.