added fallback

added fallback CR Seasons
minor improvments
This commit is contained in:
hama3254 2023-02-07 14:31:23 +01:00
parent c86c7bf2f0
commit c956218d4d
7 changed files with 165 additions and 174 deletions

Binary file not shown.

View File

@ -46,9 +46,6 @@ Public Class Anime_Add
Btn_Close.Image = Main.CloseImg
Btn_min.Image = Main.MinImg
Try
Me.Icon = My.Resources.icon
Catch ex As Exception

View File

@ -78,7 +78,7 @@ Partial Class Browser
'
'Timer1
'
Me.Timer1.Interval = 1000
Me.Timer1.Interval = 60000
'
'Timer2
'

View File

@ -10,6 +10,7 @@ Imports System.Text
Imports System.Security.Policy
Imports Microsoft.Web.WebView2.Core
Imports MetroFramework.Drawing
Imports Newtonsoft.Json.Linq
Public Class Browser
@ -98,7 +99,7 @@ Public Class Browser
If Main.UserBowser = False Then
Me.Location = New Point(-10000, 10000)
Timer1.Enabled = True
End If
WebView2.Source = New Uri(Main.Startseite)
End Sub
@ -154,8 +155,26 @@ Public Class Browser
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
If CBool(InStr(e.Request.Uri, "crunchyroll.com/")) And CBool(InStr(e.Request.Uri, "streams?")) Then
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)
Main.CR_v1Token = ""
Exit Sub
ElseIf 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
@ -176,51 +195,15 @@ Public Class Browser
ContentString = reader.ReadToEnd
Main.CR_ObjectsJson = New UrlJson(e.Request.Uri, ContentString)
'If CBool(InStr(WebView2.CoreWebView2.Source, "/objects/")) Then
' ' MsgBox("True2")
' Debug.WriteLine("Main.JSON: " + ContentString)
' Dim StreamsUrlBuilder() As String = ContentString.Split(New String() {"videos/"}, System.StringSplitOptions.RemoveEmptyEntries)
' Dim StreamsUrlBuilder2() As String = StreamsUrlBuilder(1).Split(New String() {"/streams"}, System.StringSplitOptions.RemoveEmptyEntries)
' ' MsgBox("True3")
' Dim StreamsUrlBuilder3() As String = e.Request.Uri.Split(New String() {"objects/"}, System.StringSplitOptions.RemoveEmptyEntries)
' Dim StreamsUrlBuilder4() As String = StreamsUrlBuilder3(1).Split(New String() {"?"}, System.StringSplitOptions.RemoveEmptyEntries)
' Dim StreamsUrl As String = StreamsUrlBuilder3(0) + "videos/" + StreamsUrlBuilder2(0) + "/streams?" + StreamsUrlBuilder4(1)
' MsgBox(StreamsUrl)
' WebView2.Source = New Uri(StreamsUrl)
'End If
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)
' Main.LoadedUrls.Add(e.Request)
' 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)
' If Main.GetBetaSeasonsRetry = True Then
' Main.GetBetaSeasonsRetry = False
' Main.GetBetaSeasons(Main.WebbrowserURL, e.Request.Uri, "", ContentString)
' End If
' 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)
'ElseIf CBool(InStr(e.Request.Uri, "crunchyroll.com/")) And CBool(InStr(e.Request.Uri, "episodes?season_id=")) And Main.GetBetaSeasonSingle = True Then
' Debug.WriteLine("Crunchyroll-Single-Season: " + 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.GetBetaSeasonSingle = False
' Anime_Add.FillCREpisodes(ContentString)
' Exit Sub
Exit Sub
End If
ElseIf CBool(InStr(Main.LoadingUrl, "funimation.com")) Then
If CBool(InStr(e.Request.Uri, "?deviceType=web")) Then
@ -318,7 +301,7 @@ Public Class Browser
Main.LoadedUrls.Add(e.Request)
'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
ElseIf CBool(InStr(e.Request.Uri, "crunchyroll.com/")) And CBool(InStr(e.Request.Uri, "seasons?preferred_audio_language=")) Then
Debug.WriteLine("Crunchyroll-Season: " + e.Request.Uri)
Main.LoadedUrls.Add(e.Request)
'Main.CR_SeasonJson = New UrlJson(e.Request.Uri, e.Request.Content.ToString)
@ -368,29 +351,19 @@ Public Class Browser
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
'If Main.UserBowser = False Then
' WebView2.Reload()
'Else
' Timer1.Enabled = False
'End If
End Sub
Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
Me.Close()
End Sub
'Private Sub WebBrowser1_ConsoleMessage(sender As Object, e As ConsoleMessageEventArgs) Handles WebBrowser1.ConsoleMessage
' Debug.WriteLine(e.Message)
'End Sub
End Class

View File

@ -32,6 +32,8 @@ Public Class Main
Public CR_ObjectsJson As UrlJson = New UrlJson("", "")
Public CR_VideoJson As UrlJson = New UrlJson("", "")
Public CR_AuthToken As String = ""
Public CR_v1Token As String = ""
'Public GetBetaSeasonsRetry As Boolean = False
'Public GetBetaSeasonSingle As Boolean = False
@ -1421,7 +1423,7 @@ Public Class Main
VideoJson = CR_VideoJson.Content
CR_VideoJson = New UrlJson("", "")
ElseIf CBool(InStr(VideoJson, "curl:")) = True Then
VideoJson = Nothing
'VideoJson = Nothing
MsgBox("Error - Getting VideoJson data" + vbNewLine + VideoJson)
Exit Sub
End If
@ -3505,20 +3507,14 @@ Public Class Main
End If
Me.Text = "Status: Crunchyroll episode found."
Debug.WriteLine("Crunchyroll episode found")
GetBetaVideoProxy(Request.Uri, CR_AuthToken, WebbrowserURL)
b = True
'Browser.WebBrowser1.LoadUrl(requesturl)
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=")) And CBool(InStr(WebbrowserURL, "series")) Then
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
@ -3528,7 +3524,13 @@ Public Class Main
Me.Text = "Status: Crunchyroll season found."
Debug.WriteLine("Crunchyroll season found")
GetBetaSeasons(WebbrowserURL, Request.Uri, "")
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()
@ -3959,6 +3961,12 @@ Public Class Main
End If
ElseIf strArray(0).Trim().ToUpper.Equals("GET") Then
strRequest = strArray(1).Trim
If CBool(InStr(strRequest, "403")) Then
strRequest = strRequest & defaultPage '"HTMLString" 'strRequest & defaultPage
SendHTMLResponse(stream, "index.html", Nothing, "HTTP/1.0 403 Forbidden")
End If
If strRequest.StartsWith("/") Then
strRequest = strRequest.Substring(1)
End If
@ -3984,7 +3992,7 @@ Public Class Main
End Sub
' Send HTTP Response
Private Sub SendHTMLResponse(ByVal stream As NetworkStream, Optional ByVal httpRequest As String = Nothing, Optional ByVal Response As ServerResponse = Nothing)
Private Sub SendHTMLResponse(ByVal stream As NetworkStream, Optional ByVal httpRequest As String = Nothing, Optional ByVal Response As ServerResponse = Nothing, Optional ByVal httpCode As String = "HTTP/1.0 200 OK")
Try
Dim respByte() As Byte
If httpRequest = Nothing Then
@ -3992,7 +4000,7 @@ Public Class Main
respByte = System.Text.Encoding.UTF8.GetBytes(Response.Content) 'File.ReadAllBytes("") '
' Set HTML Header
Dim htmlHeader As String =
"HTTP/1.0 200 OK" & ControlChars.CrLf &
httpCode & ControlChars.CrLf &
"Server: CRD 1.0" & ControlChars.CrLf &
"Content-Length: " & respByte.Length & ControlChars.CrLf &
"Content-Type: " & GetContentType(Response.Type) &
@ -4007,7 +4015,7 @@ Public Class Main
respByte = System.Text.Encoding.UTF8.GetBytes(HTML) 'File.ReadAllBytes("") '
' Set HTML Header
Dim htmlHeader As String =
"HTTP/1.0 200 OK" & ControlChars.CrLf &
httpCode & ControlChars.CrLf &
"Server: CRD 1.0" & ControlChars.CrLf &
"Content-Length: " & respByte.Length & ControlChars.CrLf &
"Content-Type: " & GetContentType(httpRequest) &
@ -4032,7 +4040,7 @@ Public Class Main
respByte = File.ReadAllBytes(httpRequest)
' Set HTML Header
Dim htmlHeader As String =
"HTTP/1.0 200 OK" & ControlChars.CrLf &
httpCode & ControlChars.CrLf &
"Server: CRD 1.0" & ControlChars.CrLf &
"Content-Length: " & respByte.Length & ControlChars.CrLf &
"Content-Type: " & GetContentType(httpRequest) & ControlChars.CrLf &
@ -4359,6 +4367,7 @@ Public Class Main
LoadingUrl = Url
LoadedUrls.Clear()
Dim NoBrowser As Boolean = False
'CR_v1Token = "Get"
'Browser.WebView2.Source = New Uri(Url)
'Exit Sub
'MsgBox(Url)
@ -4426,9 +4435,14 @@ Public Class Main
End If
End If
Debug.WriteLine("###" + CR_Cookies + "###")
Dim Loc_CR_Cookies = " -H " + Chr(34) + CR_Cookies + Chr(34)
'CR_v1Token = "Get"
'Browser.WebView2.Source = New Uri(Url)
'Exit Sub
#End Region
Dim Auth As String = " -H " + Chr(34) + "Authorization: " + CrBetaBasic + Chr(34)
@ -4460,43 +4474,52 @@ Public Class Main
End If
'MsgBox(v1Token)
If CBool(InStr(v1Token, "curl:")) = True Then
'Browser.WebView2.CoreWebView2.Navigate(Url)
SetStatusLabel("Status: Critical error. #4425")
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
End If
'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 ObjectsUrl As String = Nothing
Dim Auth2 As String = " -H " + Chr(34) + "Authorization: " + CRBetaBearer + Chr(34)
ProcessLoading(Url, Auth2, Loc_CR_Cookies)
If CBool(InStr(Url, "crunchyroll.com")) = True And CBool(InStr(Url, "series/")) = True Then
Else
'to do
End If
End Sub
Dim SeriesUrlBuilder() As String = Url.Split(New String() {"series/"}, System.StringSplitOptions.RemoveEmptyEntries)
Public Sub ProcessLoading(ByVal url As String, Auth2 As String, ByVal Loc_CR_Cookies As String)
If CBool(InStr(url, "crunchyroll.com")) = True And CBool(InStr(url, "series/")) = True Then
Dim SeriesUrlBuilder() As String = url.Split(New String() {"series/"}, System.StringSplitOptions.RemoveEmptyEntries)
Dim SeriesUrlBuilder2() As String = SeriesUrlBuilder(1).Split(New String() {"/"}, System.StringSplitOptions.RemoveEmptyEntries)
Dim SeriesUrl As String = "https://www.crunchyroll.com/content/v2/cms/series/" + SeriesUrlBuilder2(0) + "/seasons?preferred_audio_language=" + DubSprache.CR_Value + "&locale=" + locale '+ "&Signature=" + signature2(0) + "&Policy=" + policy2(0) + "&Key-Pair-Id=" + key_pair_id2(0)
Debug.WriteLine(SeriesUrl)
'MsgBox(SeriesUrl)
GetBetaSeasons(Url, SeriesUrl, Auth2)
GetBetaSeasons(url, SeriesUrl, Auth2)
ElseIf CBool(InStr(Url, "crunchyroll.com")) = True And CBool(InStr(Url, "watch/")) = True And CBool(CrBetaBasic = Nothing) = False Then
ElseIf CBool(InStr(url, "crunchyroll.com")) = True And CBool(InStr(url, "watch/")) = True And CBool(CrBetaBasic = Nothing) = False Then
Dim ObjectsUrl As String = Nothing
'MsgBox(Url)
Dim ObjectsURLBuilder3() As String = Url.Split(New String() {"watch/"}, System.StringSplitOptions.RemoveEmptyEntries)
Dim ObjectsURLBuilder3() As String = url.Split(New String() {"watch/"}, System.StringSplitOptions.RemoveEmptyEntries)
Dim ObjectsURLBuilder4() As String = ObjectsURLBuilder3(1).Split(New String() {"/"}, System.StringSplitOptions.RemoveEmptyEntries)
@ -4513,14 +4536,6 @@ Public Class Main
Try
ObjectJson = CurlAuth(ObjectsUrl, Loc_CR_Cookies, Auth2)
'"curl:" 'Main.Curl(ObjectsUrl)
'MsgBox(ObjectJson)
'If CBool(InStr(ObjectJson, "curl:")) = True Then
' ObjectJson = Main.Curl(ObjectsUrl)
'End If
If CBool(InStr(ObjectJson, "curl:")) = True Then
Browser.WebView2.CoreWebView2.Navigate(ObjectsUrl)
LoadingUrl = ObjectsUrl
@ -4536,7 +4551,7 @@ Public Class Main
End If
Catch ex As Exception
Browser.WebView2.CoreWebView2.Navigate(Url)
Browser.WebView2.CoreWebView2.Navigate(url)
Exit Sub
End Try
@ -4553,21 +4568,21 @@ Public Class Main
' Debug.WriteLine(StreamsUrl)
Catch ex As Exception
Browser.WebView2.CoreWebView2.Navigate(Url)
Browser.WebView2.CoreWebView2.Navigate(url)
Exit Sub
End Try
GetBetaVideoProxy(StreamsUrl, Auth2, Url)
GetBetaVideoProxy(StreamsUrl, Auth2, url)
Else
Browser.WebView2.CoreWebView2.Navigate(Url)
End If
Else
'to do
Browser.WebView2.CoreWebView2.Navigate(url)
End If
End Sub
Public Function GetCookiesFromFile(ByVal Host As String) As String
Dim Cookies As String = "Cookie: "
@ -4614,6 +4629,7 @@ Public Class Main
Sub SetStatusLabel(ByVal txt As String)
If Application.OpenForms().OfType(Of Anime_Add).Any = True Then
Anime_Add.StatusLabel.Text = txt
End If
End Sub

View File

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

View File

@ -677,9 +677,14 @@ Public Class Einstellungen
ffpmeg_cmd = " " + FFMPEG_CommandP1.Text + " " + FFMPEG_CommandP2.Text + " " + FFMPEG_CommandP3.Text + " " + FFMPEG_CommandP4.Text
End If
If Main.ffmpeg_command = My.Settings.ffmpeg_command_override Then
'override should not get overwritten
Else
Main.ffmpeg_command = ffpmeg_cmd
My.Settings.ffmpeg_command = Main.ffmpeg_command
End If
If CBool(InStr(FFMPEG_CommandP1.Text, "nvenc")) = True And CBool(Main.VideoFormat = ".aac") = False Then