added token deletion

added token deletion #959
changed error messages
This commit is contained in:
hama3254 2024-05-23 18:20:36 +02:00
parent 5c5925ba35
commit ad4d8690cc
5 changed files with 188 additions and 57 deletions

Binary file not shown.

View File

@ -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>
@ -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>
@ -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>
@ -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>

View File

@ -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
@ -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")
@ -157,7 +148,78 @@ 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
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: 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
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
@ -193,11 +255,11 @@ Module GetData
If CBool(InStr(CurlError, "curl:")) Then
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
@ -208,8 +270,6 @@ Module GetData
End Function
#End Region

View File

@ -15,7 +15,6 @@ Imports System.Runtime.InteropServices
Imports MyProvider.MyProvider
Imports Microsoft.Web.WebView2.Core
Imports Crunchyroll_Downloader.CRD_Classes
Imports System.Runtime.CompilerServices
Public Class Main
Inherits MetroForm
@ -1069,11 +1068,7 @@ Public Class Main
ObjectJson = CurlAuthNew(ObjectsURL, Loc_CR_Cookies, Loc_AuthToken)
'Filter JSON esqaped characters
'Debug.WriteLine(Date.Now.ToString + "before:" + ObjectJson)
'Debug.WriteLine("1750: " + ObjectJson)
ObjectJson = CleanJSON(ObjectJson)
'Debug.WriteLine(Date.Now.ToString + "after:" + ObjectJson)
Dim DubsAvalible As New List(Of CR_MediaVersion)
@ -1166,10 +1161,47 @@ Public Class Main
Dim NewAPI As String = "https://cr-play-service.prd.crunchyrollsvc.com/v1/" + page_guid + "/console/switch/play"
Debug.WriteLine("NewAPI: " + NewAPI)
'MsgBox(Loc_AuthToken)
Dim UserAgent As String = " -H " + Chr(34) + "User-Agent: Crunchyroll/1.8.0 Nintendo Switch/12.3.12.0 UE4/4.27" + Chr(34)
Dim NewAPIData As String = CurlAuthNew(NewAPI, "", UserAgent + Loc_AuthToken)
'Dim UserAgent As String = " -H " + Chr(34) + "User-Agent: Crunchyroll/1.8.0 Nintendo Switch/12.3.12.0 UE4/4.27" + Chr(34)
Dim UserAgent As String = Chr(34) + "Crunchyroll/1.8.0 Nintendo Switch/12.3.12.0 UE4/4.27" + Chr(34)
Dim NewAPIData As String = CurlAuthNew(NewAPI, "", Loc_AuthToken, False, UserAgent)
'Debug.WriteLine("NewAPIData: " + NewAPIData)
If CBool(InStr(NewAPIData, "HTTP Status: 420")) Then '
Me.Invoke(New Action(Function() As Object
SetStatusLabel("Stream limit reached - Bypassing")
Return Nothing
End Function))
'page_guid NewAPIData
Dim OldToCancel_0 As String() = NewAPIData.Split(New String() {Chr(34) + "token" + Chr(34) + ":" + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries) '
Dim OldToCancel_1 As String() = OldToCancel_0(1).Split(New String() {Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries) '
Dim OldToCancel As String = OldToCancel_1(0)
Dim OldPage_0 As String() = NewAPIData.Split(New String() {Chr(34) + "contentId" + Chr(34) + ":" + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries) '
Dim OldPage_1 As String() = OldPage_0(1).Split(New String() {Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries) '
Dim OldPage As String = OldPage_1(0)
CurlDeleteNew("https://cr-play-service.prd.crunchyrollsvc.com/v1/token/" + OldPage + "/" + OldToCancel, Loc_AuthToken)
Debug.WriteLine("Error 420 - delete old Token: " + OldToCancel + " for " + OldPage)
Pause(3)
NewAPIData = CurlAuthNew(NewAPI, "", Loc_AuthToken, False, UserAgent)
End If
If CBool(InStr(NewAPIData, "HTTP Status: 420")) Then
Me.Invoke(New Action(Function() As Object
SetStatusLabel("Bypassing failed")
Return Nothing
End Function))
Throw New System.Exception("Error - Getting" + vbNewLine + "Error 420")
End If
Dim VideoJSON_New As String = CleanJSON(NewAPIData)
@ -1591,7 +1623,11 @@ Public Class Main
Else
Dim str As String = CurlAuthNew(CR_URI_Master(0), "", Loc_AuthToken)
Dim str0 As String = CurlAuthNew(CR_URI_Master(0), "", Loc_AuthToken)
Dim str1() As String = str0.Split(New String() {""}, System.StringSplitOptions.RemoveEmptyEntries)
Dim str As String = str1(0)
If CBool(InStr(str, "curl:")) = True Or str = Nothing Then
@ -1646,6 +1682,8 @@ Public Class Main
Dim localm3u8 As String = CurlAuthNew(ffmpeg_url_3.Trim(), "", Loc_AuthToken)
Dim localfile As String = Application.StartupPath + "\" + GeräteID2() + ".m3u8"
Dim utf8WithoutBom As New System.Text.UTF8Encoding(False)
@ -1665,6 +1703,19 @@ Public Class Main
#End Region
#Region "Cancel Token"
'page_guid NewAPIData
Dim ToCancel_0 As String() = NewAPIData.Split(New String() {Chr(34) + "token" + Chr(34) + ":" + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries) '
Dim ToCancel_1 As String() = ToCancel_0(1).Split(New String() {Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries) '
Dim ToCancel As String = ToCancel_1(0)
CurlDeleteNew("https://cr-play-service.prd.crunchyrollsvc.com/v1/token/" + page_guid + "/" + ToCancel, Loc_AuthToken)
Debug.WriteLine("Delete Token: " + ToCancel + " for " + page_guid + " - " + CR_FilenName)
#End Region
#Region "GetSoftsubs"
Dim SoftSubsAvailable As New List(Of String)
'Dim CCAvailable As New List(Of String)
@ -2992,15 +3043,16 @@ Public Class Main
Else
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")
If CBool(InStr(v1Token, "HTTP Status: 401")) = True Then
MsgBox("CR reported :" + vbNewLine + v1Token, MsgBoxStyle.Exclamation, "CR-Error 401")
LoginForm.ShowDialog()
Exit Sub
End If
If CBool(InStr(v1Token, "curl:")) = True And CBool(InStr(v1Token, "400")) = True Then
MsgBox("CR reported error 400, idk why tbh", MsgBoxStyle.Exclamation, "CR-Error 400")
SetStatusLabel("Status: Unknown error. #3038")
If CBool(InStr(v1Token, "HTTP Status: 400")) = True Then
'MsgBox("CR reported error 400, idk why tbh", MsgBoxStyle.Exclamation, "CR-Error 400")
'SetStatusLabel("Status: Unknown error. #3038")
MsgBox("CR reported :" + vbNewLine + v1Token, MsgBoxStyle.Exclamation, "CR-Error 400")
Exit Sub
End If
@ -3085,14 +3137,15 @@ Public Class Main
ObjectJson = CurlAuthNew(ObjectsUrl, Loc_CR_Cookies, Auth2)
Catch ex As Exception
If CBool(InStr(ex.ToString, "Error - Getting")) Then
MsgBox("Error invalid CR respone")
MsgBox(ex.ToString)
Exit Sub
Else
MsgBox("Error processing data")
Exit Sub
End If
'If CBool(InStr(ex.ToString, "Error - Getting")) Then
' MsgBox("Error invalid CR respone")
' Exit Sub
'Else
' MsgBox("Error processing data")
' Exit Sub
'End If
End Try
@ -3101,7 +3154,7 @@ Public Class Main
Exit Sub
ElseIf CBool(InStr(ObjectJson, "videos/")) = False Then
MsgBox(ObjectJson)
SetStatusLabel("Status: Failed - no video, check CR login")
Me.Text = "Status: Failed - no video, check CR login"
Debug.WriteLine("Status: Failed - no video, check CR login")

View File

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