added token reusing, added error handling (.key files)

added reusing the access token (valid 300s in usage for ~270s)
added renewing the access token (via refresh token)
added .key file error detection (critical issue)
minor cleanup
This commit is contained in:
hama3254 2024-04-28 21:29:33 +02:00
parent 9be37f3904
commit a8aeceb617
12 changed files with 315 additions and 445 deletions

Binary file not shown.

View File

@ -479,7 +479,7 @@ Public Class Anime_Add
End Try End Try
'My.Computer.Clipboard.SetText(EpisodeJson) 'My.Computer.Clipboard.SetText(EpisodeJson)
Debug.WriteLine("EpisodeJson: " + EpisodeJson) 'Debug.WriteLine("EpisodeJson: " + EpisodeJson)
FillCREpisodes(EpisodeJson) FillCREpisodes(EpisodeJson)

View File

@ -129,9 +129,6 @@
<setting name="SaveThumbnail" serializeAs="String"> <setting name="SaveThumbnail" serializeAs="String">
<value>False</value> <value>False</value>
</setting> </setting>
<setting name="SaveMode" serializeAs="String">
<value>False</value>
</setting>
<setting name="DownloadScope" serializeAs="String"> <setting name="DownloadScope" serializeAs="String">
<value>0</value> <value>0</value>
</setting> </setting>

View File

@ -20,8 +20,8 @@ Public Class Browser
Private Sub WebView2_CoreWebView2InitializationCompleted(sender As Object, e As CoreWebView2InitializationCompletedEventArgs) Handles WebView2.CoreWebView2InitializationCompleted Private Sub WebView2_CoreWebView2InitializationCompleted(sender As Object, e As CoreWebView2InitializationCompletedEventArgs) Handles WebView2.CoreWebView2InitializationCompleted
Try Try
WebView2.CoreWebView2.AddWebResourceRequestedFilter("https://www.crunchyroll.com/*", CoreWebView2WebResourceContext.All) WebView2.CoreWebView2.AddWebResourceRequestedFilter("https://www.crunchyroll.com/*", CoreWebView2WebResourceContext.All)
AddHandler WebView2.CoreWebView2.WebResourceResponseReceived, AddressOf ObserveResponse 'AddHandler WebView2.CoreWebView2.WebResourceResponseReceived, AddressOf ObserveResponse
AddHandler WebView2.CoreWebView2.WebResourceRequested, AddressOf ObserveHttp 'AddHandler WebView2.CoreWebView2.WebResourceRequested, AddressOf ObserveHttp 'this is not the data we are looking for (anymore :( )
My.Settings.User_Agend = Chr(34) + "User-Agent: " + WebView2.CoreWebView2.Settings.UserAgent + Chr(34) My.Settings.User_Agend = Chr(34) + "User-Agent: " + WebView2.CoreWebView2.Settings.UserAgent + Chr(34)
If WebView2.CoreWebView2.Source = "about:blank" Or WebView2.CoreWebView2.Source = Nothing Then If WebView2.CoreWebView2.Source = "about:blank" Or WebView2.CoreWebView2.Source = Nothing Then
@ -162,60 +162,6 @@ Public Class Browser
End Sub 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, "v1/token")) And Main.CR_v1Token = "Get" Then
Debug.WriteLine("Crunchyroll-v1_token: " + 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
Dim Loc_CR_Cookies = " -H " + Chr(34) + Main.CR_Cookies + Chr(34)
Dim Token() As String = ContentString.Split(New String() {Chr(34) + "access_token" + Chr(34) + ":" + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries)
Dim Token2() As String = Token(1).Split(New String() {Chr(34) + "," + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries)
Dim Auth As String = "Bearer " + Token2(0)
Dim Auth2 As String = " -H " + Chr(34) + "Authorization: " + Auth + Chr(34)
Main.ProcessLoading(Main.LoadingUrl, Auth2, Loc_CR_Cookies, 0)
Main.CR_v1Token = ""
Exit Sub
ElseIf CBool(InStr(e.Request.Uri, "crunchyroll.com/")) And CBool(InStr(e.Request.Uri, "seasons?preferred_audio_language=")) And CBool(InStr(Main.LoadingUrl, "/series/")) Then
Debug.WriteLine("Crunchyroll-Season: " + e.Request.Uri)
Main.LoadedUrls.Add(e.Request)
Exit Sub
'ElseIf CBool(InStr(e.Request.Uri, "crunchyroll.com/")) And CBool(InStr(e.Request.Uri, "content/v2/cms/objects/")) Then
' Debug.WriteLine("Crunchyroll-objects added to cache: " + e.Request.Uri)
' Main.LoadedUrls.Add(e.Request)
' Exit Sub
'ElseIf CBool(InStr(e.Request.Uri, "crunchyroll.com/")) And CBool(InStr(e.Request.Uri, "seasons?preferred_audio_language=")) And CBool(InStr(Main.LoadingUrl, "/series/")) Then
' Debug.WriteLine("Crunchyroll-objects added to cache: " + e.Request.Uri)
' Main.LoadedUrls.Add(e.Request)
' Exit Sub
End If
End If
End Sub
Private Sub ObserveHttp(ByVal sender As Object, ByVal e As CoreWebView2WebResourceRequestedEventArgs) 'Handles RequestResource.GetUrl Private Sub ObserveHttp(ByVal sender As Object, ByVal e As CoreWebView2WebResourceRequestedEventArgs) 'Handles RequestResource.GetUrl

View File

@ -35,6 +35,25 @@ Public Class CR_Beta_Stream
End Class End Class
Public Class CR_Tokens
Public access_token As String
Public refresh_token As String
Public expires_Unix As Integer
Public Sub New(ByVal access_token As String, ByVal refresh_token As String, ByVal expires_Unix As Integer)
Me.access_token = access_token
Me.refresh_token = refresh_token
Me.expires_Unix = expires_Unix
End Sub
Public Overrides Function ToString() As String
Return String.Format("{0}, {1}, {2}", Me.access_token, Me.refresh_token, Me.expires_Unix.ToString)
End Function
End Class
Public Class CR_MediaVersion Public Class CR_MediaVersion
Public AudioLang As String Public AudioLang As String

View File

@ -31,10 +31,15 @@ Public Class CRD_List_Item
Dim TempFolder As String = Nothing Dim TempFolder As String = Nothing
Dim DownloadPfad As String = Nothing Dim DownloadPfad As String = Nothing
Dim ThumbnailSource As String = Nothing Dim ThumbnailSource As String = Nothing
Dim Failed As Boolean = False Dim Failed As Boolean = False
Dim FailedCount As Integer = 0 Dim FailedCount As Integer = 0
Dim FailedKey As Boolean = False
Dim HistoryDL_URL As String Dim HistoryDL_URL As String
Dim HistoryDL_Pfad As String Dim HistoryDL_Pfad As String
Dim HistoryFilename As String Dim HistoryFilename As String
Dim Retry As Boolean = False Dim Retry As Boolean = False
Dim HybridMode As Boolean = False Dim HybridMode As Boolean = False
@ -301,6 +306,32 @@ Public Class CRD_List_Item
StatusRunning = False StatusRunning = False
bt_pause.BackgroundImage = My.Resources.main_pause_play bt_pause.BackgroundImage = My.Resources.main_pause_play
ElseIf Failed = True And FailedKey = True Then
If Not Directory.Exists(Path.GetDirectoryName(HybridModePath)) Then
' Nein! Jetzt erstellen...
Try
Directory.Delete(Path.GetDirectoryName(HybridModePath))
Catch ex As Exception
Debug.WriteLine("folder issue - delete")
Exit Sub
End Try
End If
Dim Evaluator = New Thread(Sub() DownloadHybrid(HistoryDL_URL, HistoryDL_Pfad, HistoryFilename))
Evaluator.Start()
HybridMode = True
HybridRunning = True
StatusRunning = True
Failed = False
LastDate = Date.Now
LastSize = 0
LastDataRate1 = 0
LastDataRate2 = 0
LastDataRate3 = 0
FailedSegments.Clear()
LogText.Clear()
ZeitGesamtInteger = 0
ElseIf Failed = True Then ElseIf Failed = True Then
Dim Result As DialogResult = MessageBox.Show("The hybride mode has failed to download a fragment." + vbNewLine + "Press 'Retry' to retry the fragment or 'Ignore' to continue.", "Download Error", MessageBoxButtons.AbortRetryIgnore) '= DialogResult.Ignore Then Dim Result As DialogResult = MessageBox.Show("The hybride mode has failed to download a fragment." + vbNewLine + "Press 'Retry' to retry the fragment or 'Ignore' to continue.", "Download Error", MessageBoxButtons.AbortRetryIgnore) '= DialogResult.Ignore Then
@ -445,8 +476,6 @@ Public Class CRD_List_Item
#Region "Download + Update UI" #Region "Download + Update UI"
Public Sub StartDownload(ByVal DL_URL As String, ByVal DL_Pfad As String, ByVal Filename As String, ByVal DownloadHybridMode As Boolean, ByVal TempFolder As String) Public Sub StartDownload(ByVal DL_URL As String, ByVal DL_Pfad As String, ByVal Filename As String, ByVal DownloadHybridMode As Boolean, ByVal TempFolder As String)
'MsgBox(DL_URL)
Me.StyleManager = MetroStyleManager1 Me.StyleManager = MetroStyleManager1
@ -1073,7 +1102,16 @@ Public Class CRD_List_Item
Catch ex2 As Exception Catch ex2 As Exception
FailedCount = FailedCount + 1 FailedCount = FailedCount + 1
If Item_ErrorTolerance = 0 Then If CBool(InStr(DL_Pfad, ".key")) Then
Failed = True
FailedKey = True
StatusRunning = False
bt_pause.BackgroundImage = My.Resources.main_pause_play
Me.Invoke(New Action(Function() As Object
Label_percent.Text = "fatal! Failed to download 'encryption.key'"
Return Nothing
End Function))
ElseIf Item_ErrorTolerance = 0 Then
ElseIf FailedCount >= Item_ErrorTolerance Then ElseIf FailedCount >= Item_ErrorTolerance Then
FailedSegments.Add(New FailedSegemtsWithURL(DL_Pfad, DL_URL)) FailedSegments.Add(New FailedSegemtsWithURL(DL_Pfad, DL_URL))
@ -1085,6 +1123,7 @@ Public Class CRD_List_Item
Label_percent.Text = "Missing segment detected, retry or resume with the play button" Label_percent.Text = "Missing segment detected, retry or resume with the play button"
Return Nothing Return Nothing
End Function)) End Function))
End If End If
@ -1099,6 +1138,7 @@ Public Class CRD_List_Item
#End Region #End Region
Public Function DownloadHybrid(ByVal DL_URL As String, ByVal DL_Pfad As String, ByVal Filename As String) As String Public Function DownloadHybrid(ByVal DL_URL As String, ByVal DL_Pfad As String, ByVal Filename As String) As String
'MsgBox(DL_URL)
LogText.Add(Date.Now.ToString + " " + DL_URL) LogText.Add(Date.Now.ToString + " " + DL_URL)
Dim Folder As String = GeräteID() Dim Folder As String = GeräteID()
@ -1147,7 +1187,7 @@ Public Class CRD_List_Item
Return Nothing Return Nothing
End Function)) End Function))
For i As Integer = 0 To InuputStreams.Count - 1 For i As Integer = 1 To InuputStreams.Count - 1
Dim int As Integer = i Dim int As Integer = i

View File

@ -40,7 +40,6 @@ Partial Class Main
Me.Btn_Close = New System.Windows.Forms.Button() Me.Btn_Close = New System.Windows.Forms.Button()
Me.ContextMenuStrip1 = New System.Windows.Forms.ContextMenuStrip(Me.components) Me.ContextMenuStrip1 = New System.Windows.Forms.ContextMenuStrip(Me.components)
Me.QueueToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.QueueToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.SaveModeToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.SaveThumbnailAsImageToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.SaveThumbnailAsImageToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.ToggleDebugModeToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.ToggleDebugModeToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.CheckCRBetaTokenToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.CheckCRBetaTokenToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
@ -50,9 +49,9 @@ Partial Class Main
Me.UrlJsonsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.UrlJsonsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.DummyItemToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.DummyItemToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.AudioOnlyQualityToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.AudioOnlyQualityToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.LoginFormToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.Panel1 = New System.Windows.Forms.Panel() Me.Panel1 = New System.Windows.Forms.Panel()
Me.Btn_Queue = New System.Windows.Forms.Button() Me.Btn_Queue = New System.Windows.Forms.Button()
Me.LoginFormToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
CType(Me.PictureBox5, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.PictureBox5, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.ConsoleBar, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.ConsoleBar, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.MetroStyleManager1, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.MetroStyleManager1, System.ComponentModel.ISupportInitialize).BeginInit()
@ -161,7 +160,7 @@ Partial Class Main
' '
'ContextMenuStrip1 'ContextMenuStrip1
' '
Me.ContextMenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.QueueToolStripMenuItem, Me.SaveModeToolStripMenuItem, Me.SaveThumbnailAsImageToolStripMenuItem, Me.ToggleDebugModeToolStripMenuItem, Me.CheckCRBetaTokenToolStripMenuItem, Me.Timer3OffToolStripMenuItem, Me.ThreadCount, Me.CRCookieToolStripMenuItem, Me.UrlJsonsToolStripMenuItem, Me.DummyItemToolStripMenuItem, Me.AudioOnlyQualityToolStripMenuItem, Me.LoginFormToolStripMenuItem}) Me.ContextMenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.QueueToolStripMenuItem, Me.SaveThumbnailAsImageToolStripMenuItem, Me.ToggleDebugModeToolStripMenuItem, Me.CheckCRBetaTokenToolStripMenuItem, Me.Timer3OffToolStripMenuItem, Me.ThreadCount, Me.CRCookieToolStripMenuItem, Me.UrlJsonsToolStripMenuItem, Me.DummyItemToolStripMenuItem, Me.AudioOnlyQualityToolStripMenuItem, Me.LoginFormToolStripMenuItem})
Me.ContextMenuStrip1.Name = "ContextMenuStrip1" Me.ContextMenuStrip1.Name = "ContextMenuStrip1"
resources.ApplyResources(Me.ContextMenuStrip1, "ContextMenuStrip1") resources.ApplyResources(Me.ContextMenuStrip1, "ContextMenuStrip1")
' '
@ -170,11 +169,6 @@ Partial Class Main
Me.QueueToolStripMenuItem.Name = "QueueToolStripMenuItem" Me.QueueToolStripMenuItem.Name = "QueueToolStripMenuItem"
resources.ApplyResources(Me.QueueToolStripMenuItem, "QueueToolStripMenuItem") resources.ApplyResources(Me.QueueToolStripMenuItem, "QueueToolStripMenuItem")
' '
'SaveModeToolStripMenuItem
'
Me.SaveModeToolStripMenuItem.Name = "SaveModeToolStripMenuItem"
resources.ApplyResources(Me.SaveModeToolStripMenuItem, "SaveModeToolStripMenuItem")
'
'SaveThumbnailAsImageToolStripMenuItem 'SaveThumbnailAsImageToolStripMenuItem
' '
Me.SaveThumbnailAsImageToolStripMenuItem.Name = "SaveThumbnailAsImageToolStripMenuItem" Me.SaveThumbnailAsImageToolStripMenuItem.Name = "SaveThumbnailAsImageToolStripMenuItem"
@ -220,6 +214,11 @@ Partial Class Main
Me.AudioOnlyQualityToolStripMenuItem.Name = "AudioOnlyQualityToolStripMenuItem" Me.AudioOnlyQualityToolStripMenuItem.Name = "AudioOnlyQualityToolStripMenuItem"
resources.ApplyResources(Me.AudioOnlyQualityToolStripMenuItem, "AudioOnlyQualityToolStripMenuItem") resources.ApplyResources(Me.AudioOnlyQualityToolStripMenuItem, "AudioOnlyQualityToolStripMenuItem")
' '
'LoginFormToolStripMenuItem
'
Me.LoginFormToolStripMenuItem.Name = "LoginFormToolStripMenuItem"
resources.ApplyResources(Me.LoginFormToolStripMenuItem, "LoginFormToolStripMenuItem")
'
'Panel1 'Panel1
' '
resources.ApplyResources(Me.Panel1, "Panel1") resources.ApplyResources(Me.Panel1, "Panel1")
@ -236,11 +235,6 @@ Partial Class Main
Me.Btn_Queue.Name = "Btn_Queue" Me.Btn_Queue.Name = "Btn_Queue"
Me.Btn_Queue.UseVisualStyleBackColor = False Me.Btn_Queue.UseVisualStyleBackColor = False
' '
'LoginFormToolStripMenuItem
'
Me.LoginFormToolStripMenuItem.Name = "LoginFormToolStripMenuItem"
resources.ApplyResources(Me.LoginFormToolStripMenuItem, "LoginFormToolStripMenuItem")
'
'Main 'Main
' '
Me.ApplyImageInvert = True Me.ApplyImageInvert = True
@ -297,7 +291,6 @@ Partial Class Main
Friend WithEvents QueueToolStripMenuItem As ToolStripMenuItem Friend WithEvents QueueToolStripMenuItem As ToolStripMenuItem
Friend WithEvents Btn_Queue As Button Friend WithEvents Btn_Queue As Button
Friend WithEvents SaveThumbnailAsImageToolStripMenuItem As ToolStripMenuItem Friend WithEvents SaveThumbnailAsImageToolStripMenuItem As ToolStripMenuItem
Friend WithEvents SaveModeToolStripMenuItem As ToolStripMenuItem
Friend WithEvents AudioOnlyQualityToolStripMenuItem As ToolStripMenuItem Friend WithEvents AudioOnlyQualityToolStripMenuItem As ToolStripMenuItem
Friend WithEvents LoginFormToolStripMenuItem As ToolStripMenuItem Friend WithEvents LoginFormToolStripMenuItem As ToolStripMenuItem
End Class End Class

View File

@ -489,12 +489,6 @@
<data name="&gt;&gt;QueueToolStripMenuItem.Type" xml:space="preserve"> <data name="&gt;&gt;QueueToolStripMenuItem.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data> </data>
<data name="&gt;&gt;SaveModeToolStripMenuItem.Name" xml:space="preserve">
<value>SaveModeToolStripMenuItem</value>
</data>
<data name="&gt;&gt;SaveModeToolStripMenuItem.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;SaveThumbnailAsImageToolStripMenuItem.Name" xml:space="preserve"> <data name="&gt;&gt;SaveThumbnailAsImageToolStripMenuItem.Name" xml:space="preserve">
<value>SaveThumbnailAsImageToolStripMenuItem</value> <value>SaveThumbnailAsImageToolStripMenuItem</value>
</data> </data>
@ -573,12 +567,6 @@
<data name="QueueToolStripMenuItem.Text" xml:space="preserve"> <data name="QueueToolStripMenuItem.Text" xml:space="preserve">
<value>ffmpeg option</value> <value>ffmpeg option</value>
</data> </data>
<data name="SaveModeToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>233, 22</value>
</data>
<data name="SaveModeToolStripMenuItem.Text" xml:space="preserve">
<value>*Save Mode*</value>
</data>
<data name="SaveThumbnailAsImageToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing"> <data name="SaveThumbnailAsImageToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>233, 22</value> <value>233, 22</value>
</data> </data>
@ -640,7 +628,7 @@
<value>Login Form</value> <value>Login Form</value>
</data> </data>
<data name="ContextMenuStrip1.Size" type="System.Drawing.Size, System.Drawing"> <data name="ContextMenuStrip1.Size" type="System.Drawing.Size, System.Drawing">
<value>234, 290</value> <value>234, 268</value>
</data> </data>
<data name="&gt;&gt;ContextMenuStrip1.Name" xml:space="preserve"> <data name="&gt;&gt;ContextMenuStrip1.Name" xml:space="preserve">
<value>ContextMenuStrip1</value> <value>ContextMenuStrip1</value>

View File

@ -15,8 +15,7 @@ Imports System.Runtime.InteropServices
Imports MyProvider.MyProvider Imports MyProvider.MyProvider
Imports Microsoft.Web.WebView2.Core Imports Microsoft.Web.WebView2.Core
Imports Crunchyroll_Downloader.CRD_Classes Imports Crunchyroll_Downloader.CRD_Classes
Imports System.Runtime.CompilerServices
Public Class Main Public Class Main
Inherits MetroForm Inherits MetroForm
@ -25,32 +24,21 @@ Public Class Main
Dim HTML As String = Nothing Dim HTML As String = Nothing
Public CR_Cookies As String = "Cookie: " Public CR_Cookies As String = "Cookie: "
Public CheckCRLogin As Boolean = True
Public CR_AuthToken As String = ""
Public CR_v1Token As String = ""
'Public GetBetaSeasonsRetry As Boolean = False
'Public GetBetaSeasonSingle As Boolean = False
Public CR_MassSeasons As New List(Of CR_Seasons) Public CR_MassSeasons As New List(Of CR_Seasons)
Public CR_MassEpisodes As New List(Of CR_Seasons) Public CR_MassEpisodes As New List(Of CR_Seasons)
'Public CrBetaMass As String = Nothing
'Public CrBetaMassEpisodes As String = Nothing
'Public CrBetaMassParameters As String = Nothing
'Public CrBetaMassBaseURL As String = Nothing
Public Mail As String = Nothing Public Mail As String = Nothing
Public PW As String = Nothing Public PW As String = Nothing
Public CrBetaBasic As String = "Basic dC1rZGdwMmg4YzNqdWI4Zm4wZnE6eWZMRGZNZnJZdktYaDRKWFMxTEVJMmNDcXUxdjVXYW4=" Public CrBetaBasic As String = "Basic dC1rZGdwMmg4YzNqdWI4Zm4wZnE6eWZMRGZNZnJZdktYaDRKWFMxTEVJMmNDcXUxdjVXYW4="
Public CR_Token As CR_Tokens = New CR_Tokens(Nothing, "", 0)
Public locale As String = Nothing Public locale As String = Nothing
Public Url_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
Public LoadingUrl As String = "" Public LoadingUrl As String = ""
Public LoadedUrls As New List(Of CoreWebView2WebResourceRequest) Public LoadedUrls As New List(Of CoreWebView2WebResourceRequest)
@ -61,10 +49,8 @@ Public Class Main
Public KodiNaming As Boolean = False Public KodiNaming As Boolean = False
Public ErrorTolerance As Integer = 0 Public ErrorTolerance As Integer = 0
Public CookieList As New List(Of CoreWebView2Cookie) Public CookieList As New List(Of CoreWebView2Cookie)
'Public liList As New List(Of String)
Public HTMLString As String = My.Resources.Startuphtml Public HTMLString As String = My.Resources.Startuphtml
Public ListBoxList As New List(Of String) Public ListBoxList As New List(Of String)
'Public ItemList As New List(Of CRD_List_Item)
Public RunningDownloads As Integer = 0 Public RunningDownloads As Integer = 0
Public UseQueue As Boolean = False Public UseQueue As Boolean = False
Public StartServer As Integer = 0 Public StartServer As Integer = 0
@ -76,17 +62,12 @@ Public Class Main
Public LogBrowserData As Boolean = False Public LogBrowserData As Boolean = False
Public Thumbnail As String = Nothing Public Thumbnail As String = Nothing
Public MergeSubs As Boolean = False Public MergeSubs As Boolean = False
'Public IgnoreS1 As Boolean = False
Public IgnoreSeason As Integer = 0 Public IgnoreSeason As Integer = 0
Public HideFLInt As Integer = 0 Public HideFLInt As Integer = 0
Public KeepCache As Boolean = False Public KeepCache As Boolean = False
'Public SubsOnly As Boolean = False
Public DownloadScope As Integer = 0 Public DownloadScope As Integer = 0
Public VideoFormat As String = ".mp4" Public VideoFormat As String = ".mp4"
Public MergeSubsFormat As String = "mov_text" Public MergeSubsFormat As String = "mov_text"
'Public LoginDialog As Boolean = False
'Public NonCR_Timeout As Integer = 5
'Public NonCR_URL As String = Nothing
Public DlSoftSubsRDY As Boolean = True Public DlSoftSubsRDY As Boolean = True
Public DialogTaskString As String Public DialogTaskString As String
Dim NewAPIString1 As String Dim NewAPIString1 As String
@ -1073,93 +1054,92 @@ Public Class Main
Dim ObjectsURLBuilder() As String = Streams.Split(New String() {"videos"}, System.StringSplitOptions.RemoveEmptyEntries) Dim ObjectsURLBuilder() As String = Streams.Split(New String() {"videos"}, System.StringSplitOptions.RemoveEmptyEntries)
Dim ObjectsURLBuilder2() As String = ObjectsURLBuilder(1).Split(New String() {"/streams"}, System.StringSplitOptions.RemoveEmptyEntries) Dim ObjectsURLBuilder2() As String = ObjectsURLBuilder(1).Split(New String() {"/streams"}, System.StringSplitOptions.RemoveEmptyEntries)
Dim ObjectsURLBuilder3() As String = WebsiteURL.Split(New String() {"watch/"}, System.StringSplitOptions.RemoveEmptyEntries) Dim ObjectsURLBuilder3() As String = WebsiteURL.Split(New String() {"watch/"}, System.StringSplitOptions.RemoveEmptyEntries)
Dim ObjectsURLBuilder4() As String = ObjectsURLBuilder3(1).Split(New String() {"/"}, System.StringSplitOptions.RemoveEmptyEntries) Dim ObjectsURLBuilder4() As String = ObjectsURLBuilder3(1).Split(New String() {"/"}, System.StringSplitOptions.RemoveEmptyEntries)
Dim ObjectsURL As String = ObjectsURLBuilder(0) + "objects/" + ObjectsURLBuilder4(0) + ObjectsURLBuilder2(1) Dim ObjectsURL As String = ObjectsURLBuilder(0) + "objects/" + ObjectsURLBuilder4(0) + ObjectsURLBuilder2(1)
CR_EpisodeID = ObjectsURLBuilder4(0) CR_EpisodeID = ObjectsURLBuilder4(0)
Debug.WriteLine(ObjectsURL) 'Debug.WriteLine(ObjectsURL)
ObjectJson = CurlAuthNew(ObjectsURL, Loc_CR_Cookies, Loc_AuthToken) ObjectJson = CurlAuthNew(ObjectsURL, Loc_CR_Cookies, Loc_AuthToken)
'Filter JSON esqaped characters 'Filter JSON esqaped characters
'Debug.WriteLine(Date.Now.ToString + "before:" + ObjectJson) 'Debug.WriteLine(Date.Now.ToString + "before:" + ObjectJson)
Debug.WriteLine("1750: " + ObjectJson) 'Debug.WriteLine("1750: " + ObjectJson)
ObjectJson = CleanJSON(ObjectJson) ObjectJson = CleanJSON(ObjectJson)
'Debug.WriteLine(Date.Now.ToString + "after:" + ObjectJson) 'Debug.WriteLine(Date.Now.ToString + "after:" + ObjectJson)
Dim DubsAvalible As New List(Of CR_MediaVersion) Dim DubsAvalible As New List(Of CR_MediaVersion)
Dim ser As JObject = JObject.Parse(ObjectJson) Dim ser As JObject = JObject.Parse(ObjectJson)
Dim data As List(Of JToken) = ser.Children().ToList Dim data As List(Of JToken) = ser.Children().ToList
For Each item As JProperty In data For Each item As JProperty In data
item.CreateReader() item.CreateReader()
Select Case item.Name Select Case item.Name
Case "data" 'each record is inside the entries array Case "data" 'each record is inside the entries array
For Each Entry As JObject In item.Values For Each Entry As JObject In item.Values
Try Try
Dim Title As String = Entry("title").ToString Dim Title As String = Entry("title").ToString
CR_title = String.Join(" ", Title.Split(invalids, StringSplitOptions.RemoveEmptyEntries)).TrimEnd("."c).Replace(Chr(34), "").Replace("\", "").Replace("/", "").Replace(":", "") CR_title = String.Join(" ", Title.Split(invalids, StringSplitOptions.RemoveEmptyEntries)).TrimEnd("."c).Replace(Chr(34), "").Replace("\", "").Replace("/", "").Replace(":", "")
Debug.WriteLine(Date.Now.ToString + " CR-Title: " + CR_title) Debug.WriteLine(Date.Now.ToString + " CR-Title: " + CR_title)
Catch ex As Exception Catch ex As Exception
End Try End Try
Dim SubData As List(Of JToken) = Entry.Children().ToList Dim SubData As List(Of JToken) = Entry.Children().ToList
For Each SubItem As JProperty In SubData For Each SubItem As JProperty In SubData
'SubItem.CreateReader() 'SubItem.CreateReader()
Select Case SubItem.Name Select Case SubItem.Name
Case "episode_metadata" Case "episode_metadata"
For Each SubEntry As JProperty In SubItem.Values For Each SubEntry As JProperty In SubItem.Values
Select Case SubEntry.Name Select Case SubEntry.Name
Case "series_title" Case "series_title"
CR_series_title = SubEntry.Value.ToString.Replace(Chr(34), "").Replace("\", "").Replace("/", "").Replace(":", "") CR_series_title = SubEntry.Value.ToString.Replace(Chr(34), "").Replace("\", "").Replace("/", "").Replace(":", "")
'Case "season_title" 'Case "season_title"
' CR_season_title = SubEntry.Value.ToString ' CR_season_title = SubEntry.Value.ToString
Case "season_number" Case "season_number"
CR_season_number = SubEntry.Value.ToString.Replace(Chr(34), "").Replace("\", "").Replace("/", "").Replace(":", "") CR_season_number = SubEntry.Value.ToString.Replace(Chr(34), "").Replace("\", "").Replace("/", "").Replace(":", "")
Case "episode_number" Case "episode_number"
CR_episode2 = SubEntry.Value.ToString.Replace(Chr(34), "").Replace("\", "").Replace("/", "").Replace(":", "") CR_episode2 = SubEntry.Value.ToString.Replace(Chr(34), "").Replace("\", "").Replace("/", "").Replace(":", "")
Case "episode" Case "episode"
CR_episode = SubEntry.Value.ToString.Replace(Chr(34), "").Replace("\", "").Replace("/", "").Replace(":", "") CR_episode = SubEntry.Value.ToString.Replace(Chr(34), "").Replace("\", "").Replace("/", "").Replace(":", "")
Case "duration_ms" Case "duration_ms"
CR_episode_duration_ms = SubEntry.Value.ToString.Replace(Chr(34), "").Replace("\", "").Replace("/", "").Replace(":", "") CR_episode_duration_ms = SubEntry.Value.ToString.Replace(Chr(34), "").Replace("\", "").Replace("/", "").Replace(":", "")
Case "is_dubbed" Case "is_dubbed"
CR_audio_isDubbed = CBool(SubEntry.Value.ToString.Replace(Chr(34), "").Replace("\", "").Replace("/", "").Replace(":", "")) CR_audio_isDubbed = CBool(SubEntry.Value.ToString.Replace(Chr(34), "").Replace("\", "").Replace("/", "").Replace(":", ""))
Case "audio_locale" Case "audio_locale"
CR_audio_locale = SubEntry.Value.ToString.Replace(Chr(34), "").Replace("\", "").Replace("/", "").Replace(":", "") CR_audio_locale = SubEntry.Value.ToString.Replace(Chr(34), "").Replace("\", "").Replace("/", "").Replace(":", "")
Case "versions" 'each record is inside the entries array Case "versions" 'each record is inside the entries array
For Each VersionEntry As JObject In item.Values For Each VersionEntry As JObject In item.Values
Dim VideoSubData As List(Of JToken) = VersionEntry.Children().ToList Dim VideoSubData As List(Of JToken) = VersionEntry.Children().ToList
Dim guid As String = Nothing Dim guid As String = Nothing
Dim audio_locale As String = Nothing Dim audio_locale As String = Nothing
For Each VideoSubItem As JProperty In VideoSubData For Each VideoSubItem As JProperty In VideoSubData
Select Case VideoSubItem.Name Select Case VideoSubItem.Name
Case "audio_locale" Case "audio_locale"
audio_locale = VideoSubItem.Value.ToString audio_locale = VideoSubItem.Value.ToString
Case "guid" Case "guid"
guid = VideoSubItem.Value.ToString guid = VideoSubItem.Value.ToString
'Debug.WriteLine(guid) 'Debug.WriteLine(guid)
End Select End Select
Next
If audio_locale = Nothing Or guid = Nothing Then
Else
DubsAvalible.Add(New CR_MediaVersion(audio_locale, guid))
End If
Next Next
End Select
If audio_locale = Nothing Or guid = Nothing Then Next '
Else End Select
DubsAvalible.Add(New CR_MediaVersion(audio_locale, guid)) Next
End If
Next
End Select
Next '
End Select
Next Next
Next End Select
End Select Next
Next
#Region "m3u8 suche" #Region "m3u8 suche"
@ -1167,15 +1147,15 @@ Public Class Main
#Region "Check for dub override" #Region "Check for dub override"
If My.Settings.OverrideDub = True And CR_audio_locale = DubSprache.CR_Value = False Then 'einstellung ein + kein musikvideo oder Konzert If My.Settings.OverrideDub = True And CR_audio_locale = DubSprache.CR_Value = False Then 'einstellung ein + kein musikvideo oder Konzert
'MsgBox("Trigger on!") 'MsgBox("Trigger on!")
For i As Integer = 0 To DubsAvalible.Count - 1 For i As Integer = 0 To DubsAvalible.Count - 1
If DubsAvalible(i).AudioLang = DubSprache.CR_Value Then If DubsAvalible(i).AudioLang = DubSprache.CR_Value Then
page_guid = DubsAvalible(i).guid page_guid = DubsAvalible(i).guid
End If End If
Next Next
End If End If
#End Region #End Region
End If End If
@ -1183,7 +1163,7 @@ Public Class Main
Debug.WriteLine("NewAPI: " + NewAPI) Debug.WriteLine("NewAPI: " + NewAPI)
Dim NewAPIData As String = CurlAuthNew(NewAPI, "", Loc_AuthToken) Dim NewAPIData As String = CurlAuthNew(NewAPI, "", Loc_AuthToken)
Debug.WriteLine("NewAPIData: " + NewAPIData) 'Debug.WriteLine("NewAPIData: " + NewAPIData)
Dim VideoJSON_New As String = CleanJSON(NewAPIData) Dim VideoJSON_New As String = CleanJSON(NewAPIData)
@ -1217,7 +1197,10 @@ Public Class Main
End Select End Select
Next Next
Me.Invoke(New Action(Function() As Object
SetStatusLabel("Status: API data received")
Return Nothing
End Function))
Dim CR_URI_Master As New List(Of String) Dim CR_URI_Master As New List(Of String)
@ -1273,23 +1256,11 @@ Public Class Main
End If End If
End If End If
'MsgBox(CR_URI_Master.Count.ToString) Me.Invoke(New Action(Function() As Object
SetStatusLabel("Status: Language found")
Return Nothing
End Function))
'If CBool(InStr(CR_URI_Master(0), "master.m3u8")) Then
' Me.Invoke(New Action(Function() As Object
' Anime_Add.StatusLabel.Text = "Status: m3u8 found, looking for resolution"
' Me.Text = "Status: m3u8 found, looking for resolution"
' Me.Invalidate()
' Return Nothing
' End Function))
'Else
' If MessageBox.Show("The Url below failed a check, continue?" + vbNewLine + CR_URI_Master(0), "Mission failed?", MessageBoxButtons.OKCancel) = DialogResult.OK Then
' Else
' Throw New System.Exception("Premium Episode")
' End If
' Throw New System.Exception("Premium Episode")
'End If
#End Region #End Region
@ -1606,6 +1577,7 @@ Public Class Main
If DownloadScope = DownloadScopeEnum.SubsOnly Then If DownloadScope = DownloadScopeEnum.SubsOnly Then
ffmpegInput = "-i [Subtitles only]" ffmpegInput = "-i [Subtitles only]"
Else Else
Dim str As String = CurlAuthNew(CR_URI_Master(0), "", Loc_AuthToken) Dim str As String = CurlAuthNew(CR_URI_Master(0), "", Loc_AuthToken)
@ -1674,7 +1646,11 @@ Public Class Main
End If End If
Me.Invoke(New Action(Function() As Object
SetStatusLabel("Status: Resolution found")
Pause(2)
Return Nothing
End Function))
#End Region #End Region
@ -1686,7 +1662,6 @@ Public Class Main
'Dim SplitVideo As String() = VideoJson.Split(New String() {Chr(34) + "closed_captions" + Chr(34) + ":"}, System.StringSplitOptions.RemoveEmptyEntries) 'Dim SplitVideo As String() = VideoJson.Split(New String() {Chr(34) + "closed_captions" + Chr(34) + ":"}, System.StringSplitOptions.RemoveEmptyEntries)
'If SoftSubs.Count > 0 And My.Settings.Captions = True Then 'If SoftSubs.Count > 0 And My.Settings.Captions = True Then
@ -1698,6 +1673,11 @@ Public Class Main
'End If 'End If
'"language":"de-DE" '"language":"de-DE"
If SoftSubs.Count > 0 Then 'And CCAvailable.Count = 0 Then If SoftSubs.Count > 0 Then 'And CCAvailable.Count = 0 Then
Me.Invoke(New Action(Function() As Object
SetStatusLabel("Status: Checking Soft-Subs")
Return Nothing
End Function))
For i As Integer = 0 To SoftSubs.Count - 1 For i As Integer = 0 To SoftSubs.Count - 1
If CBool(InStr(VideoJSON_New, Chr(34) + "language" + Chr(34) + ":" + Chr(34) + SoftSubs(i) + Chr(34) + "," + Chr(34) + "url" + Chr(34) + ":" + Chr(34))) Then If CBool(InStr(VideoJSON_New, Chr(34) + "language" + Chr(34) + ":" + Chr(34) + SoftSubs(i) + Chr(34) + "," + Chr(34) + "url" + Chr(34) + ":" + Chr(34))) Then
SoftSubsAvailable.Add(SoftSubs(i)) SoftSubsAvailable.Add(SoftSubs(i))
@ -2311,84 +2291,6 @@ Public Class Main
#End Region #End Region
Public Sub ProcessUrls()
Debug.WriteLine(LoadedUrls.Count.ToString)
Debug.WriteLine(Date.Now.ToString + " Thread Name: " + Thread.CurrentThread.Name)
Dim SavedObjectsUrl = ""
For i As Integer = 0 To LoadedUrls.Count - 1
Dim Request As CoreWebView2WebResourceRequest = LoadedUrls.Item(i)
If CBool(InStr(Request.Uri, "crunchyroll.com/")) And CBool(InStr(Request.Uri, "streams?")) Then
If b = False Then
If Application.OpenForms().OfType(Of Anime_Add).Any = True Then
Anime_Add.StatusLabel.Text = "Status: Crunchyroll episode found."
End If
Me.Text = "Status: Crunchyroll episode found."
Debug.WriteLine("Crunchyroll episode found")
GetCRVideoProxy(Request.Uri, CR_AuthToken, WebbrowserURL, 0)
b = True
LoadedUrls.Clear()
Me.Text = "Crunchyroll Downloader"
Exit Sub
End If
ElseIf CBool(InStr(Request.Uri, "crunchyroll.com/")) And CBool(InStr(Request.Uri, "seasons?preferred_audio_language=")) And CBool(InStr(WebbrowserURL, "series")) Then
If b = False Then
If Application.OpenForms().OfType(Of Anime_Add).Any = True Then
Anime_Add.StatusLabel.Text = "Status: Crunchyroll season found."
End If
Me.Text = "Status: Crunchyroll season found."
Debug.WriteLine("Crunchyroll season found")
Dim Auth As String = " -H " + Chr(34) + "Authorization: " + Request.Headers.GetHeader("Authorization") + Chr(34)
Debug.WriteLine(Auth)
CR_Cookies = "Cookie: " + Request.Headers.GetHeader("Cookie")
GetBetaSeasons(WebbrowserURL, Request.Uri, Auth)
'Browser.WebBrowser1.LoadUrl(Request.Uri)
b = True
LoadedUrls.Clear()
Me.Text = "Crunchyroll Downloader"
Exit Sub
End If
ElseIf CBool(InStr(Request.Uri, "crunchyroll.com/")) And CBool(InStr(Request.Uri, "seasons?series_id=")) Then
If b = False Then
If Application.OpenForms().OfType(Of Anime_Add).Any = True Then
Anime_Add.StatusLabel.Text = "Status: Error found invalid data."
End If
b = True
LoadedUrls.Clear()
Me.Text = "Crunchyroll Downloader"
Exit Sub
End If
End If
Next
LoadedUrls.Clear()
If b = True Then
LoadedUrls.Clear()
Debug.WriteLine("Just Browsing after all, exiting...")
Grapp_RDY = True
Me.Text = "Crunchyroll Downloader"
Exit Sub
End If
End Sub
Public Sub Navigate(ByVal Url As String) Public Sub Navigate(ByVal Url As String)
If Application.OpenForms().OfType(Of Browser).Any = True Then If Application.OpenForms().OfType(Of Browser).Any = True Then
@ -2996,10 +2898,6 @@ Public Class Main
LoadedUrls.Clear() LoadedUrls.Clear()
Dim NoBrowser As Boolean = False Dim NoBrowser As Boolean = False
If My.Settings.SaveMode = True Then
Browser.WebView2.CoreWebView2.Navigate(Url)
Exit Sub
End If
'CR_v1Token = "Get" 'CR_v1Token = "Get"
'Browser.WebView2.Source = New Uri(Url) 'Browser.WebView2.Source = New Uri(Url)
@ -3012,153 +2910,167 @@ Public Class Main
#Region "Get Cookies" #Region "Get Cookies"
CR_Cookies = "Cookie: " 'CR_Cookies = "Cookie: "
'MsgBox("Cookies") ''MsgBox("Cookies")
If File.Exists("cookies.txt") = True Then 'If File.Exists("cookies.txt") = True Then
CR_Cookies = GetCookiesFromFile("crunchyroll.com") ' CR_Cookies = GetCookiesFromFile("crunchyroll.com")
NoBrowser = True ' NoBrowser = True
CrBetaBasic = "Basic bm9haWhkZXZtXzZpeWcwYThsMHE6" ' CrBetaBasic = "Basic bm9haWhkZXZtXzZpeWcwYThsMHE6"
'MsgBox(True.ToString) ' 'MsgBox(True.ToString)
Else 'Else
Browser.GetCookies(Url) ' Browser.GetCookies(Url)
Debug.WriteLine(CookieList.Count.ToString) ' Debug.WriteLine(CookieList.Count.ToString)
If CookieList.Count = 0 Then ' If CookieList.Count = 0 Then
Browser.WebView2.CoreWebView2.Navigate(Url) ' Browser.WebView2.CoreWebView2.Navigate(Url)
SetStatusLabel("Status: loading in browser...") ' SetStatusLabel("Status: loading in browser...")
Me.Text = "Status: loading in browser..." ' Me.Text = "Status: loading in browser..."
Exit Sub ' Exit Sub
End If ' End If
For i As Integer = 0 To CookieList.Count - 1 ' For i As Integer = 0 To CookieList.Count - 1
If CBool(InStr(CookieList.Item(i).Domain, ".crunchyroll.com")) And CBool(InStr(CookieList.Item(i).Name, "_evidon_suppress")) = False Then ' If CBool(InStr(CookieList.Item(i).Domain, ".crunchyroll.com")) And CBool(InStr(CookieList.Item(i).Name, "_evidon_suppress")) = False Then
CR_Cookies = CR_Cookies + CookieList.Item(i).Name + "=" + CookieList.Item(i).Value + ";" ' CR_Cookies = CR_Cookies + CookieList.Item(i).Name + "=" + CookieList.Item(i).Value + ";"
End If ' End If
Next ' Next
End If 'End If
'MsgBox(Main.CR_Cookies) ''MsgBox(Main.CR_Cookies)
Dim DeviceRegion As String = Nothing 'Dim DeviceRegion As String = Nothing
If CBool(InStr(Url, "/series")) Then 'If CBool(InStr(Url, "/series")) Then
Dim locale1() As String = Url.Split(New String() {"crunchyroll.com/"}, System.StringSplitOptions.RemoveEmptyEntries) ' 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) ' Dim locale2() As String = locale1(1).Split(New String() {"/series"}, System.StringSplitOptions.RemoveEmptyEntries)
locale = Convert_locale(locale2(0)) ' locale = Convert_locale(locale2(0))
If locale = "en-US" Then ' If locale = "en-US" Then
Url_locale = "" ' Url_locale = ""
Else ' Else
Url_locale = locale2(0) ' Url_locale = locale2(0)
End If ' End If
ElseIf CBool(InStr(Url, "/watch")) Then 'ElseIf CBool(InStr(Url, "/watch")) Then
Dim locale1() As String = Url.Split(New String() {"crunchyroll.com/"}, System.StringSplitOptions.RemoveEmptyEntries) ' Dim locale1() As String = Url.Split(New String() {"crunchyroll.com/"}, System.StringSplitOptions.RemoveEmptyEntries)
Dim locale2() As String = locale1(1).Split(New String() {"/watch"}, System.StringSplitOptions.RemoveEmptyEntries) ' Dim locale2() As String = locale1(1).Split(New String() {"/watch"}, System.StringSplitOptions.RemoveEmptyEntries)
'MsgBox(locale2(0)) ' 'MsgBox(locale2(0))
locale = Convert_locale(locale2(0)) ' locale = Convert_locale(locale2(0))
'End If ' 'End If
If locale = "en-US" Then ' If locale = "en-US" Then
Url_locale = "" ' Url_locale = ""
Else ' Else
Url_locale = locale2(0) ' Url_locale = locale2(0)
End If ' End If
'If CBool(InStr(Url, "musicvideo/")) Then ' 'If CBool(InStr(Url, "musicvideo/")) Then
' SetStatusLabel("Status: musicvideo detected - partial support only") ' ' SetStatusLabel("Status: musicvideo detected - partial support only")
' Browser.WebView2.CoreWebView2.Navigate(Url) ' ' Browser.WebView2.CoreWebView2.Navigate(Url)
' Exit Sub ' ' Exit Sub
'Else ' 'Else
'If CBool(InStr(Url, "/concert/")) Then ' 'If CBool(InStr(Url, "/concert/")) Then
' SetStatusLabel("Status: concert detected - partial support only") ' ' SetStatusLabel("Status: concert detected - partial support only")
' Browser.WebView2.CoreWebView2.Navigate(Url) ' ' Browser.WebView2.CoreWebView2.Navigate(Url)
' Exit Sub ' ' Exit Sub
' End If ' ' End If
End If 'End If
'Debug.WriteLine("###" + CR_Cookies + "###") ''Debug.WriteLine("###" + CR_Cookies + "###")
Dim Loc_CR_Cookies = " -H " + Chr(34) + CR_Cookies + Chr(34) 'Dim Loc_CR_Cookies = " -H " + Chr(34) + CR_Cookies + Chr(34)
'CR_v1Token = "Get" ''CR_v1Token = "Get"
'Browser.WebView2.Source = New Uri(Url) ''Browser.WebView2.Source = New Uri(Url)
'Exit Sub ''Exit Sub
#End Region #End Region
Dim Loc_CR_Cookies As String = "" ' do we need that? does not seem like it.
Dim Auth As String = " -H " + Chr(34) + "Authorization: " + CrBetaBasic + Chr(34) Dim Auth As String = " -H " + Chr(34) + "Authorization: " + CrBetaBasic + Chr(34)
'Dim Post As String = " -d " + Chr(34) + "grant_type=etp_rt_cookie" + Chr(34) + " -X POST"
Dim Post As String = " -d " + Chr(34) + "username=" + UrlEncode(Mail) + "&password=" + UrlEncode(PW) + "&grant_type=password&scope=offline_access" + Chr(34) + " -X POST -H " + Chr(34) + "Content-Type: application/x-www-form-urlencoded; charset=utf-8" + Chr(34) Dim Post As String = Nothing
Dim UnixTime As Integer
UnixTime = CInt((DateTime.UtcNow - New DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds)
If CBool(CR_Token.access_token = Nothing) = True Then ' *insert *First time* meme
Post = " -d " + Chr(34) + "username=" + UrlEncode(Mail) + "&password=" + UrlEncode(PW) + "&grant_type=password&scope=offline_access" + Chr(34) + " -X POST -H " + Chr(34) + "Content-Type: application/x-www-form-urlencoded; charset=utf-8" + Chr(34)
SetStatusLabel("Status: using login to authenticate")
Pause(2)
ElseIf CR_Token.expires_Unix + 30 > UnixTime Then 'we are not expired yet (+10% tolleranz)
Post = "Skip!"
SetStatusLabel("Status: Token not expired - skip auth")
Pause(2)
ElseIf CR_Token.expires_Unix + 30 < UnixTime Then 'we should renew it
Post = " -d " + Chr(34) + "refresh_token=" + CR_Token.refresh_token + "&grant_type=refresh_token&scope=offline_access" + Chr(34) + " -X POST -H " + Chr(34) + "Content-Type: application/x-www-form-urlencoded; charset=utf-8" + Chr(34)
SetStatusLabel("Status: Token expired - refreshing")
Pause(2)
End If
' '
Dim CRBetaBearer As String = "Bearer " Dim CRBetaBearer As String = "Bearer "
If Post = "Skip!" Then
Dim Auth2 As String = " -H " + Chr(34) + "Authorization: " + CRBetaBearer + CR_Token.access_token + Chr(34)
ProcessLoading(Url, Auth2, Loc_CR_Cookies, RT_count)
Else
Dim v1Token As String = CurlPost("https://www.crunchyroll.com/auth/v1/token", Loc_CR_Cookies, Auth, Post, "add_main_4494")
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")
LoginForm.ShowDialog()
Exit Sub
End If
If CBool(InStr(v1Token, "curl:")) = True And CBool(InStr(v1Token, "401")) = True Then If CBool(InStr(v1Token, "curl:")) = True And CBool(InStr(v1Token, "400")) = True Then
MsgBox("CR reported error 401, this may mean incorrect login detail, please try again.", MsgBoxStyle.Exclamation, "CR-Error 401") MsgBox("CR reported error 400, idk why tbh", MsgBoxStyle.Exclamation, "CR-Error 400")
LoginForm.ShowDialog() SetStatusLabel("Status: Unknown error. #3038")
Exit Sub Exit Sub
End If End If
If CBool(InStr(v1Token, "curl:")) = True And CBool(InStr(v1Token, "400")) = True Then
Debug.WriteLine("Post error!, 400")
Post = " -d " + Chr(34) + "grant_type=client_id&scope=offline_access" + Chr(34) + " -X POST"
Debug.WriteLine(Post.Replace("etp_rt_cookie", "client_id")) If CBool(InStr(v1Token, "curl: (60)")) = True Then
v1Token = CurlPost("https://www.crunchyroll.com/auth/v1/token", Loc_CR_Cookies, Auth, Post.Replace("etp_rt_cookie", "client_id"), "add_main-4499") SetStatusLabel("Status: Critical error. #3043")
MsgBox("Please try the '--insecure' option found on the 'Main' page of the settings.")
Exit Sub
'ElseIf CBool(InStr(v1Token, "curl:")) Then
ElseIf CBool(InStr(v1Token, "curl:")) = True Then
' Browser.WebView2.CoreWebView2.Navigate(Url)
SetStatusLabel("Status: Unknown error. #3050")
Exit Sub
End If
Dim Token() As String = v1Token.Split(New String() {Chr(34) + "access_token" + Chr(34) + ":" + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries)
Dim Token2() As String = Token(1).Split(New String() {Chr(34) + "," + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries)
CRBetaBearer = CRBetaBearer + Token2(0)
Dim RefrehToken() As String = v1Token.Split(New String() {Chr(34) + "refresh_token" + Chr(34) + ":" + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries)
Dim RefrehToken2() As String = RefrehToken(1).Split(New String() {Chr(34) + "," + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries)
Dim TokenUnixTime As Integer
TokenUnixTime = CInt((DateTime.UtcNow - New DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds) + 300
CR_Token = New CR_Tokens(Token2(0), RefrehToken2(0), TokenUnixTime)
Dim Auth2 As String = " -H " + Chr(34) + "Authorization: " + CRBetaBearer + Chr(34)
ProcessLoading(Url, Auth2, Loc_CR_Cookies, RT_count)
End If End If
'MsgBox(v1Token)
If CBool(InStr(v1Token, "curl:")) = True And CBool(InStr(v1Token, "400")) = True Then
SetStatusLabel("Status: Failed - bad request, check CR login")
Me.Text = "Status: Failed - bad request, check CR login"
Debug.WriteLine("Status: Failed - bad request, check CR login")
b = True
Exit Sub
ElseIf CBool(InStr(v1Token, "curl:")) = True Then
v1Token = CurlPost("https://www.crunchyroll.com/auth/v1/token", Loc_CR_Cookies, Auth, Post, "add_main_4516")
End If
'MsgBox(v1Token)
If CBool(InStr(v1Token, "curl: (60)")) = True Then
SetStatusLabel("Status: Critical error. #4478")
MsgBox("Please try the '--insecure' option found on the 'Main' page of the settings.")
Exit Sub
'ElseIf CBool(InStr(v1Token, "curl:")) Then
ElseIf CBool(InStr(v1Token, "curl:")) = True Then
Browser.WebView2.CoreWebView2.Navigate(Url)
Exit Sub
End If
Dim Token() As String = v1Token.Split(New String() {Chr(34) + "access_token" + Chr(34) + ":" + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries)
Dim Token2() As String = Token(1).Split(New String() {Chr(34) + "," + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries)
CRBetaBearer = CRBetaBearer + Token2(0)
Dim Auth2 As String = " -H " + Chr(34) + "Authorization: " + CRBetaBearer + Chr(34)
ProcessLoading(Url, Auth2, Loc_CR_Cookies, RT_count)
Else Else
'to do 'to do
End If End If
@ -3181,7 +3093,7 @@ Public Class Main
ElseIf CBool(InStr(url, "crunchyroll.com")) = True And CBool(InStr(url, "watch/")) = True And CBool(CrBetaBasic = Nothing) = False And CBool(InStr(url, "/musicvideo/")) = False And CBool(InStr(url, "/concert/")) = False Then ElseIf CBool(InStr(url, "crunchyroll.com")) = True And CBool(InStr(url, "watch/")) = True And CBool(CrBetaBasic = Nothing) = False And CBool(InStr(url, "/musicvideo/")) = False And CBool(InStr(url, "/concert/")) = False Then
#Region "Anime" #Region "Anime"
SetStatusLabel("Status: Url match - Anime episode")
Dim ObjectsUrl As String = Nothing Dim ObjectsUrl As String = Nothing
@ -3254,7 +3166,7 @@ Public Class Main
#End Region #End Region
ElseIf CBool(InStr(url, "crunchyroll.com")) = True And CBool(InStr(url, "musicvideo/")) = True And CBool(CrBetaBasic = Nothing) = False Then ElseIf CBool(InStr(url, "crunchyroll.com")) = True And CBool(InStr(url, "musicvideo/")) = True And CBool(CrBetaBasic = Nothing) = False Then
#Region "musik videos" #Region "musik videos"
SetStatusLabel("Status: Url match - Music video")
Dim ObjectsUrl As String = Nothing Dim ObjectsUrl As String = Nothing
@ -3307,6 +3219,8 @@ Public Class Main
GetCRVideoProxy(StreamsUrl, Auth2, url, RT_Count) GetCRVideoProxy(StreamsUrl, Auth2, url, RT_Count)
#End Region #End Region
ElseIf CBool(InStr(url, "crunchyroll.com")) = True And CBool(InStr(url, "concert/")) = True And CBool(CrBetaBasic = Nothing) = False Then ElseIf CBool(InStr(url, "crunchyroll.com")) = True And CBool(InStr(url, "concert/")) = True And CBool(CrBetaBasic = Nothing) = False Then
#Region "concert"
SetStatusLabel("Status: Url match - Concert")
Dim ObjectsUrl As String = Nothing Dim ObjectsUrl As String = Nothing
@ -3357,8 +3271,10 @@ Public Class Main
GetCRVideoProxy(StreamsUrl, Auth2, url, RT_Count) GetCRVideoProxy(StreamsUrl, Auth2, url, RT_Count)
#End Region
Else Else
Browser.WebView2.CoreWebView2.Navigate(url)
'Browser.WebView2.CoreWebView2.Navigate(url)
End If End If
@ -3411,9 +3327,9 @@ Public Class Main
Sub SetStatusLabel(ByVal txt As String) Sub SetStatusLabel(ByVal txt As String)
If Application.OpenForms().OfType(Of Anime_Add).Any = True Then If Application.OpenForms().OfType(Of Anime_Add).Any = True Then
Anime_Add.StatusLabel.Text = txt Anime_Add.StatusLabel.Text = txt
End If End If
Me.Text = txt
Debug.WriteLine("StatusLabel: " + Date.Now.ToString + " - " + txt)
End Sub End Sub
Private Sub SaveThumbnailAsImageToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SaveThumbnailAsImageToolStripMenuItem.Click Private Sub SaveThumbnailAsImageToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SaveThumbnailAsImageToolStripMenuItem.Click
@ -3430,20 +3346,6 @@ Public Class Main
End If End If
End Sub End Sub
Private Sub SaveModeToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SaveModeToolStripMenuItem.Click
If My.Settings.SaveMode = False Then
My.Settings.SaveMode = True
MsgBox("SaveMode enabled")
My.Settings.Save()
Else
My.Settings.SaveMode = False
MsgBox("SaveMode disabled")
My.Settings.Save()
End If
End Sub
Private Sub Panel1_Paint(sender As Object, e As PaintEventArgs) Handles Panel1.Paint Private Sub Panel1_Paint(sender As Object, e As PaintEventArgs) Handles Panel1.Paint
End Sub End Sub

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.22.2")> <Assembly: AssemblyVersion("3.23")>
<Assembly: AssemblyFileVersion("3.22.2")> <Assembly: AssemblyFileVersion("3.23")>
<Assembly: NeutralResourcesLanguage("en")> <Assembly: NeutralResourcesLanguage("en")>

View File

@ -486,18 +486,6 @@ Namespace My
End Set End Set
End Property End Property
<Global.System.Configuration.UserScopedSettingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Configuration.DefaultSettingValueAttribute("False")> _
Public Property SaveMode() As Boolean
Get
Return CType(Me("SaveMode"),Boolean)
End Get
Set
Me("SaveMode") = value
End Set
End Property
<Global.System.Configuration.UserScopedSettingAttribute(), _ <Global.System.Configuration.UserScopedSettingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _ Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Configuration.DefaultSettingValueAttribute("0")> _ Global.System.Configuration.DefaultSettingValueAttribute("0")> _

View File

@ -110,9 +110,6 @@
<Setting Name="SaveThumbnail" Type="System.Boolean" Scope="User"> <Setting Name="SaveThumbnail" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value> <Value Profile="(Default)">False</Value>
</Setting> </Setting>
<Setting Name="SaveMode" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="DownloadScope" Type="System.Int32" Scope="User"> <Setting Name="DownloadScope" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value> <Value Profile="(Default)">0</Value>
</Setting> </Setting>