fixes and improvements

fix funimation base function #753
added `download_hls` as last option for #748
redone retry #747 (untested)
block add button (wait for browser to load)
This commit is contained in:
hama3254 2023-06-03 15:57:13 +02:00
parent ffcce61e1d
commit ef75816810
7 changed files with 217 additions and 163 deletions

Binary file not shown.

View File

@ -328,6 +328,7 @@ Partial Class Anime_Add
' '
Me.btn_dl.BackgroundImage = Global.Crunchyroll_Downloader.My.Resources.Resources.main_button_download_default Me.btn_dl.BackgroundImage = Global.Crunchyroll_Downloader.My.Resources.Resources.main_button_download_default
Me.btn_dl.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch Me.btn_dl.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch
Me.btn_dl.Cursor = System.Windows.Forms.Cursors.No
Me.btn_dl.FlatAppearance.BorderSize = 0 Me.btn_dl.FlatAppearance.BorderSize = 0
Me.btn_dl.FlatStyle = System.Windows.Forms.FlatStyle.Flat Me.btn_dl.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.btn_dl.Font = New System.Drawing.Font("Microsoft Sans Serif", 27.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.btn_dl.Font = New System.Drawing.Font("Microsoft Sans Serif", 27.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))

View File

@ -11,6 +11,8 @@ Imports System.Text
Imports System.Runtime.InteropServices.ComTypes Imports System.Runtime.InteropServices.ComTypes
Imports System.Windows.Forms.VisualStyles.VisualStyleElement.Status Imports System.Windows.Forms.VisualStyles.VisualStyleElement.Status
Imports Newtonsoft.Json.Linq Imports Newtonsoft.Json.Linq
Imports System.Timers
Imports System.Security.Policy
Public Class Anime_Add Public Class Anime_Add
Public Mass_DL_Cancel As Boolean = False Public Mass_DL_Cancel As Boolean = False
@ -48,6 +50,16 @@ Public Class Anime_Add
Btn_Close.Image = Main.CloseImg Btn_Close.Image = Main.CloseImg
Btn_min.Image = Main.MinImg Btn_min.Image = Main.MinImg
btn_dl.Cursor = Cursors.No
btn_dl.BackgroundImage = My.Resources.main_button_download_deactivate
If File.Exists("cookies.txt") = True Or Main.BowserWasOpen = True Then
btn_dl.BackgroundImage = My.Resources.main_button_download_default
btn_dl.Cursor = Cursors.Default
End If
Try Try
Me.Icon = My.Resources.icon Me.Icon = My.Resources.icon
Catch ex As Exception Catch ex As Exception
@ -147,6 +159,10 @@ 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 btn_dl.Cursor = Cursors.No Then
Exit Sub
End If
Main.LoginOnly = "Download Mode!" Main.LoginOnly = "Download Mode!"
'MsgBox(Main.WebbrowserURL) 'MsgBox(Main.WebbrowserURL)
@ -154,7 +170,7 @@ Public Class Anime_Add
If groupBox1.Visible = True Then If groupBox1.Visible = True Then
' Main.LoadedUrls.Clear() ' Main.LoadedUrls.Clear()
Try Try
If CBool(InStr(textBox1.Text, "crunchyroll.com")) Or CBool(InStr(textBox1.Text, "funimation.com")) Then If CBool(InStr(textBox1.Text, "crunchyroll.com")) Or CBool(InStr(textBox1.Text, "funimation.com")) Then
@ -202,7 +218,15 @@ Public Class Anime_Add
Debug.WriteLine("error- getting v1Json data for the bypass") Debug.WriteLine("error- getting v1Json data for the bypass")
Debug.WriteLine(ex.ToString) Debug.WriteLine(ex.ToString)
End Try End Try
ElseIf CBool(InStr(textBox1.Text, "funimation.com/shows/")) Then
Main.LoadingUrl = textBox1.Text
Main.LoadedUrls.Clear()
Main.b = False
Debug.WriteLine("loading funimation show url: " + Date.Now.ToString)
StatusLabel.Text = "Status: loading funimation...."
'Main.LoadBrowser()
Browser.WebView2.CoreWebView2.Navigate(textBox1.Text)
Exit Sub
End If End If
End If End If
@ -228,8 +252,8 @@ Public Class Anime_Add
End If End If
Catch ex As Exception Catch ex As Exception
MsgBox(ex.ToString) MsgBox(ex.ToString)
Main.b = True Main.b = True
MsgBox(Main.URL_Invaild, MsgBoxStyle.OkOnly) MsgBox(Main.URL_Invaild, MsgBoxStyle.OkOnly)
End Try End Try
ElseIf groupBox2.Visible = True Then ElseIf groupBox2.Visible = True Then
@ -324,6 +348,11 @@ Public Class Anime_Add
Private Sub Btn_dl_MouseEnter(sender As Object, e As EventArgs) Handles btn_dl.MouseEnter Private Sub Btn_dl_MouseEnter(sender As Object, e As EventArgs) Handles btn_dl.MouseEnter
If btn_dl.Cursor = Cursors.No Then
Exit Sub
End If
If Mass_DL_Cancel = True Then If Mass_DL_Cancel = True Then
btn_dl.Text = "Cancel" btn_dl.Text = "Cancel"
btn_dl.BackgroundImage = My.Resources.main_button_download_hovert btn_dl.BackgroundImage = My.Resources.main_button_download_hovert
@ -339,6 +368,11 @@ Public Class Anime_Add
End Sub End Sub
Private Sub Btn_dl_MouseLeave(sender As Object, e As EventArgs) Handles btn_dl.MouseLeave Private Sub Btn_dl_MouseLeave(sender As Object, e As EventArgs) Handles btn_dl.MouseLeave
If btn_dl.Cursor = Cursors.No Then
Exit Sub
End If
If Mass_DL_Cancel = True Then If Mass_DL_Cancel = True Then
btn_dl.Text = "Cancel" btn_dl.Text = "Cancel"
btn_dl.BackgroundImage = My.Resources.main_button_download_hovert btn_dl.BackgroundImage = My.Resources.main_button_download_hovert

View File

@ -21,24 +21,28 @@ Public Class Browser
WebView2.CoreWebView2.AddWebResourceRequestedFilter("https://www.crunchyroll.com/*", CoreWebView2WebResourceContext.All) WebView2.CoreWebView2.AddWebResourceRequestedFilter("https://www.crunchyroll.com/*", CoreWebView2WebResourceContext.All)
WebView2.CoreWebView2.AddWebResourceRequestedFilter("https://www.funimation.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) 'WebView2.CoreWebView2.AddWebResourceRequestedFilter("*", 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
'WebView2.CoreWebView2.Settings.UserAgent = My.Settings.User_Agend.Replace(Chr(34), "").Replace("User-Agent: ", "") 'WebView2.CoreWebView2.Settings.UserAgent = My.Settings.User_Agend.Replace(Chr(34), "").Replace("User-Agent: ", "")
'
'WebView2.CoreWebView2.Settings.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Trident/7.0; rv:11.0) like Gecko"
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)
'MsgBox(My.Settings.User_Agend) 'MsgBox(My.Settings.User_Agend)
If WebView2.CoreWebView2.Source = "about:blank" Or WebView2.CoreWebView2.Source = Nothing Then If WebView2.CoreWebView2.Source = "about:blank" Or WebView2.CoreWebView2.Source = Nothing Then
'TextBox1.Text = Main.Startseite 'TextBox1.Text = Main.Startseite
WebView2.CoreWebView2.Navigate(Main.Startseite) WebView2.CoreWebView2.Navigate(Main.Startseite)
End If End If
End Sub End Sub
Private Sub WebView2_SourceChanged(sender As Object, e As CoreWebView2SourceChangedEventArgs) Handles WebView2.SourceChanged Private Sub WebView2_SourceChanged(sender As Object, e As CoreWebView2SourceChangedEventArgs) Handles WebView2.SourceChanged
Try Try
TextBox1.Text = WebView2.CoreWebView2.Source TextBox1.Text = WebView2.CoreWebView2.Source
@ -54,6 +58,8 @@ Public Class Browser
' Dim HTML As String = WebView2.CoreWebView2. ' Dim HTML As String = WebView2.CoreWebView2.
'TextBox1.Text = WebView2.CoreWebView2.Source 'TextBox1.Text = WebView2.CoreWebView2.Source
' Exit Sub ' Exit Sub
If e.HttpStatusCode = 200 Then If e.HttpStatusCode = 200 Then
Dim DocumentTitle As String = WebView2.CoreWebView2.DocumentTitle Dim DocumentTitle As String = WebView2.CoreWebView2.DocumentTitle
@ -66,6 +72,13 @@ Public Class Browser
GetCookies(Main.WebbrowserURL) GetCookies(Main.WebbrowserURL)
Main.BowserWasOpen = True
If Application.OpenForms().OfType(Of Anime_Add).Any = True Then
Anime_Add.btn_dl.Cursor = Cursors.Default
Anime_Add.btn_dl.BackgroundImage = My.Resources.main_button_download_default
End If
End If End If
End Sub End Sub
@ -78,6 +91,7 @@ Public Class Browser
Private Sub Browser_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) Main.waveOutSetVolume(0, 0)
If Me.Width > My.Computer.Screen.Bounds.Width Then If Me.Width > My.Computer.Screen.Bounds.Width Then
Me.Width = My.Computer.Screen.Bounds.Width Me.Width = My.Computer.Screen.Bounds.Width
@ -108,6 +122,8 @@ Public Class Browser
End Sub End Sub
Private Sub Browser_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing Private Sub Browser_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
Main.BowserWasOpen = False
'Main.UserBowser = False 'Main.UserBowser = False
'Me.Location = New Point(-10000, -10000) 'Me.Location = New Point(-10000, -10000)
'Main.LoadingUrl = "" 'Main.LoadingUrl = ""
@ -121,10 +137,12 @@ Public Class Browser
End Sub End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'MsgBox(Main.CR_etp_rt) 'MsgBox(Main.CR_etp_rt)
'MsgBox(Main.CR_ajs_user_id) 'MsgBox(Main.CR_ajs_user_id)
'MsgBox(Main.CheckCRLogin.ToString) 'MsgBox(Main.CheckCRLogin.ToString)
Try Try
My.Computer.Clipboard.SetText(WebView2.CoreWebView2.Source) My.Computer.Clipboard.SetText(WebView2.CoreWebView2.Source)
MsgBox("copied: " + Chr(34) + WebView2.CoreWebView2.Source + Chr(34)) MsgBox("copied: " + Chr(34) + WebView2.CoreWebView2.Source + Chr(34))
@ -152,8 +170,6 @@ Public Class Browser
Private Async Sub ObserveResponse(ByVal sender As Object, ByVal e As CoreWebView2WebResourceResponseReceivedEventArgs) Private Async Sub ObserveResponse(ByVal sender As Object, ByVal e As CoreWebView2WebResourceResponseReceivedEventArgs)
If CBool(InStr(Main.LoadingUrl, "crunchyroll.com")) Then If CBool(InStr(Main.LoadingUrl, "crunchyroll.com")) Then
@ -165,27 +181,35 @@ Public Class Browser
Dim reader As New StreamReader(Content) Dim reader As New StreamReader(Content)
ContentString = reader.ReadToEnd ContentString = reader.ReadToEnd
Dim Loc_CR_Cookies = " -H " + Chr(34) + Main.CR_Cookies + Chr(34) 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 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 Token2() As String = Token(1).Split(New String() {Chr(34) + "," + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries)
Dim Auth As String = "Bearer " + Token2(0) Dim Auth As String = "Bearer " + Token2(0)
Dim Auth2 As String = " -H " + Chr(34) + "Authorization: " + Auth + Chr(34) Dim Auth2 As String = " -H " + Chr(34) + "Authorization: " + Auth + Chr(34)
Main.ProcessLoading(Main.LoadingUrl, Auth2, Loc_CR_Cookies) Main.ProcessLoading(Main.LoadingUrl, Auth2, Loc_CR_Cookies, 0)
Main.CR_v1Token = "" Main.CR_v1Token = ""
Exit Sub 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 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) Debug.WriteLine("Crunchyroll-Season: " + e.Request.Uri)
Main.LoadedUrls.Add(e.Request) Main.LoadedUrls.Add(e.Request)
Exit Sub 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
ElseIf CBool(InStr(Main.LoadingUrl, "funimation.com")) Then ElseIf CBool(InStr(Main.LoadingUrl, "funimation.com")) Then
If CBool(InStr(e.Request.Uri, "?deviceType=web")) Then If CBool(InStr(e.Request.Uri, "?deviceType=web")) Then
'Debug.WriteLine(e.Request.Uri) 'Debug.WriteLine(e.Request.Uri)
@ -251,87 +275,40 @@ Public Class Browser
Next Next
End If End If
If CBool(InStr(e.Request.Uri, "crunchyroll.com/")) And CBool(InStr(e.Request.Uri, "streams?")) Then 'If CBool(InStr(e.Request.Uri, "crunchyroll.com/")) And CBool(InStr(e.Request.Uri, "streams?")) Then
Dim Headers As New List(Of KeyValuePair(Of String, String)) ' Dim Headers As New List(Of KeyValuePair(Of String, String))
Headers.AddRange(e.Request.Headers.ToList) ' Headers.AddRange(e.Request.Headers.ToList)
For i As Integer = 0 To Headers.Count ' For i As Integer = 0 To Headers.Count
If CBool(InStr(Headers.Item(i).Value, "Bearer")) Then ' If CBool(InStr(Headers.Item(i).Value, "Bearer")) Then
Main.CR_AuthToken = Headers.Item(i).Value ' Main.CR_AuthToken = Headers.Item(i).Value
Debug.WriteLine("Auth-Bearer: " + Main.CR_AuthToken) ' Debug.WriteLine("Auth-Bearer: " + Main.CR_AuthToken)
End If ' End If
Next ' Next
'End If
'
'
If CBool(InStr(e.Request.Uri, "9016.2bd48f1e07adf6596b2d.js")) = True Then '
Debug.WriteLine(e.Request.Uri)
'MsgBox("Found!")
e.Response = WebView2.CoreWebView2.Environment.CreateWebResourceResponse(StringToStream(File.ReadAllText(Application.StartupPath + "\WebInterface\9016.2bd48f1e07adf6596b2d.js"), Encoding.UTF8), 200, "Not found", "content-type: application/javascript")
End If 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)
'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)
'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
Debug.WriteLine(e.Request.Uri)
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?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)
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))
Exit Sub
Else
Main.LoadedUrls.Add(e.Request)
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))
Exit Sub
Else
Main.LoadedUrls.Add(e.Request)
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))
Exit Sub
Else
Main.LoadedUrls.Add(e.Request)
Exit Sub
End If
End If
End If
End Sub End Sub
Public Function StringToStream(input As String, enc As Encoding) As Stream
Dim memoryStream = New MemoryStream()
Dim streamWriter = New StreamWriter(memoryStream, enc)
streamWriter.Write(input)
streamWriter.Flush()
memoryStream.Position = 0
Return memoryStream
End Function
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
'If Main.UserBowser = False Then 'If Main.UserBowser = False Then
' WebView2.Reload() ' WebView2.Reload()

View File

@ -7,6 +7,8 @@ Module GetData
Public Function Curl(ByVal Url As String) As String Public Function Curl(ByVal Url As String) As String
'MsgBox(Url)
Dim exepath As String = Path.Combine(Application.StartupPath, "lib", "curl.exe") Dim exepath As String = Path.Combine(Application.StartupPath, "lib", "curl.exe")
Dim startinfo As New System.Diagnostics.ProcessStartInfo Dim startinfo As New System.Diagnostics.ProcessStartInfo
Dim sr As StreamReader Dim sr As StreamReader
@ -50,21 +52,16 @@ Module GetData
Loop Until Proc.HasExited Or Microsoft.VisualBasic.DateAndTime.Timer < finish Loop Until Proc.HasExited Or Microsoft.VisualBasic.DateAndTime.Timer < finish
If CurlOutput = Nothing And CurlError = Nothing Then If CBool(InStr(CurlError, "curl")) Then
Debug.WriteLine("curl-E: " + "curl: ") Debug.WriteLine(CurlError)
Return CurlError Throw New System.Exception("Error - Getting" + vbNewLine + CurlError)
ElseIf CurlOutput = Nothing And CurlError IsNot Nothing Then Return Nothing
Debug.WriteLine("curl-E: " + CurlError) ElseIf CBool(InStr(CurlOutput, "curl")) Then
Return CurlError Debug.WriteLine(CurlOutput)
ElseIf CurlOutput IsNot Nothing And CurlError = Nothing Then Throw New System.Exception("Error - Getting" + vbNewLine + CurlError)
Debug.WriteLine("curl-O: " + CurlOutput) Return Nothing
Return CurlOutput
ElseIf CurlOutput IsNot Nothing And CurlError IsNot Nothing Then
Debug.WriteLine("curl-O: " + CurlOutput)
Return CurlOutput
Else Else
Debug.WriteLine("curl-E: " + "curl: ") Return CurlOutput
Return CurlError
End If End If
@ -118,28 +115,26 @@ Module GetData
Loop Until Proc.HasExited Or Microsoft.VisualBasic.DateAndTime.Timer < finish Loop Until Proc.HasExited Or Microsoft.VisualBasic.DateAndTime.Timer < finish
If CurlOutput = Nothing And CurlError = Nothing Then If CBool(InStr(CurlError, "curl")) Then
Debug.WriteLine("CurlPost-E: " + "curl: ") Debug.WriteLine(CurlError)
Return CurlError Throw New System.Exception("Error - Getting" + vbNewLine + CurlError)
ElseIf CurlOutput = Nothing And CurlError IsNot Nothing Then Return Nothing
Debug.WriteLine("CurlPost-E: " + CurlError) ElseIf CBool(InStr(CurlOutput, "curl")) Then
Return CurlError Debug.WriteLine(CurlOutput)
ElseIf CurlOutput IsNot Nothing And CurlError = Nothing Then Throw New System.Exception("Error - Getting" + vbNewLine + CurlError)
Debug.WriteLine("CurlPost-O: " + CurlOutput) Return Nothing
Return CurlOutput
ElseIf CurlOutput IsNot Nothing And CurlError IsNot Nothing Then
Debug.WriteLine("CurlPost-O: " + CurlOutput)
Return CurlOutput
Else Else
Debug.WriteLine("CurlPost-E: " + "curl: ") Return CurlOutput
Return CurlError
End If End If
End Function End Function
Public Function CurlAuthNew(ByVal Url As String, ByVal Cookies As String, ByVal Auth As String) As String Public Function CurlAuthNew(ByVal Url As String, ByVal Cookies As String, ByVal Auth As String, Optional ByVal Test As Boolean = False) As String
If Test = True Then
Throw New System.Exception("Error - Getting" + vbNewLine + "Test")
End If
Dim exepath As String = Path.Combine(Application.StartupPath, "lib", "curl.exe") Dim exepath As String = Path.Combine(Application.StartupPath, "lib", "curl.exe")
@ -190,10 +185,12 @@ Module GetData
If CurlOutput = Nothing Or CBool(InStr(CurlOutput, "curl")) Then If CBool(InStr(CurlError, "curl")) Then
Throw New System.Exception("Error - Getting ObjectJson data" + vbNewLine + CurlOutput) Debug.WriteLine(CurlError)
Throw New System.Exception("Error - Getting" + vbNewLine + CurlError)
Return Nothing Return Nothing
ElseIf CBool(InStr(CurlError, "curl")) Then ElseIf CBool(InStr(CurlOutput, "curl")) Then
Debug.WriteLine(CurlOutput)
Throw New System.Exception("Error - Getting" + vbNewLine + CurlError) Throw New System.Exception("Error - Getting" + vbNewLine + CurlError)
Return Nothing Return Nothing
Else Else

View File

@ -158,6 +158,7 @@ Public Class Main
Public WebbrowserTitle As String = Nothing Public WebbrowserTitle As String = Nothing
Public WebbrowserCookie As String = Nothing Public WebbrowserCookie As String = Nothing
Public UserBowser As Boolean = False Public UserBowser As Boolean = False
Public BowserWasOpen As Boolean = False
Public HybridMode As Boolean = False Public HybridMode As Boolean = False
Public HardSubFunimation As String = "Disabled" Public HardSubFunimation As String = "Disabled"
Public Funimation_Bitrate As Integer = 0 Public Funimation_Bitrate As Integer = 0
@ -438,6 +439,7 @@ Public Class Main
Trace.Listeners.Add(tbtl) Trace.Listeners.Add(tbtl)
b = True b = True
Thread.CurrentThread.Name = "Main" Thread.CurrentThread.Name = "Main"
Debug.WriteLine("v" + Application.ProductVersion)
Debug.WriteLine("Thread Name: " + Thread.CurrentThread.Name) Debug.WriteLine("Thread Name: " + Thread.CurrentThread.Name)
@ -980,12 +982,12 @@ Public Class Main
End Sub End Sub
Public Sub GetCRVideoProxy(ByVal requesturl As String, ByVal AuthToken As String, ByVal WebsiteURL As String) Public Sub GetCRVideoProxy(ByVal requesturl As String, ByVal AuthToken As String, ByVal WebsiteURL As String, ByVal RT_count As Integer)
Dim Evaluator = New Thread(Sub() Me.GetCRVideo(requesturl, AuthToken, WebsiteURL)) Dim Evaluator = New Thread(Sub() Me.GetCRVideo(requesturl, AuthToken, WebsiteURL, RT_count))
Evaluator.Start() Evaluator.Start()
End Sub End Sub
Public Sub GetCRVideo(ByVal Streams As String, ByVal AuthToken As String, ByVal WebsiteURL As String) Public Sub GetCRVideo(ByVal Streams As String, ByVal AuthToken As String, ByVal WebsiteURL As String, ByVal RT_count As Integer)
If b = False Then If b = False Then
b = True b = True
End If End If
@ -1204,6 +1206,8 @@ Public Class Main
Dim VideoJObject As JObject = JObject.Parse(VideoJson) Dim VideoJObject As JObject = JObject.Parse(VideoJson)
Dim VideoData As List(Of JToken) = VideoJObject.Children().ToList Dim VideoData As List(Of JToken) = VideoJObject.Children().ToList
Dim download_hls As CR_Beta_Stream = Nothing
For Each item As JProperty In VideoData For Each item As JProperty In VideoData
item.CreateReader() item.CreateReader()
Select Case item.Name Select Case item.Name
@ -1214,7 +1218,7 @@ Public Class Main
For Each VideoSubItem As JProperty In VideoSubData For Each VideoSubItem As JProperty In VideoSubData
Dim JsonEntryFormat As String = VideoSubItem.Name Dim JsonEntryFormat As String = VideoSubItem.Name
If CBool(InStr(JsonEntryFormat, "drm")) Or CBool(InStr(JsonEntryFormat, "dash")) Or CBool(InStr(JsonEntryFormat, "download")) Or CBool(InStr(JsonEntryFormat, "urls")) Then ' If CBool(InStr(JsonEntryFormat, "drm")) Or CBool(InStr(JsonEntryFormat, "dash")) Or CBool(InStr(JsonEntryFormat, "urls")) Then ' Or CBool(InStr(JsonEntryFormat, "download")) workaround http 502 / false http 400
Continue For Continue For
End If End If
@ -1233,6 +1237,11 @@ Public Class Main
SubLang = "" SubLang = ""
End If End If
If CBool(InStr(JsonEntryFormat, "download")) Then
download_hls = New CR_Beta_Stream(SubLang, JsonEntryFormat, Url)
Continue For
End If
CR_Streams.Add(New CR_Beta_Stream(SubLang, JsonEntryFormat, Url)) CR_Streams.Add(New CR_Beta_Stream(SubLang, JsonEntryFormat, Url))
Next Next
@ -1240,6 +1249,9 @@ Public Class Main
Next Next
If download_hls IsNot Nothing Then
CR_Streams.Add(download_hls)
End If
Next Next
Case "meta" 'each record is inside the entries array Case "meta" 'each record is inside the entries array
For Each MetaEntrys As JProperty In item.Values For Each MetaEntrys As JProperty In item.Values
@ -1469,22 +1481,22 @@ Public Class Main
If CR_Chapters = True Then If CR_Chapters = True Then
Dim ChaptersUrl As String = "https://static.crunchyroll.com/datalab-intro-v2/" + CR_EpisodeID + ".json"
Dim ChaptersJson As String = Nothing Dim ChaptersJson As String = Nothing
Dim ChaptersUrl As String = "https://static.crunchyroll.com/datalab-intro-v2/" + CR_EpisodeID + ".json"
Try
ChaptersJson = Curl(ChaptersUrl)
If CBool(InStr(ChaptersJson, "curl:")) = True Then
ChaptersJson = Curl(ChaptersUrl) ChaptersJson = Curl(ChaptersUrl)
End If
If CBool(InStr(ChaptersJson, "curl:")) = True Then If CBool(InStr(ChaptersJson, "curl:")) = True Then
ChaptersJson = Nothing ChaptersJson = Curl(ChaptersUrl)
Debug.WriteLine("no Chapter data... ignoring") End If
End If
If CBool(InStr(ChaptersJson, "curl:")) = True Then
ChaptersJson = Nothing
Debug.WriteLine("no Chapter data... ignoring")
End If
Catch ex As Exception
End Try
If ChaptersJson IsNot Nothing Then If ChaptersJson IsNot Nothing Then
@ -1642,16 +1654,28 @@ Public Class Main
For i As Integer = 0 To CR_URI_Master.Count - 1 For i As Integer = 0 To CR_URI_Master.Count - 1
Dim Count As String = (i + 1).ToString
Try
str = Curl(CR_URI_Master(i))
If CBool(InStr(str, "curl:")) = False Then
Exit For
End If
Catch ex As Exception
str = Curl(CR_URI_Master(i)) Me.Invoke(New Action(Function() As Object
Anime_Add.StatusLabel.Text = "failed accessing master.m3u8 " + Count + "/" + CR_URI_Master.Count.ToString
If CBool(InStr(str, "curl:")) = False Then Me.Text = "failed accessing master.m3u8 " + Count + "/" + CR_URI_Master.Count.ToString
Exit For Me.Invalidate()
End If Return Nothing
End Function))
Debug.WriteLine("Error accessing master #" + i.ToString + " -- " + CR_URI_Master(i))
Pause(5)
End Try
Next Next
If CBool(InStr(str, "curl:")) = True Then
If CBool(InStr(str, "curl:")) = True Or str = Nothing Then
Debug.WriteLine("Checked " + CR_URI_Master.Count.ToString) Debug.WriteLine("Checked " + CR_URI_Master.Count.ToString)
MsgBox("Unable to get master.m3u8" + vbNewLine + str, MsgBoxStyle.Critical) MsgBox("Unable to get master.m3u8" + vbNewLine + str, MsgBoxStyle.Critical)
@ -1980,7 +2004,18 @@ Public Class Main
ElseIf CBool(InStr(ex.ToString, Chr(34) + "UserAbort" + Chr(34))) Then ElseIf CBool(InStr(ex.ToString, Chr(34) + "UserAbort" + Chr(34))) Then
MsgBox(ex.ToString, MsgBoxStyle.Information) MsgBox(ex.ToString, MsgBoxStyle.Information)
ElseIf CBool(InStr(ex.ToString, "Error - Getting")) Then ElseIf CBool(InStr(ex.ToString, "Error - Getting")) Then
Navigate(WebsiteURL) If RT_count = 0 Then
If File.Exists("cookies.txt") = True Then
MsgBox("Request refused, try a new cookies.txt", MsgBoxStyle.Exclamation)
End If
Navigate(WebsiteURL)
Pause(5)
LoadBrowser(WebsiteURL, 1)
Exit Sub
End If
MsgBox(ex.ToString)
' b = False
' Navigate(WebsiteURL)
Else Else
MsgBox(ex.ToString, MsgBoxStyle.Information) MsgBox(ex.ToString, MsgBoxStyle.Information)
End If End If
@ -2189,7 +2224,7 @@ Public Class Main
End Sub End Sub
Private Sub Btn_Browser_Click(sender As Object, e As EventArgs) Handles Btn_Browser.Click Private Sub Btn_Browser_Click(sender As Object, e As EventArgs) Handles Btn_Browser.Click
Debug.WriteLine(Date.Now.ToString + "." + Date.Now.Millisecond.ToString) 'Debug.WriteLine(Date.Now.ToString + "." + Date.Now.Millisecond.ToString)
UserBowser = True UserBowser = True
If Application.OpenForms().OfType(Of Browser).Any = True Then If Application.OpenForms().OfType(Of Browser).Any = True Then
@ -2922,7 +2957,20 @@ Public Class Main
Dim Funimation_m3u8_final As String = Nothing Dim Funimation_m3u8_final As String = Nothing
Dim client0 As New WebClient Dim client0 As New WebClient
client0.Encoding = Encoding.UTF8 client0.Encoding = Encoding.UTF8
If DownloadScope = 1 Then If DownloadScope = DownloadScopeEnum.SubsOnly Then
Me.Invoke(New Action(Function() As Object
Me.Text = "Status: Substitles only mode - skipped video"
Anime_Add.StatusLabel.Text = "Status: Substitles only mode - skipped video"
Me.Invalidate()
Return Nothing
End Function))
'ElseIf DownloadScope = DownloadScopeEnum.MergeAudio Then
ElseIf DownloadScope = DownloadScopeEnum.OldDefault Or DownloadScope = DownloadScopeEnum.MergeAudio Or DownloadScope = DownloadScopeEnum.AudioOnly Then
For i As Integer = 0 To VideoStreams.Count - 1 For i As Integer = 0 To VideoStreams.Count - 1
If VideoStreams(i).Primary = True Then If VideoStreams(i).Primary = True Then
Funimation_m3u8_Primary = VideoStreams(i).Url Funimation_m3u8_Primary = VideoStreams(i).Url
@ -2946,6 +2994,7 @@ Public Class Main
Funimation_m3u8_MainVersion = Funimation_m3u8_Primary_Version Funimation_m3u8_MainVersion = Funimation_m3u8_Primary_Version
FunimationDub = ConvertFunimationDub(ConvertJsonToFunimationDub(Funimation_m3u8_Primary_audioLanguage)) FunimationDub = ConvertFunimationDub(ConvertJsonToFunimationDub(Funimation_m3u8_Primary_audioLanguage))
End If End If
If Funimation_m3u8_Main = Nothing Then If Funimation_m3u8_Main = Nothing Then
If MessageBox.Show("No media matching your settings." + vbNewLine + "Avalible: Not implimentented, press 'Yes' to copy the data into the clipboard.", "No media", MessageBoxButtons.YesNo) = DialogResult.Yes Then If MessageBox.Show("No media matching your settings." + vbNewLine + "Avalible: Not implimentented, press 'Yes' to copy the data into the clipboard.", "No media", MessageBoxButtons.YesNo) = DialogResult.Yes Then
Me.Invoke(New Action(Function() As Object Me.Invoke(New Action(Function() As Object
@ -3113,13 +3162,7 @@ Public Class Main
End If End If
Debug.WriteLine("Funimation_m3u8_final: " + Funimation_m3u8_final) Debug.WriteLine("Funimation_m3u8_final: " + Funimation_m3u8_final)
Funimation_m3u8_final = Funimation_m3u8_final.Replace(Chr(34), "") Funimation_m3u8_final = Funimation_m3u8_final.Replace(Chr(34), "")
Else
Me.Invoke(New Action(Function() As Object
Me.Text = "Status: Substitles only mode - skipped video"
Anime_Add.StatusLabel.Text = "Status: Substitles only mode - skipped video"
Me.Invalidate()
Return Nothing
End Function))
End If End If
'MsgBox(FunimationName3) 'MsgBox(FunimationName3)
Dim ResoHTMLDisplay As String = Reso.ToString + "p" Dim ResoHTMLDisplay As String = Reso.ToString + "p"
@ -3503,7 +3546,7 @@ Public Class Main
End If End If
Me.Text = "Status: Crunchyroll episode found." Me.Text = "Status: Crunchyroll episode found."
Debug.WriteLine("Crunchyroll episode found") Debug.WriteLine("Crunchyroll episode found")
GetCRVideoProxy(Request.Uri, CR_AuthToken, WebbrowserURL) GetCRVideoProxy(Request.Uri, CR_AuthToken, WebbrowserURL, 0)
b = True b = True
LoadedUrls.Clear() LoadedUrls.Clear()
Me.Text = "Crunchyroll Downloader" Me.Text = "Crunchyroll Downloader"
@ -4033,6 +4076,8 @@ Public Class Main
Return "text/html" Return "text/html"
ElseIf (httpRequest.EndsWith("txt")) Then ElseIf (httpRequest.EndsWith("txt")) Then
Return "text/plain" Return "text/plain"
ElseIf (httpRequest.EndsWith("css")) Then
Return "text/css"
ElseIf (httpRequest.EndsWith("gif")) Then ElseIf (httpRequest.EndsWith("gif")) Then
Return "image/gif" Return "image/gif"
ElseIf (httpRequest.EndsWith("jpg")) Then ElseIf (httpRequest.EndsWith("jpg")) Then
@ -4294,7 +4339,7 @@ Public Class Main
#Region "Process Urls" #Region "Process Urls"
Public Sub LoadBrowser(ByVal Url As String) Public Sub LoadBrowser(ByVal Url As String, Optional ByVal RT_count As Integer = 0)
LoadingUrl = Url LoadingUrl = Url
@ -4391,7 +4436,7 @@ Public Class Main
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)
@ -4448,14 +4493,14 @@ Public Class Main
Dim Auth2 As String = " -H " + Chr(34) + "Authorization: " + CRBetaBearer + Chr(34) Dim Auth2 As String = " -H " + Chr(34) + "Authorization: " + CRBetaBearer + Chr(34)
ProcessLoading(Url, Auth2, Loc_CR_Cookies) ProcessLoading(Url, Auth2, Loc_CR_Cookies, RT_count)
Else Else
'to do 'to do
End If End If
End Sub End Sub
Public Sub ProcessLoading(ByVal url As String, Auth2 As String, ByVal Loc_CR_Cookies As String) Public Sub ProcessLoading(ByVal url As String, Auth2 As String, ByVal Loc_CR_Cookies As String, ByVal RT_Count As Integer)
If CBool(InStr(url, "crunchyroll.com")) = True And CBool(InStr(url, "series/")) = True Then If CBool(InStr(url, "crunchyroll.com")) = True And CBool(InStr(url, "series/")) = True Then
@ -4538,7 +4583,7 @@ Public Class Main
Exit Sub Exit Sub
End Try End Try
GetCRVideoProxy(StreamsUrl, Auth2, url) GetCRVideoProxy(StreamsUrl, Auth2, url, RT_Count)
Else Else

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.15.2")> <Assembly: AssemblyVersion("3.15.4")>
<Assembly: AssemblyFileVersion("3.15.2")> <Assembly: AssemblyFileVersion("3.15.4")>
<Assembly: NeutralResourcesLanguage("en")> <Assembly: NeutralResourcesLanguage("en")>