added cookies.txt support

added cookies.txt support #632
This commit is contained in:
hama3254 2022-12-19 21:15:30 +01:00
parent 37f10d366f
commit 8e7544b100
4 changed files with 79 additions and 51 deletions

Binary file not shown.

View File

@ -16,17 +16,56 @@ Public Class Anime_Add
Public List_DL_Cancel As Boolean = False Public List_DL_Cancel As Boolean = False
Public Function GetCookiesFromFile(ByVal Host As String) As String
Dim Cookies As String = "Cookie: "
Dim Cookie_txt As String = My.Computer.FileSystem.ReadAllText("cookies.txt")
Dim LineChar As String = vbCrLf
If CBool(InStr(Cookie_txt, vbCr)) Then
LineChar = vbCr
'Debug.WriteLine("vbCr")
ElseIf CBool(InStr(Cookie_txt, vbLf)) Then
LineChar = vbLf
'Debug.WriteLine("vbLf")
End If
Dim Cookie_txt1() As String = Cookie_txt.Split(New String() {LineChar}, System.StringSplitOptions.RemoveEmptyEntries)
Debug.WriteLine("got txt")
For i As Integer = 0 To Cookie_txt1.Count - 1
Dim Cookie_txt2() As String = Cookie_txt1(i).Split(New String() {Chr(9)}, System.StringSplitOptions.RemoveEmptyEntries)
If CBool(InStr(Cookie_txt2(0), Host)) = True Then
If CBool(InStr(Cookie_txt2(5), "_evidon_suppress")) = True Then
Continue For
End If
Cookies = Cookies + Cookie_txt2(5) + "=" + Cookie_txt2(6) + ";"
Public Authorization As String = Nothing
Public AuthorizationCookie As String = Nothing End If
Next
Debug.WriteLine(Cookies)
Return Cookies
End Function
Public Sub LoadBrowser(ByVal Url As String) Public Sub LoadBrowser(ByVal Url As String)
Main.LoadingUrl = Url Main.LoadingUrl = Url
Main.LoadedUrls.Clear() Main.LoadedUrls.Clear()
Dim NoBrowser As Boolean = False
'Browser.WebView2.Source = New Uri(Url) 'Browser.WebView2.Source = New Uri(Url)
'Exit Sub 'Exit Sub
'MsgBox(Url) 'MsgBox(Url)
@ -39,36 +78,39 @@ Public Class Anime_Add
Main.CR_Cookies = "Cookie: " Main.CR_Cookies = "Cookie: "
'MsgBox("Cookies") 'MsgBox("Cookies")
Browser.GetCookies(Url) If File.Exists("cookies.txt") = True Then
'MsgBox("Cookies2") Main.CR_Cookies = GetCookiesFromFile("crunchyroll.com")
NoBrowser = True
Main.CrBetaBasic = "Basic bm9haWhkZXZtXzZpeWcwYThsMHE6"
'MsgBox(True.ToString)
Else
Browser.GetCookies(Url)
Debug.WriteLine(Main.CookieList.Count.ToString) Debug.WriteLine(Main.CookieList.Count.ToString)
If Main.CookieList.Count = 0 Then If Main.CookieList.Count = 0 Then
Browser.WebView2.CoreWebView2.Navigate(Url) Browser.WebView2.CoreWebView2.Navigate(Url)
StatusLabel.Text = "Status: loading in browser..." StatusLabel.Text = "Status: loading in browser..."
Main.Text = "Status: loading in browser..." Main.Text = "Status: loading in browser..."
Exit Sub Exit Sub
End If End If
Try
Dim DeviceRegion As String = Nothing
' Main.CookieList = Collector.Task.Result()
For i As Integer = 0 To Main.CookieList.Count - 1 For i As Integer = 0 To Main.CookieList.Count - 1
If CBool(InStr(Main.CookieList.Item(i).Domain, ".crunchyroll.com")) And CBool(InStr(Main.CookieList.Item(i).Name, "_evidon_suppress")) = False Then If CBool(InStr(Main.CookieList.Item(i).Domain, ".crunchyroll.com")) And CBool(InStr(Main.CookieList.Item(i).Name, "_evidon_suppress")) = False Then
Main.CR_Cookies = Main.CR_Cookies + Main.CookieList.Item(i).Name + "=" + Main.CookieList.Item(i).Value + ";" Main.CR_Cookies = Main.CR_Cookies + Main.CookieList.Item(i).Name + "=" + Main.CookieList.Item(i).Value + ";"
End If End If
Next Next
'MsgBox(Main.CR_Cookies) End If
'Browser.WebView2.Source = New Uri(Url) 'MsgBox(Main.CR_Cookies)
'Exit Sub
If CBool(InStr(Url, "/series")) Then Dim DeviceRegion As String = Nothing
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)
Main.locale = Main.Convert_locale(locale2(0)) Main.locale = Main.Convert_locale(locale2(0))
@ -91,18 +133,6 @@ Public Class Anime_Add
End If End If
End If End If
'MsgBox("locale: " + Main.locale)
Catch ex As Exception
Browser.WebView2.CoreWebView2.Navigate(Url)
StatusLabel.Text = "Status: loading in browser..."
Exit Sub
End Try
'MsgBox(Cookies)
Dim Loc_CR_Cookies = " -H " + Chr(34) + Main.CR_Cookies + Chr(34) Dim Loc_CR_Cookies = " -H " + Chr(34) + Main.CR_Cookies + Chr(34)
@ -123,6 +153,7 @@ Public Class Anime_Add
End If End If
MsgBox(v1Token)
If CBool(InStr(v1Token, "curl:")) = True And CBool(InStr(v1Token, "400")) = True Then If CBool(InStr(v1Token, "curl:")) = True And CBool(InStr(v1Token, "400")) = True Then
Me.StatusLabel.Text = "Status: Failed - bad request, check CR login" Me.StatusLabel.Text = "Status: Failed - bad request, check CR login"
@ -142,13 +173,15 @@ Public Class Anime_Add
v1Token = Main.CurlPost("https://www.crunchyroll.com/auth/v1/token", Loc_CR_Cookies, Auth, Post) v1Token = Main.CurlPost("https://www.crunchyroll.com/auth/v1/token", Loc_CR_Cookies, Auth, Post)
End If End If
If CBool(InStr(v1Token, "curl:")) = True Then If CBool(InStr(v1Token, "curl:")) = True Then
Browser.WebView2.CoreWebView2.Navigate(Url) Browser.WebView2.CoreWebView2.Navigate(Url)
StatusLabel.Text = "Status: loading in browser..." StatusLabel.Text = "Status: loading in browser..."
Exit Sub Exit Sub
End If End If
'MsgBox(v1Token) '
Dim Token() As String = v1Token.Split(New String() {Chr(34) + "access_token" + Chr(34) + ":" + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries) 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) Dim Token2() As String = Token(1).Split(New String() {Chr(34) + "," + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries)
@ -414,12 +447,6 @@ Public Class Anime_Add
Private Sub Btn_dl_Click(sender As Object, e As EventArgs) Handles btn_dl.Click Private Sub Btn_dl_Click(sender As Object, e As EventArgs) Handles btn_dl.Click
If Application.OpenForms().OfType(Of Browser).Any = True Then
Else
Main.UserBowser = False
Browser.Show()
End If
Main.LoginOnly = "Download Mode!" Main.LoginOnly = "Download Mode!"
'MsgBox(Main.WebbrowserURL) 'MsgBox(Main.WebbrowserURL)
If SubTitlesOnlyCB.Text = "[Default]" Then If SubTitlesOnlyCB.Text = "[Default]" Then
@ -484,7 +511,7 @@ Public Class Anime_Add
If Main.Grapp_RDY = True Then If Main.Grapp_RDY = True Then
Main.b = False Main.b = False
Debug.WriteLine("Start loading: " + Date.Now.ToString) Debug.WriteLine("what's going on?: " + Date.Now.ToString)
StatusLabel.Text = "Status: loading ...." StatusLabel.Text = "Status: loading ...."
LoadBrowser(textBox1.Text) LoadBrowser(textBox1.Text)
Else Else

View File

@ -2152,11 +2152,12 @@ Public Class Main
Private Sub Btn_add_Click(sender As Object, e As EventArgs) Handles Btn_add.Click Private Sub Btn_add_Click(sender As Object, e As EventArgs) Handles Btn_add.Click
If File.Exists("cookies.txt") = False Then
If Application.OpenForms().OfType(Of Browser).Any = True Then If Application.OpenForms().OfType(Of Browser).Any = True Then
Else Else
UserBowser = False UserBowser = False
Browser.Show() Browser.Show()
End If
End If End If
If Anime_Add.WindowState = System.Windows.Forms.FormWindowState.Minimized Then If Anime_Add.WindowState = System.Windows.Forms.FormWindowState.Minimized Then

View File

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