diff --git a/.vs/Crunchyroll Downloader/v17/.suo b/.vs/Crunchyroll Downloader/v17/.suo index 862e801..de4f8d3 100644 Binary files a/.vs/Crunchyroll Downloader/v17/.suo and b/.vs/Crunchyroll Downloader/v17/.suo differ diff --git a/Crunchyroll Downloader/Browser.vb b/Crunchyroll Downloader/Browser.vb index 063647d..1e8d800 100644 --- a/Crunchyroll Downloader/Browser.vb +++ b/Crunchyroll Downloader/Browser.vb @@ -19,7 +19,10 @@ Public Class Browser Private Sub WebView2_CoreWebView2InitializationCompleted(sender As Object, e As CoreWebView2InitializationCompletedEventArgs) Handles WebView2.CoreWebView2InitializationCompleted WebView2.CoreWebView2.AddWebResourceRequestedFilter("https://www.crunchyroll.com/*", CoreWebView2WebResourceContext.All) WebView2.CoreWebView2.AddWebResourceRequestedFilter("https://www.funimation.com/*", CoreWebView2WebResourceContext.All) + WebView2.CoreWebView2.AddWebResourceRequestedFilter("https://www.crunchyroll.com/*", CoreWebView2WebResourceContext.All) + 'WebView2.CoreWebView2.AddWebResourceRequestedFilter("*", CoreWebView2WebResourceContext.All) + AddHandler WebView2.CoreWebView2.WebResourceResponseReceived, AddressOf ObserveResponse AddHandler WebView2.CoreWebView2.WebResourceRequested, AddressOf ObserveHttp WebView2.CoreWebView2.Settings.UserAgent = My.Resources.ffmpeg_user_agend.Replace(Chr(34), "").Replace("User-Agent: ", "") @@ -69,7 +72,7 @@ Public Class Browser End Sub - Private Sub GeckoFX_Load(sender As Object, e As EventArgs) Handles Me.Load + Private Sub Browser_Load(sender As Object, e As EventArgs) Handles Me.Load Main.waveOutSetVolume(0, 0) If Me.Width > My.Computer.Screen.Bounds.Width Then Me.Width = My.Computer.Screen.Bounds.Width @@ -141,6 +144,90 @@ Public Class Browser End Sub + Private Async Sub ObserveResponse(ByVal sender As Object, ByVal e As CoreWebView2WebResourceResponseReceivedEventArgs) + + + + + If CBool(InStr(Main.LoadingUrl, "crunchyroll.com")) Then + + + + + If CBool(InStr(e.Request.Uri, "crunchyroll.com/")) And CBool(InStr(e.Request.Uri, "streams?")) Then + Debug.WriteLine("Crunchyroll-Single: " + e.Request.Uri) + Dim Content As Stream = Await e.Response.GetContentAsync + Dim ContentString As String = Nothing + Dim reader As New StreamReader(Content) + ContentString = reader.ReadToEnd + + Main.LoadedUrls.Add(e.Request.Uri) + Main.CR_VideoJson = New UrlJson(e.Request.Uri, ContentString) + + Exit Sub + ElseIf CBool(InStr(e.Request.Uri, "crunchyroll.com/")) And CBool(InStr(e.Request.Uri, "/objects/")) And CBool(InStr(Main.LoadingUrl, "/watch/")) Then + Debug.WriteLine(e.Request.Uri) + Main.LoadedUrls.Add(e.Request.Uri) + Dim Content As Stream = Await e.Response.GetContentAsync + Dim ContentString As String = Nothing + Dim reader As New StreamReader(Content) + ContentString = reader.ReadToEnd + Main.CR_ObjectsJson = New UrlJson(e.Request.Uri, ContentString) + Exit Sub + ElseIf CBool(InStr(e.Request.Uri, "crunchyroll.com/")) And CBool(InStr(e.Request.Uri, "seasons?series_id=")) And CBool(InStr(Main.LoadingUrl, "/series/")) Then + Debug.WriteLine("Crunchyroll-Season: " + e.Request.Uri) + Main.LoadedUrls.Add(e.Request.Uri) + Main.LoadedUrls.Add(e.Request.Uri) + Dim Content As Stream = Await e.Response.GetContentAsync + Dim ContentString As String = Nothing + Dim reader As New StreamReader(Content) + ContentString = reader.ReadToEnd + Main.CR_SeasonJson = New UrlJson(e.Request.Uri, ContentString) + Exit Sub + End If + + ElseIf CBool(InStr(Main.LoadingUrl, "funimation.com")) Then + If CBool(InStr(e.Request.Uri, "?deviceType=web")) Then + 'Debug.WriteLine(e.Request.Uri) + Dim parms As String() = e.Request.Uri.Split(New String() {"?deviceType="}, System.StringSplitOptions.RemoveEmptyEntries) + Main.FunimationDeviceRegion = "?deviceType=" + parms(1) + + End If + If CBool(InStr(e.Request.Uri, "https://title-api.prd.funimationsvc.com")) Then + Debug.WriteLine("Funimtaion: " + e.Request.Uri) + If (Me.InvokeRequired) Then + Me.Invoke(Sub() Main.LoadedUrls.Add(e.Request.Uri)) + Exit Sub + Else + Main.LoadedUrls.Add(e.Request.Uri) + Exit Sub + End If + ElseIf CBool(InStr(e.Request.Uri, "/data/v2/shows/")) Then + Debug.WriteLine("Funimtaion: " + e.Request.Uri) + If (Me.InvokeRequired) Then + Me.Invoke(Sub() Main.LoadedUrls.Add(e.Request.Uri)) + Exit Sub + Else + Main.LoadedUrls.Add(e.Request.Uri) + Exit Sub + End If + ElseIf CBool(InStr(e.Request.Uri, "/data/v1/episodes/")) Then + Debug.WriteLine("Funimtaion: " + e.Request.Uri) + If (Me.InvokeRequired) Then + Me.Invoke(Sub() Main.LoadedUrls.Add(e.Request.Uri)) + Exit Sub + Else + Main.LoadedUrls.Add(e.Request.Uri) + Exit Sub + End If + End If + + + + End If + + End Sub + @@ -149,6 +236,7 @@ Public Class Browser Private Sub ObserveHttp(ByVal sender As Object, ByVal e As CoreWebView2WebResourceRequestedEventArgs) 'Handles RequestResource.GetUrl + If CBool(InStr(e.Request.Uri, "crunchyroll.com")) = True And Main.CrBetaBasic = Nothing Then Dim Headers As New List(Of KeyValuePair(Of String, String)) Headers.AddRange(e.Request.Headers.ToList) @@ -160,36 +248,31 @@ Public Class Browser Next End If - + Exit Sub If CBool(InStr(Main.LoadingUrl, "crunchyroll.com")) Then + If CBool(InStr(e.Request.Uri, "crunchyroll.com/")) And CBool(InStr(e.Request.Uri, "streams?")) Then Debug.WriteLine("Crunchyroll-Single: " + e.Request.Uri) - If (Me.InvokeRequired) Then - Me.Invoke(Sub() Main.LoadedUrls.Add(e.Request.Uri)) - Exit Sub - Else - Main.LoadedUrls.Add(e.Request.Uri) - Exit Sub - End If + 'Dim ContentString As String = Nothing + 'Dim Content As New MemoryStream + 'e.Response.Content.CopyTo(Content) + 'Content.Position = 0 + 'ContentString = Encoding.UTF8.GetString(Content.ToArray()) + 'MsgBox(ContentString) + Main.LoadedUrls.Add(e.Request.Uri) + 'Main.CR_VideoJson = New UrlJson(e.Request.Uri, e.Request.Content.ToString) + Exit Sub ElseIf CBool(InStr(e.Request.Uri, "crunchyroll.com/")) And CBool(InStr(e.Request.Uri, "/objects/")) And CBool(InStr(e.Request.Uri, "/watch/")) Then - If (Me.InvokeRequired) Then - Me.Invoke(Sub() Main.LoadedUrls.Add(e.Request.Uri)) - Exit Sub - Else - Main.LoadedUrls.Add(e.Request.Uri) - Exit Sub - End If Debug.WriteLine(e.Request.Uri) + Main.LoadedUrls.Add(e.Request.Uri) + 'Main.CR_ObjectsJson = New UrlJson(e.Request.Uri, e.Request.Content.ToString) + Exit Sub ElseIf CBool(InStr(e.Request.Uri, "crunchyroll.com/")) And CBool(InStr(e.Request.Uri, "seasons?series_id=")) Then Debug.WriteLine("Crunchyroll-Season: " + e.Request.Uri) - If (Me.InvokeRequired) Then - Me.Invoke(Sub() Main.LoadedUrls.Add(e.Request.Uri)) - Exit Sub - Else - Main.LoadedUrls.Add(e.Request.Uri) - Exit Sub - End If + Main.LoadedUrls.Add(e.Request.Uri) + 'Main.CR_SeasonJson = New UrlJson(e.Request.Uri, e.Request.Content.ToString) + Exit Sub End If diff --git a/Crunchyroll Downloader/Main.designer.vb b/Crunchyroll Downloader/Main.designer.vb index 1c2e40f..82afaee 100644 --- a/Crunchyroll Downloader/Main.designer.vb +++ b/Crunchyroll Downloader/Main.designer.vb @@ -48,7 +48,7 @@ Partial Class Main Me.ThreadCount = New System.Windows.Forms.ToolStripMenuItem() Me.MsgBoxToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.CRCookieToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() - Me.ClearAllSettingsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() + Me.UrlJsonsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.ItemBoundsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.DummyItemToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.Panel1 = New System.Windows.Forms.Panel() @@ -161,7 +161,7 @@ Partial Class Main ' 'ContextMenuStrip1 ' - Me.ContextMenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToggleDebugModeToolStripMenuItem, Me.OpenSettingsToolStripMenuItem, Me.Funimation_Token, Me.CheckCRBetaTokenToolStripMenuItem, Me.AddonHTMLToolStripMenuItem, Me.Timer3OffToolStripMenuItem, Me.ThreadCount, Me.MsgBoxToolStripMenuItem, Me.CRCookieToolStripMenuItem, Me.ClearAllSettingsToolStripMenuItem, Me.ItemBoundsToolStripMenuItem, Me.DummyItemToolStripMenuItem}) + Me.ContextMenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToggleDebugModeToolStripMenuItem, Me.OpenSettingsToolStripMenuItem, Me.Funimation_Token, Me.CheckCRBetaTokenToolStripMenuItem, Me.AddonHTMLToolStripMenuItem, Me.Timer3OffToolStripMenuItem, Me.ThreadCount, Me.MsgBoxToolStripMenuItem, Me.CRCookieToolStripMenuItem, Me.UrlJsonsToolStripMenuItem, Me.ItemBoundsToolStripMenuItem, Me.DummyItemToolStripMenuItem}) Me.ContextMenuStrip1.Name = "ContextMenuStrip1" resources.ApplyResources(Me.ContextMenuStrip1, "ContextMenuStrip1") ' @@ -210,10 +210,10 @@ Partial Class Main Me.CRCookieToolStripMenuItem.Name = "CRCookieToolStripMenuItem" resources.ApplyResources(Me.CRCookieToolStripMenuItem, "CRCookieToolStripMenuItem") ' - 'ClearAllSettingsToolStripMenuItem + 'UrlJsonsToolStripMenuItem ' - Me.ClearAllSettingsToolStripMenuItem.Name = "ClearAllSettingsToolStripMenuItem" - resources.ApplyResources(Me.ClearAllSettingsToolStripMenuItem, "ClearAllSettingsToolStripMenuItem") + Me.UrlJsonsToolStripMenuItem.Name = "UrlJsonsToolStripMenuItem" + resources.ApplyResources(Me.UrlJsonsToolStripMenuItem, "UrlJsonsToolStripMenuItem") ' 'ItemBoundsToolStripMenuItem ' @@ -287,7 +287,7 @@ Partial Class Main Friend WithEvents ThreadCount As ToolStripMenuItem Friend WithEvents MsgBoxToolStripMenuItem As ToolStripMenuItem Friend WithEvents CRCookieToolStripMenuItem As ToolStripMenuItem - Friend WithEvents ClearAllSettingsToolStripMenuItem As ToolStripMenuItem + Friend WithEvents UrlJsonsToolStripMenuItem As ToolStripMenuItem Friend WithEvents ItemBoundsToolStripMenuItem As ToolStripMenuItem Friend WithEvents DummyItemToolStripMenuItem As ToolStripMenuItem Public WithEvents Panel1 As Panel diff --git a/Crunchyroll Downloader/Main.resx b/Crunchyroll Downloader/Main.resx index 4d741d5..bff13bf 100644 --- a/Crunchyroll Downloader/Main.resx +++ b/Crunchyroll Downloader/Main.resx @@ -231,6 +231,21 @@ 842, 630 + + True + + + 1, 71 + + + 798, 403 + + + 840, 546 + + + 0 + Panel1 @@ -243,6 +258,24 @@ 1 + + None + + + Flat + + + NoControl + + + 800, 1 + + + 40, 40 + + + 5 + Btn_Close @@ -255,6 +288,24 @@ 2 + + None + + + Flat + + + NoControl + + + 757, 1 + + + 40, 40 + + + 4 + Btn_min @@ -267,6 +318,24 @@ 3 + + Zoom + + + Flat + + + NoControl + + + 641, 18 + + + 80, 35 + + + 3 + Btn_Settings @@ -279,6 +348,21 @@ 4 + + Zoom + + + Flat + + + 124, 18 + + + 80, 35 + + + 2 + Btn_Browser @@ -291,6 +375,24 @@ 5 + + Zoom + + + Flat + + + NoControl + + + 11, 18 + + + 80, 35 + + + 1 + Btn_add @@ -405,10 +507,10 @@ System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - ClearAllSettingsToolStripMenuItem + + UrlJsonsToolStripMenuItem - + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 @@ -438,165 +540,9 @@ 276, 52 - - Zoom - - - Flat - - - NoControl - - - 11, 18 - - - 80, 35 - - - 1 - - - Btn_add - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 6 - - - Zoom - - - Flat - - - 124, 18 - - - 80, 35 - - - 2 - - - Btn_Browser - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 5 - - - Zoom - - - Flat - - - NoControl - - - 641, 18 - - - 80, 35 - - - 3 - - - Btn_Settings - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 4 - - - None - - - Flat - - - NoControl - - - 757, 1 - - - 40, 40 - - - 4 - - - Btn_min - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 3 - - - None - - - Flat - - - NoControl - - - 800, 1 - - - 40, 40 - - - 5 - - - Btn_Close - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 2 - 352, 49 - - 234, 268 - - - ContextMenuStrip1 - - - System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - 233, 22 @@ -651,11 +597,11 @@ CR_Cookie - + 233, 22 - - Clear all settings + + UrlJsons 233, 22 @@ -669,32 +615,14 @@ Dummy_Item - - True + + 234, 290 - - 1, 71 + + ContextMenuStrip1 - - 798, 403 - - - 840, 546 - - - 0 - - - Panel1 - - - System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 1 + + System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 167, 10 diff --git a/Crunchyroll Downloader/Main.vb b/Crunchyroll Downloader/Main.vb index 46e4393..f4b4dac 100644 --- a/Crunchyroll Downloader/Main.vb +++ b/Crunchyroll Downloader/Main.vb @@ -25,7 +25,11 @@ Public Class Main Public CheckCRLogin As Boolean = True - 'Public LoadedUrl As String = Nothing + + Public CR_SeasonJson As UrlJson = New UrlJson("", "") + Public CR_ObjectsJson As UrlJson = New UrlJson("", "") + Public CR_VideoJson As UrlJson = New UrlJson("", "") + Public CrBetaMass As String = Nothing Public CrBetaMassEpisodes As String = Nothing Public CrBetaMassParameters As String = Nothing @@ -1147,7 +1151,7 @@ Public Class Main End If If CBool(InStr(SeasonJson, "curl:")) = True Then - MsgBox("Error - Getting SeasonJson data" + vbNewLine + SeasonJson) + MsgBox("Error - Getting SeasonJson data" + vbNewLine + SeasonJson + vbNewLine + vbNewLine + JsonUrl) Exit Sub End If SeasonJson = CleanJSON(SeasonJson) @@ -1223,6 +1227,9 @@ Public Class Main Dim ObjectsURL As String = ObjectsURLBuilder(0) + "objects/" + ObjectsURLBuilder4(0) + ObjectsURLBuilder2(1) Debug.WriteLine(ObjectsURL) + + + ObjectJson = Curl(ObjectsURL) 'MsgBox(ObjectJson) @@ -1231,7 +1238,12 @@ Public Class Main ObjectJson = Curl(ObjectsURL) End If - If CBool(InStr(ObjectJson, "curl:")) = True Then + If CBool(InStr(ObjectJson, "curl:")) = True And CBool(InStr(CR_ObjectsJson.Url, ObjectsURLBuilder4(0))) Then + Debug.WriteLine("curl error, using UrlJson " + vbNewLine + ObjectJson) + + ObjectJson = CR_ObjectsJson.Content + CR_ObjectsJson = New UrlJson("", "") + ElseIf CBool(InStr(ObjectJson, "curl:")) Then MsgBox("Error - Getting ObjectJson data" + vbNewLine + ObjectJson) Exit Sub End If @@ -1533,7 +1545,16 @@ Public Class Main VideoJson = Curl(Streams) End If - If CBool(InStr(VideoJson, "curl:")) = True Then + Dim StreamsUrlBuilder() As String = ObjectJson.Split(New String() {"videos/"}, System.StringSplitOptions.RemoveEmptyEntries) + Dim StreamsUrlBuilder2() As String = StreamsUrlBuilder(1).Split(New String() {"/streams"}, System.StringSplitOptions.RemoveEmptyEntries) + + + + If CBool(InStr(VideoJson, "curl:")) = True And CBool(InStr(CR_VideoJson.Url, StreamsUrlBuilder2(0))) Then + Debug.WriteLine("curl error, using UrlJson " + vbNewLine + VideoJson) + VideoJson = CR_VideoJson.Content + CR_VideoJson = New UrlJson("", "") + ElseIf CBool(InStr(VideoJson, "curl:")) = True Then VideoJson = Nothing MsgBox("Error - Getting VideoJson data" + vbNewLine + VideoJson) Exit Sub @@ -4224,13 +4245,11 @@ Public Class Main 'MsgBox(CR_Cookies) End Sub - Private Sub ClearAllSettingsToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ClearAllSettingsToolStripMenuItem.Click + Private Sub ClearAllSettingsToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles UrlJsonsToolStripMenuItem.Click - - If MessageBox.Show("This will clear all settings and close the programm!", "confirm?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then - Registry.CurrentUser.DeleteSubKey("Software\CRDownloader") - Me.Close() - End If + MsgBox("Season" + vbNewLine + CR_SeasonJson.Content.Count.ToString) + MsgBox("Object" + vbNewLine + CR_ObjectsJson.Content.Count.ToString) + MsgBox("Streams" + vbNewLine + CR_VideoJson.Content.Count.ToString) End Sub @@ -4375,6 +4394,20 @@ Public Class CR_Beta_Stream End Function End Class +Public Class UrlJson + + Public Url As String + Public Content As String + Public Sub New(ByVal Url As String, ByVal Content As String) + Me.Url = Url + Me.Content = Content + + End Sub + + Public Overrides Function ToString() As String + Return String.Format("{0}, {1}", Me.Url, Me.Content) + End Function +End Class Public Class ServerResponse Public Type As String diff --git a/Crunchyroll Downloader/My Project/AssemblyInfo.vb b/Crunchyroll Downloader/My Project/AssemblyInfo.vb index 65fb66c..9e2d6d9 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: ' - - + +