Curl timeout; bugfixes

added timeout for curl requests
fix locale value for api requests
added locale value for mutli download
added an extra check for series false postives
This commit is contained in:
hama3254 2022-10-29 14:48:05 +02:00
parent c1494366f2
commit 3014a1d628
4 changed files with 114 additions and 50 deletions

Binary file not shown.

View File

@ -27,11 +27,23 @@ Public Class Anime_Add
'Main.LoadedUrl = Url 'Main.LoadedUrl = Url
If CBool(InStr(Url, "crunchyroll.com")) = True And CBool(InStr(Url, "series")) = True Then
If CBool(InStr(Url, "crunchyroll.com")) = True And CBool(InStr(Url, "watch")) = True And CBool(Main.CrBetaBasic = Nothing) = False Then Dim locale1() As String = Url.Split(New String() {"crunchyroll.com/"}, System.StringSplitOptions.RemoveEmptyEntries)
Dim locale2() As String = locale1(1).Split(New String() {"/series"}, System.StringSplitOptions.RemoveEmptyEntries)
Main.locale = Main.Convert_locale(locale2(0))
If Main.locale = "en-US" Then
Main.Url_locale = ""
Else
Main.Url_locale = locale2(0)
End If
CefSharp_Browser.WebBrowser1.Load(Url)
ElseIf CBool(InStr(Url, "crunchyroll.com")) = True And CBool(InStr(Url, "watch")) = True And CBool(Main.CrBetaBasic = Nothing) = False Then
#Region "Get Cookies" #Region "Get Cookies"
Main.CR_Cookies = "Cookie: " Main.CR_Cookies = "Cookie: "
Try Try
Dim rk As RegistryKey = Registry.CurrentUser.CreateSubKey("Software\CRDownloader") Dim rk As RegistryKey = Registry.CurrentUser.CreateSubKey("Software\CRDownloader")
Dim etp_rt As Boolean = False Dim etp_rt As Boolean = False
Dim ajs_user_id As Boolean = False Dim ajs_user_id As Boolean = False
@ -46,10 +58,10 @@ Public Class Anime_Add
If CBool(InStr(list.Item(i).Domain, ".crunchyroll.com")) And CBool(InStr(list.Item(i).Name, "_evidon_suppress")) = False Then If CBool(InStr(list.Item(i).Domain, ".crunchyroll.com")) And CBool(InStr(list.Item(i).Name, "_evidon_suppress")) = False Then
Main.CR_Cookies = Main.CR_Cookies + list.Item(i).Name + "=" + list.Item(i).Value + ";" Main.CR_Cookies = Main.CR_Cookies + list.Item(i).Name + "=" + list.Item(i).Value + ";"
End If End If
If CBool(InStr(list.Item(i).Domain, ".crunchyroll.com")) And CBool(InStr(list.Item(i).Name, "c_locale")) Then 'If CBool(InStr(list.Item(i).Domain, ".crunchyroll.com")) And CBool(InStr(list.Item(i).Name, "c_locale")) Then
Main.locale = list.Item(i).Value ' Main.locale = list.Item(i).Value
End If 'End If
'If CBool(InStr(list.Item(i).Domain, ".crunchyroll.com")) = True And CBool(InStr(list.Item(i).Name, "etp_rt")) = True And Main.CheckCRLogin = True And Main.CR_etp_rt = Nothing Then 'If CBool(InStr(list.Item(i).Domain, ".crunchyroll.com")) = True And CBool(InStr(list.Item(i).Name, "etp_rt")) = True And Main.CheckCRLogin = True And Main.CR_etp_rt = Nothing Then
' Debug.WriteLine("etp_rt = True") ' Debug.WriteLine("etp_rt = True")
' etp_rt = True ' etp_rt = True
@ -70,6 +82,11 @@ Public Class Anime_Add
'MsgBox(locale2(0)) 'MsgBox(locale2(0))
Main.locale = Main.Convert_locale(locale2(0)) Main.locale = Main.Convert_locale(locale2(0))
'End If 'End If
If Main.locale = "en-US" Then
Main.Url_locale = ""
Else
Main.Url_locale = locale2(0)
End If
'MsgBox(Main.locale) 'MsgBox(Main.locale)
@ -149,37 +166,39 @@ Public Class Anime_Add
' client.Headers.Add(Cookies) '+ WebBrowser1.Document.Cookie) ' client.Headers.Add(Cookies) '+ WebBrowser1.Document.Cookie)
'MsgBox(OmUStreamSplitEpisodeIndex(1)) 'MsgBox(OmUStreamSplitEpisodeIndex(1))
Dim Auth2 As String = " -H " + Chr(34) + "Authorization: " + CRBetaBearer + Chr(34) Dim Auth2 As String = " -H " + Chr(34) + "Authorization: " + CRBetaBearer + Chr(34)
Dim v2Content As String = Main.CurlAuth("https://www.crunchyroll.com/index/v2", Main.CR_Cookies, Auth2) 'client.DownloadString("https://www.crunchyroll.com/index/v2") Dim v2Content As String = Main.CurlAuth("https://www.crunchyroll.com/index/v2", Main.CR_Cookies, Auth2) 'client.DownloadString("https://www.crunchyroll.com/index/v2")
'Debug.WriteLine(v2Content) 'Debug.WriteLine(v2Content)
'MsgBox("v2: " + v2Content) 'MsgBox("v2: " + v2Content)
If CBool(InStr(v2Content, "curl:")) = True Then If CBool(InStr(v2Content, "curl:")) = True Then
v2Content = Main.CurlAuth("https://www.crunchyroll.com/index/v2", Main.CR_Cookies, Auth2) v2Content = Main.CurlAuth("https://www.crunchyroll.com/index/v2", Main.CR_Cookies, Auth2)
End If End If
If CBool(InStr(v2Content, "curl:")) = True Then If CBool(InStr(v2Content, "curl:")) = True Then
CefSharp_Browser.WebBrowser1.Load(Url) CefSharp_Browser.WebBrowser1.Load(Url)
Exit Sub Exit Sub
End If End If
Dim v2ContentBeta() As String = v2Content.Split(New String() {Chr(34) + "cms_web" + Chr(34) + ":"}, System.StringSplitOptions.RemoveEmptyEntries) Dim v2ContentBeta() As String = v2Content.Split(New String() {Chr(34) + "cms_web" + Chr(34) + ":"}, System.StringSplitOptions.RemoveEmptyEntries)
Dim bucket() As String = v2ContentBeta(1).Split(New String() {Chr(34) + "bucket" + Chr(34) + ":" + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries) Dim bucket() As String = v2ContentBeta(1).Split(New String() {Chr(34) + "bucket" + Chr(34) + ":" + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries)
Dim bucket2() As String = bucket(1).Split(New String() {Chr(34) + "," + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries) Dim bucket2() As String = bucket(1).Split(New String() {Chr(34) + "," + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries)
Dim policy() As String = v2ContentBeta(1).Split(New String() {Chr(34) + "policy" + Chr(34) + ":" + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries) Dim policy() As String = v2ContentBeta(1).Split(New String() {Chr(34) + "policy" + Chr(34) + ":" + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries)
Dim policy2() As String = policy(1).Split(New String() {Chr(34) + "," + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries) Dim policy2() As String = policy(1).Split(New String() {Chr(34) + "," + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries)
Dim signature() As String = v2ContentBeta(1).Split(New String() {Chr(34) + "signature" + Chr(34) + ":" + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries) Dim signature() As String = v2ContentBeta(1).Split(New String() {Chr(34) + "signature" + Chr(34) + ":" + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries)
Dim signature2() As String = signature(1).Split(New String() {Chr(34) + "," + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries) Dim signature2() As String = signature(1).Split(New String() {Chr(34) + "," + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries)
Dim key_pair_id() As String = v2ContentBeta(1).Split(New String() {Chr(34) + "key_pair_id" + Chr(34) + ":" + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries) Dim key_pair_id() As String = v2ContentBeta(1).Split(New String() {Chr(34) + "key_pair_id" + Chr(34) + ":" + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries)
Dim key_pair_id2() As String = key_pair_id(1).Split(New String() {Chr(34) + "," + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries) Dim key_pair_id2() As String = key_pair_id(1).Split(New String() {Chr(34) + "," + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries)
Dim ObjectsURLBuilder3() As String = Url.Split(New String() {"watch/"}, System.StringSplitOptions.RemoveEmptyEntries)
Dim ObjectsURLBuilder4() As String = ObjectsURLBuilder3(1).Split(New String() {"/"}, System.StringSplitOptions.RemoveEmptyEntries) 'MsgBox(Url)
Dim ObjectsURLBuilder3() As String = Url.Split(New String() {"watch/"}, System.StringSplitOptions.RemoveEmptyEntries)
Dim ObjectsURLBuilder4() As String = ObjectsURLBuilder3(1).Split(New String() {"/"}, System.StringSplitOptions.RemoveEmptyEntries)
ObjectsUrl = "https://www.crunchyroll.com/cms/v2" + bucket2(0) + "/objects/" + ObjectsURLBuilder4(0) + "?locale=" + Main.locale + "&Signature=" + signature2(0) + "&Policy=" + policy2(0) + "&Key-Pair-Id=" + key_pair_id2(0) ObjectsUrl = "https://www.crunchyroll.com/cms/v2" + bucket2(0) + "/objects/" + ObjectsURLBuilder4(0) + "?locale=" + Main.locale + "&Signature=" + signature2(0) + "&Policy=" + policy2(0) + "&Key-Pair-Id=" + key_pair_id2(0)
@ -189,13 +208,13 @@ Public Class Anime_Add
Debug.WriteLine("ObjectsUrl: " + ObjectsUrl) Debug.WriteLine("ObjectsUrl: " + ObjectsUrl)
'Catch ex As Exception 'Catch ex As Exception
' MsgBox(ex.ToString) ' MsgBox(ex.ToString)
' CefSharp_Browser.WebBrowser1.Load(Url) ' CefSharp_Browser.WebBrowser1.Load(Url)
' Exit Sub ' Exit Sub
'End Try 'End Try
Dim StreamsUrl As String = Nothing Dim StreamsUrl As String = Nothing
Dim ObjectJson As String Dim ObjectJson As String
Try Try
ObjectJson = Main.Curl(ObjectsUrl) ObjectJson = Main.Curl(ObjectsUrl)

View File

@ -34,6 +34,8 @@ Public Class Main
Public CrBetaMassBaseURL As String = Nothing Public CrBetaMassBaseURL As String = Nothing
Public CrBetaBasic As String = Nothing Public CrBetaBasic As String = Nothing
Public locale As String = Nothing Public locale As String = Nothing
Public Url_locale As String = Nothing
'Public CrBetaObjects As String = Nothing 'Public CrBetaObjects As String = Nothing
'Public CrBetaStreams As String = Nothing 'Public CrBetaStreams As String = Nothing
'Public CrBetaStreamsUrl As String = Nothing 'Public CrBetaStreamsUrl As String = Nothing
@ -1052,22 +1054,35 @@ Public Class Main
sr2 = Proc.StandardError sr2 = Proc.StandardError
'sw = proc.StandardInput 'sw = proc.StandardInput
Dim start, finish, pau As Double
start = CSng(Microsoft.VisualBasic.DateAndTime.Timer)
pau = 5
finish = start + pau
Do Do
CurlOutput = CurlOutput + sr.ReadToEnd CurlOutput = CurlOutput + sr.ReadToEnd
CurlError = CurlError + sr2.ReadToEnd CurlError = CurlError + sr2.ReadToEnd
'ffmpegOutput2 = sr.ReadLine 'ffmpegOutput2 = sr.ReadLine
Debug.WriteLine(CurlOutput) Debug.WriteLine(CurlOutput)
Loop Until Proc.HasExited Loop Until Proc.HasExited Or Microsoft.VisualBasic.DateAndTime.Timer < finish
If CurlOutput = Nothing Then
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) Debug.WriteLine("curl-E: " + CurlError)
Return CurlError Return CurlError
ElseIf CurlOutput IsNot Nothing And CurlError = Nothing Then
Else
Debug.WriteLine("curl-O: " + CurlOutput) Debug.WriteLine("curl-O: " + CurlOutput)
Return 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 If
@ -1108,6 +1123,10 @@ Public Class Main
sr = Proc.StandardOutput 'standard error is used by ffmpeg sr = Proc.StandardOutput 'standard error is used by ffmpeg
sr2 = Proc.StandardError sr2 = Proc.StandardError
'sw = proc.StandardInput 'sw = proc.StandardInput
Dim start, finish, pau As Double
start = CSng(Microsoft.VisualBasic.DateAndTime.Timer)
pau = 5
finish = start + pau
Do Do
CurlOutput = CurlOutput + sr.ReadToEnd CurlOutput = CurlOutput + sr.ReadToEnd
@ -1115,19 +1134,26 @@ Public Class Main
'ffmpegOutput2 = sr.ReadLine 'ffmpegOutput2 = sr.ReadLine
Debug.WriteLine(CurlOutput) Debug.WriteLine(CurlOutput)
Loop Until Proc.HasExited Loop Until Proc.HasExited Or Microsoft.VisualBasic.DateAndTime.Timer < finish
If CurlOutput = Nothing Then
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) Debug.WriteLine("curl-E: " + CurlError)
Return CurlError Return CurlError
ElseIf CurlOutput IsNot Nothing And CurlError = Nothing Then
Else
Debug.WriteLine("curl-O: " + CurlOutput) Debug.WriteLine("curl-O: " + CurlOutput)
Return 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 If
End Function End Function
@ -1168,20 +1194,34 @@ Public Class Main
sr2 = Proc.StandardError sr2 = Proc.StandardError
'sw = proc.StandardInput 'sw = proc.StandardInput
Dim start, finish, pau As Double
start = CSng(Microsoft.VisualBasic.DateAndTime.Timer)
pau = 5
finish = start + pau
Do Do
CurlOutput = CurlOutput + sr.ReadToEnd CurlOutput = CurlOutput + sr.ReadToEnd
CurlError = CurlError + sr2.ReadToEnd CurlError = CurlError + sr2.ReadToEnd
'ffmpegOutput2 = sr.ReadLine 'ffmpegOutput2 = sr.ReadLine
Debug.WriteLine(CurlOutput) Debug.WriteLine(CurlOutput)
Loop Until Proc.HasExited Loop Until Proc.HasExited Or Microsoft.VisualBasic.DateAndTime.Timer < finish
If CurlOutput = Nothing Then 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) Debug.WriteLine("curl-E: " + CurlError)
Return CurlError Return CurlError
Else ElseIf CurlOutput IsNot Nothing And CurlError = Nothing Then
Debug.WriteLine("curl-O: " + CurlOutput) Debug.WriteLine("curl-O: " + CurlOutput)
Return 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 If
@ -1207,7 +1247,12 @@ Public Class Main
Dim EpisodeSplit4() As String = EpisodeSplit3(1).Split(New String() {Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries) Dim EpisodeSplit4() As String = EpisodeSplit3(1).Split(New String() {Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries)
'MsgBox("https://www.crunchyroll.com/watch/" + EpisodeSplit2(0) + "/" + EpisodeSplit4(0) + "/") 'MsgBox("https://www.crunchyroll.com/watch/" + EpisodeSplit2(0) + "/" + EpisodeSplit4(0) + "/")
ListOfEpisodes.Add("https://www.crunchyroll.com/watch/" + EpisodeSplit2(0) + "/" + EpisodeSplit4(0) + "/") If Url_locale = "" Then
ListOfEpisodes.Add("https://www.crunchyroll.com/watch/" + EpisodeSplit2(0) + "/" + EpisodeSplit4(0) + "/")
Else
ListOfEpisodes.Add("https://www.crunchyroll.com/" + Url_locale + "/" + "watch/" + EpisodeSplit2(0) + "/" + EpisodeSplit4(0) + "/")
End If
Next Next
Dim First As Integer = 0 Dim First As Integer = 0
Dim Last As Integer = 0 Dim Last As Integer = 0
@ -2120,7 +2165,7 @@ Public Class Main
ElseIf locale = "pt-pt" Then ElseIf locale = "pt-pt" Then
Return "pt-PT" Return "pt-PT"
Else Else
Return CB_SuB_Nothing Return "en-US"
End If End If
Catch ex As Exception Catch ex As Exception
Return Nothing Return Nothing
@ -3725,7 +3770,7 @@ Public Class Main
Me.Text = "Crunchyroll Downloader" Me.Text = "Crunchyroll Downloader"
Exit Sub Exit Sub
End If End If
ElseIf CBool(InStr(requesturl, "crunchyroll.com/")) And CBool(InStr(requesturl, "seasons?series_id=")) Then ElseIf CBool(InStr(requesturl, "crunchyroll.com/")) And CBool(InStr(requesturl, "seasons?series_id=")) And CBool(InStr(WebbrowserURL, "series")) Then
If b = False Then If b = False Then

View File

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