fixes funimation

fix funimation request without cookie
added error handling for unavalible resolution on funimation
This commit is contained in:
hama3254 2020-07-19 12:15:41 +02:00
parent c1bcb32832
commit 87d2c682fb
13 changed files with 100 additions and 30 deletions

Binary file not shown.

View File

@ -161,9 +161,15 @@ Public Class GeckoFX
'ElseIf CBool(InStr(WebBrowser1.Url.ToString, "https://www.anime-on-demand.de/anime/")) Then
ElseIf CBool(InStr(WebBrowser1.Url.ToString, "funimation.com/player")) Then
'todo softsub download
Dim SubTitle1() As String = WebBrowser1.Document.Body.OuterHtml.Split(New String() {".srt"}, System.StringSplitOptions.RemoveEmptyEntries)
Dim SubTitle2() As String = SubTitle1(0).Split(New String() {Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries)
Main.WebbrowserSoftSubURL = SubTitle2(SubTitle2.Count - 1) + ".srt"
'MsgBox(WebBrowser1.Document.Body.OuterHtml)
If InStr(WebBrowser1.Document.Body.OuterHtml, ".srt") Then
Dim SubTitle1() As String = WebBrowser1.Document.Body.OuterHtml.Split(New String() {".srt"}, System.StringSplitOptions.RemoveEmptyEntries)
Dim SubTitle2() As String = SubTitle1(0).Split(New String() {Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries)
Main.WebbrowserSoftSubURL = SubTitle2(SubTitle2.Count - 1) + ".srt"
Else
Main.WebbrowserSoftSubURL = Nothing
End If
'MsgBox(Main.WebbrowserSoftSubURL)
' Anime_Add.StatusLabel.Text =
ElseIf CBool(InStr(WebBrowser1.Url.ToString, "funimation.com")) Then
@ -174,6 +180,7 @@ Public Class GeckoFX
Main.WebbrowserText = WebBrowser1.Document.Body.OuterHtml
Main.WebbrowserTitle = WebBrowser1.DocumentTitle
Main.WebbrowserHeadText = WebBrowser1.Document.Head.InnerHtml
Main.WebbrowserCookie = WebBrowser1.Document.Cookie
Main.b = True
t = New Thread(AddressOf Main.Funitmation_Grapp)
@ -404,7 +411,7 @@ Public Class GeckoFX
'Main.GrappURL()
Try
My.Computer.Clipboard.SetText(WebBrowser1.Url.ToString)
'My.Computer.Clipboard.SetText(WebBrowser1.Document.Head.InnerHtml)
'My.Computer.Clipboard.SetText(WebBrowser1.Document.Cookie)
MsgBox("copied: " + Chr(34) + WebBrowser1.Url.ToString + Chr(34))
Catch ex As Exception
@ -629,34 +636,34 @@ Public Class GeckoFX
Next
End If
If Main.txtList.Count > 0 Then 'InStr(HTMLString, ".mpd?") Then
HTMLString = Main.mpdList.Item(0)
'Button2.Text = "found mpd!"
Main.LogBrowserData = False
'If Main.txtList.Count > 0 Then 'InStr(HTMLString, ".mpd?") Then
' HTMLString = Main.mpdList.Item(0)
' 'Button2.Text = "found mpd!"
' Main.LogBrowserData = False
GeckoPreferences.Default("logging.config.LOG_FILE") = "gecko-network.txt"
GeckoPreferences.Default("logging.nsHttp") = 0
Dim URL As String = Nothing
Dim HTMLSplit() As String = HTMLString.Split(New String() {vbNewLine}, System.StringSplitOptions.RemoveEmptyEntries)
For i As Integer = 0 To HTMLSplit.Count - 1
If InStr(HTMLSplit(i), ".mpd?") Then
Dim URLPart2() As String = HTMLSplit(i).Split(New String() {" GET "}, System.StringSplitOptions.RemoveEmptyEntries)
Dim URLPart2Split2() As String = URLPart2(1).Split(New String() {" HTTP/"}, System.StringSplitOptions.RemoveEmptyEntries)
Dim URLPart1() As String = HTMLSplit(i + 1).Split(New String() {" Host: "}, System.StringSplitOptions.RemoveEmptyEntries)
Main.NonCR_URL = "https://" + URLPart1(1) + URLPart2Split2(0)
'MsgBox(Main.NonCR_URL)
'RichTextBox1.Text = RichTextBox1.Text + vbNewLine + URL_Final
Main.FFMPEG_Reso(Main.NonCR_URL)
t = New Thread(AddressOf Main.Grapp_non_CR)
t.Priority = ThreadPriority.Normal
t.IsBackground = True
t.Start()
Button2.Text = "Start network scan"
Exit For
End If
Next
' GeckoPreferences.Default("logging.config.LOG_FILE") = "gecko-network.txt"
' GeckoPreferences.Default("logging.nsHttp") = 0
' Dim URL As String = Nothing
' Dim HTMLSplit() As String = HTMLString.Split(New String() {vbNewLine}, System.StringSplitOptions.RemoveEmptyEntries)
' For i As Integer = 0 To HTMLSplit.Count - 1
' If InStr(HTMLSplit(i), ".mpd?") Then
' Dim URLPart2() As String = HTMLSplit(i).Split(New String() {" GET "}, System.StringSplitOptions.RemoveEmptyEntries)
' Dim URLPart2Split2() As String = URLPart2(1).Split(New String() {" HTTP/"}, System.StringSplitOptions.RemoveEmptyEntries)
' Dim URLPart1() As String = HTMLSplit(i + 1).Split(New String() {" Host: "}, System.StringSplitOptions.RemoveEmptyEntries)
' Main.NonCR_URL = "https://" + URLPart1(1) + URLPart2Split2(0)
' 'MsgBox(Main.NonCR_URL)
' 'RichTextBox1.Text = RichTextBox1.Text + vbNewLine + URL_Final
' Main.FFMPEG_Reso(Main.NonCR_URL)
' t = New Thread(AddressOf Main.Grapp_non_CR)
' t.Priority = ThreadPriority.Normal
' t.IsBackground = True
' t.Start()
' Button2.Text = "Start network scan"
' Exit For
' End If
' Next
End If
'End If
ScanTrue = False
Button2.Enabled = True
Catch ex As Exception

View File

@ -62,6 +62,7 @@ Public Class Main
Public WebbrowserURL As String = Nothing
Public WebbrowserText As String = Nothing
Public WebbrowserTitle As String = Nothing
Public WebbrowserCookie As String = Nothing
Public UserBowser As Boolean = False
#Region "Sprachen Vairablen"
Public URL_Invaild As String = "invalid URL, this Downloader is only for crunchyroll.com"
@ -1852,6 +1853,10 @@ Public Class Main
Dim client0 As New WebClient
client0.Encoding = Encoding.UTF8
If WebbrowserCookie = Nothing Then
Else
client0.Headers.Add(HttpRequestHeader.Cookie, WebbrowserCookie)
End If
Dim str0 As String = client0.DownloadString("https://www.funimation.com/api/showexperience/" + Player_ID2(0) + "/?pinst_id=fzQc9p9f")
Dim Funimation_m3u8() As String = str0.Split(New String() {My.Resources.Funimation_src_string}, System.StringSplitOptions.RemoveEmptyEntries)
Dim Funimation_m3u8_final As String = Nothing
@ -1863,6 +1868,25 @@ Public Class Main
Exit For
End If
Next
If Funimation_m3u8_Main = Nothing Then
If MessageBox.Show("No media found in:" + vbNewLine + str0, "No media", MessageBoxButtons.RetryCancel) = DialogResult.Retry Then
Me.Invoke(New Action(Function()
GeckoFX.WebBrowser1.Navigate(WebbrowserURL)
Try
Anime_Add.StatusLabel.Text = "retrying Funimation"
Catch ex As Exception
End Try
Return Nothing
End Function))
Exit Sub
Else
Funimation_Grapp_RDY = True
Exit Sub
End If
Else
'MsgBox(Funimation_m3u8_Main)
End If
Dim str1 As String = client0.DownloadString(Funimation_m3u8_Main.Replace(Chr(34), ""))
Dim textLenght() As String = str1.Split(New String() {vbLf}, System.StringSplitOptions.RemoveEmptyEntries)
@ -1875,6 +1899,24 @@ Public Class Main
End If
Next
If Funimation_m3u8_final = Nothing Then
Me.Invoke(New Action(Function()
DialogTaskString = "Funimation_Resolution"
ResoNotFoundString = str1
Reso.ShowDialog()
Return Nothing
End Function))
For i As Integer = 0 To textLenght.Length - 1
If InStr(textLenght(i), "https") Then
If InStr(textLenght(i - 1), ResoBackString) Then
Funimation_m3u8_final = textLenght(i)
Exit For
End If
End If
Next
End If
'
'MsgBox(FunimationName3)
'MsgBox(Funimation_m3u8_final)
@ -1895,6 +1937,7 @@ Public Class Main
#End Region
If WebbrowserSoftSubURL = Nothing Then
Else
'MsgBox(WebbrowserSoftSubURL)
Dim str2 As String = client0.DownloadString(WebbrowserSoftSubURL)
Dim Pfad3 As String = DownloadPfad.Replace(Chr(34), "")
Dim Pfad4 As String = Pfad3.Replace(".mp4", ".srt")

View File

@ -66,6 +66,26 @@
Catch ex As Exception
End Try
ElseIf Main.DialogTaskString = "Funimation_Resolution" Then
StatusLabel.Text = Main.LabelResoNotFoundText
Dim ResoList As New List(Of String)
Dim m3u8_split As String() = Main.ResoNotFoundString.Split(New String() {vbLf}, System.StringSplitOptions.RemoveEmptyEntries)
For i As Integer = 0 To m3u8_split.Count - 1
If InStr(m3u8_split(i), "RESOLUTION=") Then
ResoList.Add(m3u8_split(i))
End If
Next
Dim Reso_avaible1 As String() = Main.ResoNotFoundString.Split(New String() {"RESOLUTION="}, System.StringSplitOptions.RemoveEmptyEntries)
For i As Integer = 0 To ResoList.Count - 1
Dim Reso_avaible As String() = ResoList.Item(i).Split(New String() {"RESOLUTION="}, System.StringSplitOptions.RemoveEmptyEntries)
ComboBox1.Items.Add(Reso_avaible(1))
Next
SurroundingSub()
Try
ComboBox1.SelectedIndex = 0
Catch ex As Exception
End Try
End If
End Sub