diff --git a/.vs/Crunchyroll Downloader/v17/.suo b/.vs/Crunchyroll Downloader/v17/.suo index 961e0ec..2bfcf8f 100644 Binary files a/.vs/Crunchyroll Downloader/v17/.suo and b/.vs/Crunchyroll Downloader/v17/.suo differ diff --git a/Crunchyroll Downloader/Crunchyroll Downloader.vbproj b/Crunchyroll Downloader/Crunchyroll Downloader.vbproj index 1b85eaf..8d89303 100644 --- a/Crunchyroll Downloader/Crunchyroll Downloader.vbproj +++ b/Crunchyroll Downloader/Crunchyroll Downloader.vbproj @@ -155,20 +155,28 @@ LoginForm.vb - + + Form + ffmpeg_option.vb - + + Form + CheckBoxComboBox.vb - + + Form + queue.vb - + + Form + Trackbar.vb @@ -185,11 +193,15 @@ Anime_Add.vb - + + Form + einstellungen.vb - + + Form + Browser.vb @@ -200,11 +212,15 @@ ErrorDialog.vb - + + Form + Main.vb - + + Form + True @@ -219,7 +235,9 @@ CRD_List_Item.vb - + + UserControl + diff --git a/Crunchyroll Downloader/GetData.vb b/Crunchyroll Downloader/GetData.vb index 52a090f..82911ee 100644 --- a/Crunchyroll Downloader/GetData.vb +++ b/Crunchyroll Downloader/GetData.vb @@ -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 diff --git a/Crunchyroll Downloader/Main.vb b/Crunchyroll Downloader/Main.vb index df75208..acf826b 100644 --- a/Crunchyroll Downloader/Main.vb +++ b/Crunchyroll Downloader/Main.vb @@ -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,8 +1703,21 @@ 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 SoftSubsAvailable As New List(Of String) 'Dim CCAvailable As New List(Of String) Dim SoftSubsList As New List(Of CR_Subtiles) @@ -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") - Exit Sub - Else - MsgBox("Error processing data") - Exit Sub - End If + MsgBox(ex.ToString) + Exit Sub + '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") diff --git a/Crunchyroll Downloader/My Project/AssemblyInfo.vb b/Crunchyroll Downloader/My Project/AssemblyInfo.vb index 240e473..b55f751 100644 --- a/Crunchyroll Downloader/My Project/AssemblyInfo.vb +++ b/Crunchyroll Downloader/My Project/AssemblyInfo.vb @@ -32,6 +32,6 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - - + +