catch http 401 status for token request

catch http 401 status for token request   #941
This commit is contained in:
hama3254 2024-04-21 16:45:13 +02:00
parent 8f3b4f4108
commit e818618f53
6 changed files with 41 additions and 21 deletions

Binary file not shown.

View File

@ -116,6 +116,10 @@ Module GetData
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

View File

@ -24,13 +24,13 @@ Partial Class LoginForm
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Me.GroupBox3 = New System.Windows.Forms.GroupBox()
Me.Btn_Save = New System.Windows.Forms.Button()
Me.Save = New MetroFramework.Controls.MetroCheckBox()
Me.IssueLink = New MetroFramework.Controls.MetroLink()
Me.PW = New MetroFramework.Controls.MetroTextBox()
Me.Mail = New MetroFramework.Controls.MetroTextBox()
Me.StatusLabel = New MetroFramework.Controls.MetroLabel()
Me.Delay = New System.Windows.Forms.Timer(Me.components)
Me.Btn_Save = New System.Windows.Forms.Button()
Me.GroupBox3.SuspendLayout()
Me.SuspendLayout()
'
@ -49,6 +49,22 @@ Partial Class LoginForm
Me.GroupBox3.TabIndex = 38
Me.GroupBox3.TabStop = False
'
'Btn_Save
'
Me.Btn_Save.BackColor = System.Drawing.Color.Transparent
Me.Btn_Save.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom
Me.Btn_Save.Cursor = System.Windows.Forms.Cursors.Hand
Me.Btn_Save.FlatAppearance.BorderSize = 0
Me.Btn_Save.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent
Me.Btn_Save.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.Btn_Save.Image = Global.Crunchyroll_Downloader.My.Resources.Resources.DialogNotFound_Submit
Me.Btn_Save.ImeMode = System.Windows.Forms.ImeMode.NoControl
Me.Btn_Save.Location = New System.Drawing.Point(165, 246)
Me.Btn_Save.Name = "Btn_Save"
Me.Btn_Save.Size = New System.Drawing.Size(150, 40)
Me.Btn_Save.TabIndex = 3
Me.Btn_Save.UseVisualStyleBackColor = False
'
'Save
'
Me.Save.AutoSize = True
@ -89,7 +105,7 @@ Partial Class LoginForm
Me.PW.Location = New System.Drawing.Point(165, 140)
Me.PW.MaxLength = 32767
Me.PW.Name = "PW"
Me.PW.PasswordChar = Global.Microsoft.VisualBasic.ChrW(9679)
Me.PW.PasswordChar = Global.Microsoft.VisualBasic.ChrW(42)
Me.PW.ScrollBars = System.Windows.Forms.ScrollBars.None
Me.PW.SelectedText = ""
Me.PW.SelectionLength = 0
@ -99,7 +115,6 @@ Partial Class LoginForm
Me.PW.TabIndex = 1
Me.PW.Text = "Password"
Me.PW.UseSelectable = True
Me.PW.UseSystemPasswordChar = True
Me.PW.WaterMarkColor = System.Drawing.Color.FromArgb(CType(CType(109, Byte), Integer), CType(CType(109, Byte), Integer), CType(CType(109, Byte), Integer))
Me.PW.WaterMarkFont = New System.Drawing.Font("Segoe UI", 12.0!, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel)
'
@ -155,22 +170,6 @@ Partial Class LoginForm
'
Me.Delay.Interval = 2000
'
'Btn_Save
'
Me.Btn_Save.BackColor = System.Drawing.Color.Transparent
Me.Btn_Save.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom
Me.Btn_Save.Cursor = System.Windows.Forms.Cursors.Hand
Me.Btn_Save.FlatAppearance.BorderSize = 0
Me.Btn_Save.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent
Me.Btn_Save.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.Btn_Save.Image = Global.Crunchyroll_Downloader.My.Resources.Resources.DialogNotFound_Submit
Me.Btn_Save.ImeMode = System.Windows.Forms.ImeMode.NoControl
Me.Btn_Save.Location = New System.Drawing.Point(165, 246)
Me.Btn_Save.Name = "Btn_Save"
Me.Btn_Save.Size = New System.Drawing.Size(150, 40)
Me.Btn_Save.TabIndex = 3
Me.Btn_Save.UseVisualStyleBackColor = False
'
'LoginForm
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)

View File

@ -22,6 +22,18 @@ Public Class LoginForm
Me.Location = New Point(CInt(Main.Location.X + Main.Width / 2 - Me.Width / 2), CInt(Main.Location.Y + Main.Height / 2 - Me.Height / 2))
'MsgBox(CInt(Main.Location.X + Main.Width / 2 - Me.Width / 2).ToString)
If My.Settings.Mail = "na" Then
Else
Mail.Text = My.Settings.Mail
Save.Checked = True
End If
If My.Settings.PW = "na" Then
Else
PW.Text = My.Settings.PW
'PW.UseSystemPasswordChar = False
PW.PasswordChar = Nothing
End If
End Sub
Private Sub Btn_Save_Click(sender As Object, e As EventArgs) Handles Btn_Save.Click

View File

@ -3107,6 +3107,11 @@ Public Class Main
Dim v1Token As String = CurlPost("https://www.crunchyroll.com/auth/v1/token", Loc_CR_Cookies, Auth, Post, "add_main_4494")
If CBool(InStr(v1Token, "curl:")) = True And CBool(InStr(v1Token, "401")) = True Then
MsgBox("CR reported error 401, this may mean incorrect login detail, please try again.", MsgBoxStyle.Exclamation, "CR-Error 401")
LoginForm.ShowDialog()
Exit Sub
End If
If CBool(InStr(v1Token, "curl:")) = True And CBool(InStr(v1Token, "400")) = True Then
Debug.WriteLine("Post error!, 400")

View File

@ -32,6 +32,6 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("3.21")>
<Assembly: AssemblyFileVersion("3.21")>
<Assembly: AssemblyVersion("3.22")>
<Assembly: AssemblyFileVersion("3.22")>
<Assembly: NeutralResourcesLanguage("en")>