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
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"
Main.CR_Cookies = "Cookie: "
Try
Dim rk As RegistryKey = Registry.CurrentUser.CreateSubKey("Software\CRDownloader")
Dim etp_rt 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
Main.CR_Cookies = Main.CR_Cookies + list.Item(i).Name + "=" + list.Item(i).Value + ";"
End If
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
'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
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
' Debug.WriteLine("etp_rt = True")
' etp_rt = True
@ -70,6 +82,11 @@ Public Class Anime_Add
'MsgBox(locale2(0))
Main.locale = Main.Convert_locale(locale2(0))
'End If
If Main.locale = "en-US" Then
Main.Url_locale = ""
Else
Main.Url_locale = locale2(0)
End If
'MsgBox(Main.locale)
@ -178,6 +195,8 @@ Public Class Anime_Add
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)
'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)

View File

@ -34,6 +34,8 @@ Public Class Main
Public CrBetaMassBaseURL As String = Nothing
Public CrBetaBasic As String = Nothing
Public locale As String = Nothing
Public Url_locale As String = Nothing
'Public CrBetaObjects As String = Nothing
'Public CrBetaStreams As String = Nothing
'Public CrBetaStreamsUrl As String = Nothing
@ -1052,22 +1054,35 @@ Public Class Main
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
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)
Return CurlError
Else
ElseIf CurlOutput IsNot Nothing And CurlError = Nothing Then
Debug.WriteLine("curl-O: " + 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
@ -1108,6 +1123,10 @@ Public Class Main
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
@ -1115,19 +1134,26 @@ Public Class Main
'ffmpegOutput2 = sr.ReadLine
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)
Return CurlError
Else
ElseIf CurlOutput IsNot Nothing And CurlError = Nothing Then
Debug.WriteLine("curl-O: " + 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 Function
@ -1168,20 +1194,34 @@ Public Class Main
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
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)
Return CurlError
Else
ElseIf CurlOutput IsNot Nothing And CurlError = Nothing Then
Debug.WriteLine("curl-O: " + 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
@ -1207,7 +1247,12 @@ Public Class Main
Dim EpisodeSplit4() As String = EpisodeSplit3(1).Split(New String() {Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries)
'MsgBox("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
Dim First As Integer = 0
Dim Last As Integer = 0
@ -2120,7 +2165,7 @@ Public Class Main
ElseIf locale = "pt-pt" Then
Return "pt-PT"
Else
Return CB_SuB_Nothing
Return "en-US"
End If
Catch ex As Exception
Return Nothing
@ -3725,7 +3770,7 @@ Public Class Main
Me.Text = "Crunchyroll Downloader"
Exit Sub
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

View File

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