fix hybrid mode key error handling
fix network scan logfile out of memory
This commit is contained in:
hama3254 2020-12-21 12:18:18 +01:00
parent 0dbc0deccc
commit 8ea6abe0e9
13 changed files with 333 additions and 236 deletions

Binary file not shown.

View File

@ -359,24 +359,38 @@ Public Class Anime_Add
Else 'If CBool(InStr(textBox1.Text, "vrv.co")) Then Else 'If CBool(InStr(textBox1.Text, "vrv.co")) Then
If MessageBox.Show("This in NOT a Crunchyroll URL, try anyway?", "confirm?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then If MessageBox.Show("This in NOT a Crunchyroll URL, try anyway?", "confirm?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
Dim FileLocation As DirectoryInfo = New DirectoryInfo(Application.StartupPath) Dim FileLocation As DirectoryInfo = New DirectoryInfo(Application.StartupPath)
Dim CurrentFile As String = Nothing
For Each File In FileLocation.GetFiles() For Each File In FileLocation.GetFiles()
If InStr(File.FullName, "gecko-network.txt") Then If InStr(File.FullName, "gecko-network.txt") Then
CurrentFile = File.FullName Try
File.Delete()
Catch ex As Exception
End Try
End If
Next
Main.LogBrowserData = True
GeckoPreferences.Default("logging.config.LOG_FILE") = "gecko-network.txt"
GeckoPreferences.Default("logging.nsHttp") = 3
For Each File In FileLocation.GetFiles()
If InStr(File.FullName, "gecko-network.txt") Then
Main.GeckoLogFile = File.FullName
Exit For Exit For
End If End If
Next Next
If CurrentFile = Nothing Then If Main.GeckoLogFile = Nothing Then
StatusLabel.Text = "Status: error reading network traffic"
Exit Sub
Else Else
Dim logFileStream As FileStream = New FileStream(CurrentFile, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite) 'MsgBox(Main.GeckoLogFile)
Dim logFileStream As FileStream = New FileStream(Main.GeckoLogFile, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)
Dim logFileReader As StreamReader = New StreamReader(logFileStream) Dim logFileReader As StreamReader = New StreamReader(logFileStream)
logFileStream.SetLength(0) logFileStream.SetLength(0)
logFileReader.Close() logFileReader.Close()
logFileStream.Close() logFileStream.Close()
End If End If
Main.LogBrowserData = True
GeckoPreferences.Default("logging.config.LOG_FILE") = "gecko-network.txt"
GeckoPreferences.Default("logging.nsHttp") = 3
GeckoFX.WebBrowser1.Navigate(textBox1.Text) GeckoFX.WebBrowser1.Navigate(textBox1.Text)
StatusLabel.Text = "Status: looking for non CR video file" StatusLabel.Text = "Status: looking for non CR video file"
Main.b = False Main.b = False

View File

@ -235,7 +235,8 @@ Public Class CRD_List_Item
ElseIf Result = DialogResult.Retry Then ElseIf Result = DialogResult.Retry Then
If FailedSegments.Count > 0 Then If FailedSegments.Count > 0 Then
For i As Integer = 0 To FailedSegments.Count - 1 For i As Integer = 0 To FailedSegments.Count - 1
Dim Evaluator = New Thread(Sub() Me.TS_DownloadAsync(FailedSegments.Item(i).url, FailedSegments.Item(i).path)) Dim ii As Integer = i
Dim Evaluator = New Thread(Sub() Me.TS_DownloadAsync(FailedSegments.Item(ii).url, FailedSegments.Item(ii).path))
FailedSegments.RemoveAt(i) FailedSegments.RemoveAt(i)
Evaluator.Start() Evaluator.Start()
ThreadList.Add(Evaluator) ThreadList.Add(Evaluator)
@ -734,7 +735,7 @@ Public Class CRD_List_Item
Dim retry As Boolean = True Dim retry As Boolean = True
Dim retryCount As Integer = 3 Dim retryCount As Integer = 3
While retry
Try Try
KeyClient.DownloadFile(KeyFile2(0), Application.StartupPath + "\" + KeyFile3) KeyClient.DownloadFile(KeyFile2(0), Application.StartupPath + "\" + KeyFile3)
retry = False retry = False
@ -747,20 +748,18 @@ Public Class CRD_List_Item
End Function)) End Function))
Else Else
'retry = False
Me.Invoke(New Action(Function() Me.Invoke(New Action(Function()
Label_percent.Text = "Access Error - download canceled" Label_percent.Text = "Access Error - download canceled"
Return Nothing Return Nothing
End Function)) End Function))
Return Nothing Return Nothing
Exit Function Exit Function
'Dim utf8WithoutBom2 As New System.Text.UTF8Encoding(False)
'Using sink As New StreamWriter(SubsFile, False, utf8WithoutBom2)
' sink.WriteLine(My.Resources.ass_template)
'End Using
'Retry = False
End If End If
End Try End Try
End While
LoadedKeys.Add(KeyFile2(0)) LoadedKeys.Add(KeyFile2(0))
End If End If
If KeyFile2.Count > 1 Then If KeyFile2.Count > 1 Then

View File

@ -119,7 +119,7 @@ Public Class GeckoFX
If Main.d = False Then If Main.d = False Then
Main.d = True Main.d = True
Main.SeasonDropdownGrappSubs() Main.SeasonDropdownGrappSubs()
einstellungen.StatusLabel.Text = "Status: Multi Download detected!" Einstellungen.StatusLabel.Text = "Status: Multi Download detected!"
Else Else
Main.SeasonDropdownGrapp() Main.SeasonDropdownGrapp()
End If End If
@ -132,7 +132,7 @@ Public Class GeckoFX
If Main.d = False Then If Main.d = False Then
Main.d = True Main.d = True
Main.MassGrappSubs() Main.MassGrappSubs()
einstellungen.StatusLabel.Text = "Status: Multi Download detected!" Einstellungen.StatusLabel.Text = "Status: Multi Download detected!"
Else Else
Main.MassGrapp() Main.MassGrapp()
@ -207,74 +207,128 @@ Public Class GeckoFX
Else Else
If Main.b = False Then If Main.b = False Then
Main.WebbrowserURL = WebBrowser1.Url.ToString
Main.WebbrowserText = WebBrowser1.Document.Body.OuterHtml
Main.WebbrowserTitle = WebBrowser1.DocumentTitle
Main.b = True Main.b = True
Main.UserBowser = True Main.UserBowser = True
For i As Integer = 20 To 0 Step -1 For i As Integer = 20 To 0 Step -1
Pause(1) Pause(1)
Anime_Add.StatusLabel.Text = "Status: scanning network traffic " + Math.Abs(i).ToString Anime_Add.StatusLabel.Text = "Status: scanning network traffic " + Math.Abs(i).ToString
Next Next
Anime_Add.StatusLabel.Text = "Status: "
Dim FileLocation As DirectoryInfo = New DirectoryInfo(Application.StartupPath)
Dim CurrentFile As String = Nothing
For Each File In FileLocation.GetFiles()
If InStr(File.FullName, "gecko-network.txt") Then
CurrentFile = File.FullName
Exit For
End If
Next
Dim logFileStream As FileStream = New FileStream(CurrentFile, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)
Dim logFileReader As StreamReader = New StreamReader(logFileStream)
Dim line As String = Nothing
Dim HTMLString As String = Nothing
line = logFileReader.ReadLine
While (line IsNot Nothing) Main.WebbrowserURL = WebBrowser1.Url.ToString
line = logFileReader.ReadLine Main.WebbrowserText = WebBrowser1.Document.Body.OuterHtml
If InStr(line, ".m3u8") Then 'm3u8? Main.WebbrowserTitle = WebBrowser1.DocumentTitle
If HTMLString = Nothing Then
HTMLString = line
Else
HTMLString = HTMLString + vbNewLine + line
End If
For i As Integer = 0 To 10
line = logFileReader.ReadLine
If InStr(line, " Host: ") Then
HTMLString = HTMLString + vbNewLine + line
End If
Next
End If
End While
logFileReader.Close()
logFileStream.Close()
'MsgBox(HTMLString)
If InStr(HTMLString, ".m3u8") Then 'm3u8?
Anime_Add.StatusLabel.Text = "Status: m3u8 found, trying to start the download"
Main.LogBrowserData = False Main.LogBrowserData = False
GeckoPreferences.Default("logging.config.LOG_FILE") = "gecko-network.txt" GeckoPreferences.Default("logging.config.LOG_FILE") = "gecko-network.txt"
GeckoPreferences.Default("logging.nsHttp") = 0 GeckoPreferences.Default("logging.nsHttp") = 0
Dim URL As String = Nothing
Dim HTMLSplit() As String = HTMLString.Split(New String() {vbNewLine}, System.StringSplitOptions.RemoveEmptyEntries)
For i As Integer = 0 To HTMLSplit.Count - 1
If InStr(HTMLSplit(i), ".m3u8") Then 'm3u8? Dim SubtitleName As String = Main.WebbrowserTitle.Replace(" - Watch on VRV", "").Replace("Free Streaming", "").Replace("Tubi", "")
Dim URLPart2() As String = HTMLSplit(i).Split(New String() {" GET "}, System.StringSplitOptions.RemoveEmptyEntries) SubtitleName = Main.RemoveExtraSpaces(System.Text.RegularExpressions.Regex.Replace(SubtitleName, "[^\w\\-]", " "))
Dim URLPart2Split2() As String = URLPart2(1).Split(New String() {" HTTP/"}, System.StringSplitOptions.RemoveEmptyEntries) Dim SubtitlePfad As String = Main.Pfad + "\" + SubtitleName
Dim URLPart1() As String = HTMLSplit(i + 1).Split(New String() {" Host: "}, System.StringSplitOptions.RemoveEmptyEntries)
Main.NonCR_URL = "https://" + URLPart1(1) + URLPart2Split2(0) Dim logFileStream As FileStream = New FileStream(Main.GeckoLogFile, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)
'MsgBox(Main.NonCR_URL) Dim logFileReader As StreamReader = New StreamReader(logFileStream)
'RichTextBox1.Text = RichTextBox1.Text + vbNewLine + URL_Final
Dim Requests As New List(Of String)
Dim LogText As String = Nothing
Dim line As String = logFileReader.ReadLine
While (line IsNot Nothing)
line = logFileReader.ReadLine
If InStr(line, "I/nsHttp http request [") Then
For i As Integer = 0 To 25
line = logFileReader.ReadLine
If InStr(line, "I/nsHttp ]") Then
Exit For
Else
LogText = LogText + line + vbNewLine
End If
Next
Requests.Add(LogText)
LogText = Nothing
End If
End While
logFileReader.Dispose()
logFileStream.Dispose()
'Dim Requests() As String = LogText.Split(New String() {"I/nsHttp http request ["}, System.StringSplitOptions.RemoveEmptyEntries)
Dim client0 As New WebClient
client0.Encoding = Encoding.UTF8
If WebBrowser1.Document.Cookie = Nothing Then
Else
client0.Headers.Add(HttpRequestHeader.Cookie, WebBrowser1.Document.Cookie)
End If
For i As Integer = 1 To Requests.Count - 1
'Dim Requests2() As String = Requests.Item(i).Split(New String() {"I/nsHttp ]"}, System.StringSplitOptions.RemoveEmptyEntries)
If InStr(Requests.Item(i), " GET ") Then
Dim URLPath() As String = Requests.Item(i).Split(New String() {" GET "}, System.StringSplitOptions.RemoveEmptyEntries)
Dim URLPath2() As String = URLPath(1).Split(New String() {" HTTP/"}, System.StringSplitOptions.RemoveEmptyEntries)
Dim URLHost1() As String = Requests.Item(i).Split(New String() {" Host: "}, System.StringSplitOptions.RemoveEmptyEntries)
Dim URLHost2() As String = URLHost1(1).Split(New String() {vbNewLine}, System.StringSplitOptions.RemoveEmptyEntries)
Dim RequestURL As String = "https://" + URLHost2(0) + URLPath2(0)
If InStr(RequestURL, ".m3u8") Then
Dim str0 As String = client0.DownloadString(RequestURL)
If InStr(str0, "#EXTM3U") Then
Main.m3u8List.Add(RequestURL)
End If
ElseIf InStr(RequestURL, ".mpd") Then
Main.mpdList.Add(RequestURL)
ElseIf InStr(RequestURL, ".txt") Then
Main.txtList.Add(RequestURL)
client0.DownloadFileAsync(New Uri(RequestURL), SubtitlePfad + ".txt")
ElseIf InStr(RequestURL, ".vtt") Then
Main.txtList.Add(RequestURL)
client0.DownloadFileAsync(New Uri(RequestURL), SubtitlePfad + ".vtt")
ElseIf InStr(RequestURL, ".srt") Then
Main.txtList.Add(RequestURL)
client0.DownloadFileAsync(New Uri(RequestURL), SubtitlePfad + ".srt")
ElseIf InStr(RequestURL, ".ass") Then
Main.txtList.Add(RequestURL)
client0.DownloadFileAsync(New Uri(RequestURL), SubtitlePfad + ".ass")
ElseIf InStr(RequestURL, ".ssa") Then
Main.txtList.Add(RequestURL)
client0.DownloadFileAsync(New Uri(RequestURL), SubtitlePfad + ".ssa")
ElseIf InStr(RequestURL, ".dfxp") Then
Main.txtList.Add(RequestURL)
client0.DownloadFileAsync(New Uri(RequestURL), SubtitlePfad + ".dfxp")
End If
End If
Next
If Main.m3u8List.Count > 0 Then
Main.NonCR_URL = Main.m3u8List.Item(0)
Main.FFMPEG_Reso(Main.NonCR_URL)
t = New Thread(AddressOf Main.Grapp_non_CR) t = New Thread(AddressOf Main.Grapp_non_CR)
t.Priority = ThreadPriority.Normal t.Priority = ThreadPriority.Normal
t.IsBackground = True t.IsBackground = True
t.Start() t.Start()
Main.UserBowser = False
Exit For
Me.Close() ElseIf Main.mpdList.Count > 0 Then
End If Main.NonCR_URL = Main.mpdList.Item(0)
Next Main.FFMPEG_Reso(Main.NonCR_URL)
t = New Thread(AddressOf Main.Grapp_non_CR)
t.Priority = ThreadPriority.Normal
t.IsBackground = True
t.Start()
Else Else
Anime_Add.StatusLabel.Text = "Status: no m3u8 found, analyzing HTML content" Anime_Add.StatusLabel.Text = "Status: no m3u8 found, analyzing HTML content"
WebBrowser1.Navigate("view-source:" + Main.WebbrowserURL) WebBrowser1.Navigate("view-source:" + Main.WebbrowserURL)
@ -338,13 +392,14 @@ Public Class GeckoFX
End If End If
End If End If
End If End If
End If
If Main.UserBowser = False Then If Main.UserBowser = False Then
If Main.b = True Then If Main.b = True Then
Anime_Add.StatusLabel.Text = "Status: idle" Anime_Add.StatusLabel.Text = "Status: idle"
Me.Close() Me.Close()
End If End If
End If End If
End If 'End If
End Sub End Sub
Private Sub GeckoFX_Load(sender As Object, e As EventArgs) Handles MyBase.Load Private Sub GeckoFX_Load(sender As Object, e As EventArgs) Handles MyBase.Load
@ -551,6 +606,11 @@ Public Class GeckoFX
Pause(1) Pause(1)
Button2.Text = "network scan is in progess " + Math.Abs(i).ToString Button2.Text = "network scan is in progess " + Math.Abs(i).ToString
Next Next
Main.LogBrowserData = False
GeckoPreferences.Default("logging.config.LOG_FILE") = "gecko-network.txt"
GeckoPreferences.Default("logging.nsHttp") = 0
Main.WebbrowserURL = WebBrowser1.Url.ToString Main.WebbrowserURL = WebBrowser1.Url.ToString
Main.WebbrowserText = WebBrowser1.Document.Body.OuterHtml Main.WebbrowserText = WebBrowser1.Document.Body.OuterHtml
Main.WebbrowserTitle = WebBrowser1.DocumentTitle Main.WebbrowserTitle = WebBrowser1.DocumentTitle
@ -559,8 +619,33 @@ Public Class GeckoFX
SubtitleName = Main.RemoveExtraSpaces(System.Text.RegularExpressions.Regex.Replace(SubtitleName, "[^\w\\-]", " ")) SubtitleName = Main.RemoveExtraSpaces(System.Text.RegularExpressions.Regex.Replace(SubtitleName, "[^\w\\-]", " "))
Dim SubtitlePfad As String = Main.Pfad + "\" + SubtitleName Dim SubtitlePfad As String = Main.Pfad + "\" + SubtitleName
Dim LogText As String = logFileReader.ReadToEnd Dim Requests As New List(Of String)
Dim Requests() As String = LogText.Split(New String() {"I/nsHttp http request ["}, System.StringSplitOptions.RemoveEmptyEntries) Dim LogText As String = Nothing
Dim line As String = logFileReader.ReadLine
While (line IsNot Nothing)
line = logFileReader.ReadLine
If InStr(line, "I/nsHttp http request [") Then
For i As Integer = 0 To 25
line = logFileReader.ReadLine
If InStr(line, "I/nsHttp ]") Then
Exit For
Else
LogText = LogText + line + vbNewLine
End If
Next
Requests.Add(LogText)
LogText = Nothing
End If
End While
logFileReader.Dispose()
logFileStream.Dispose()
Dim client0 As New WebClient Dim client0 As New WebClient
client0.Encoding = Encoding.UTF8 client0.Encoding = Encoding.UTF8
If WebBrowser1.Document.Cookie = Nothing Then If WebBrowser1.Document.Cookie = Nothing Then
@ -568,46 +653,45 @@ Public Class GeckoFX
client0.Headers.Add(HttpRequestHeader.Cookie, WebBrowser1.Document.Cookie) client0.Headers.Add(HttpRequestHeader.Cookie, WebBrowser1.Document.Cookie)
End If End If
For i As Integer = 1 To Requests.Count - 1 For i As Integer = 1 To Requests.Count - 1
Dim Requests2() As String = Requests(i).Split(New String() {"I/nsHttp ]"}, System.StringSplitOptions.RemoveEmptyEntries)
If InStr(Requests2(0), " GET ") Then If InStr(Requests.Item(i), " GET ") Then
Dim URLPath() As String = Requests2(0).Split(New String() {" GET "}, System.StringSplitOptions.RemoveEmptyEntries) Dim URLPath() As String = Requests.Item(i).Split(New String() {" GET "}, System.StringSplitOptions.RemoveEmptyEntries)
Dim URLPath2() As String = URLPath(1).Split(New String() {" HTTP/"}, System.StringSplitOptions.RemoveEmptyEntries) Dim URLPath2() As String = URLPath(1).Split(New String() {" HTTP/"}, System.StringSplitOptions.RemoveEmptyEntries)
Dim URLHost1() As String = Requests2(0).Split(New String() {" Host: "}, System.StringSplitOptions.RemoveEmptyEntries) Dim URLHost1() As String = Requests.Item(i).Split(New String() {" Host: "}, System.StringSplitOptions.RemoveEmptyEntries)
Dim URLHost2() As String = URLHost1(1).Split(New String() {vbNewLine}, System.StringSplitOptions.RemoveEmptyEntries) Dim URLHost2() As String = URLHost1(1).Split(New String() {vbNewLine}, System.StringSplitOptions.RemoveEmptyEntries)
Dim RequestURL As String = "https://" + URLHost2(0) + URLPath2(0) Dim RequestURL As String = "https://" + URLHost2(0) + URLPath2(0)
If InStr(Requests2(0), ".m3u8") Then If InStr(RequestURL, ".m3u8") Then
Dim str0 As String = client0.DownloadString(RequestURL) Dim str0 As String = client0.DownloadString(RequestURL)
If InStr(str0, "#EXTM3U") Then If InStr(str0, "#EXTM3U") Then
Main.m3u8List.Add(RequestURL) Main.m3u8List.Add(RequestURL)
End If End If
ElseIf InStr(Requests2(0), ".mpd") Then ElseIf InStr(RequestURL, ".mpd") Then
Main.mpdList.Add(RequestURL) Main.mpdList.Add(RequestURL)
ElseIf InStr(Requests2(0), ".txt") Then ElseIf InStr(RequestURL, ".txt") Then
Main.txtList.Add(RequestURL) Main.txtList.Add(RequestURL)
client0.DownloadFileAsync(New Uri(RequestURL), SubtitlePfad + ".txt") client0.DownloadFileAsync(New Uri(RequestURL), SubtitlePfad + ".txt")
ElseIf InStr(Requests2(0), ".vtt") Then ElseIf InStr(RequestURL, ".vtt") Then
Main.txtList.Add(RequestURL) Main.txtList.Add(RequestURL)
client0.DownloadFileAsync(New Uri(RequestURL), SubtitlePfad + ".vtt") client0.DownloadFileAsync(New Uri(RequestURL), SubtitlePfad + ".vtt")
ElseIf InStr(Requests2(0), ".srt") Then ElseIf InStr(RequestURL, ".srt") Then
Main.txtList.Add(RequestURL) Main.txtList.Add(RequestURL)
client0.DownloadFileAsync(New Uri(RequestURL), SubtitlePfad + ".srt") client0.DownloadFileAsync(New Uri(RequestURL), SubtitlePfad + ".srt")
ElseIf InStr(Requests2(0), ".ass") Then ElseIf InStr(RequestURL, ".ass") Then
Main.txtList.Add(RequestURL) Main.txtList.Add(RequestURL)
client0.DownloadFileAsync(New Uri(RequestURL), SubtitlePfad + ".ass") client0.DownloadFileAsync(New Uri(RequestURL), SubtitlePfad + ".ass")
ElseIf InStr(Requests2(0), ".ssa") Then ElseIf InStr(RequestURL, ".ssa") Then
Main.txtList.Add(RequestURL) Main.txtList.Add(RequestURL)
client0.DownloadFileAsync(New Uri(RequestURL), SubtitlePfad + ".ssa") client0.DownloadFileAsync(New Uri(RequestURL), SubtitlePfad + ".ssa")
ElseIf InStr(Requests2(0), ".dfxp") Then ElseIf InStr(RequestURL, ".dfxp") Then
Main.txtList.Add(RequestURL) Main.txtList.Add(RequestURL)
client0.DownloadFileAsync(New Uri(RequestURL), SubtitlePfad + ".dfxp") client0.DownloadFileAsync(New Uri(RequestURL), SubtitlePfad + ".dfxp")
End If End If
@ -634,7 +718,6 @@ Public Class GeckoFX
End If End If
ScanTrue = False ScanTrue = False
Button2.Enabled = True Button2.Enabled = True
Catch ex As Exception Catch ex As Exception

View File

@ -68,6 +68,7 @@ Public Class Main
Public TempSoftSubs As New List(Of String) Public TempSoftSubs As New List(Of String)
Public AbourtList As New List(Of String) Public AbourtList As New List(Of String)
Public watingList As New List(Of String) Public watingList As New List(Of String)
Public GeckoLogFile As String = Nothing
Dim SoftSubsString As String Dim SoftSubsString As String
Dim CR_Unlock_Error As String Dim CR_Unlock_Error As String
Public Startseite As String = "https://www.crunchyroll.com/" Public Startseite As String = "https://www.crunchyroll.com/"

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.6.7")> <Assembly: AssemblyVersion("3.6.9")>
<Assembly: AssemblyFileVersion("3.6.7")> <Assembly: AssemblyFileVersion("3.6.9")>
<Assembly: NeutralResourcesLanguage("en")> <Assembly: NeutralResourcesLanguage("en")>