Imports System.Net
Imports System.Text
Imports System.IO
Imports Microsoft.Win32
Imports System.ComponentModel
Public Class Main
Public gIndexH As Integer = -1
Public DialogTaskString As String
Public UserCloseDialog As Boolean = False
Dim Aktuell As String
Dim Gesamt As String
Public LabelUpdate As String = "Status: idle"
Public LabelEpisode As String = "..."
Public b As Boolean = True
Public LoginOnly As String = "False"
Public CreditsOnly As Boolean = False
Public Pfad As String = My.Computer.FileSystem.CurrentDirectory
Dim ffmpeg_command As String
Public Resu As Integer
Dim Resu2 As String
Public ResuSave As String = "6666x6666"
Public SubSprache As String
Public Unlock As Integer = 0
Public Unlock2 As Integer
Public SubFolder As Integer
Public SoftSubs As New List(Of String)
Public AbourtList As New List(Of String)
Public watingList As New List(Of String)
Dim SoftSubsString As String
Dim CR_Unlock_Error As String
Dim versuch2 As Integer = 0
Public keks As String = Nothing
Public Startseite As String = "https://www.crunchyroll.com/"
Dim SubSprache2 As String
Dim URL_DL As String
Dim Pfad_DL As String
Public Grapp_RDY As Boolean = True
Public Grapp_non_cr_RDY As Boolean = True
Public Grapp_Abord As Boolean = False
Public MaxDL As Integer
'Public TaskCount As Integer = 0
Public Event UpdateUI(ByVal sender As String, ByVal Int As Integer, ByVal Size As Double, ByVal Finished As Double)
Public ResoNotFoundString As String
Public ResoBackString As String
Dim PB_list As New List(Of PictureBox)
Public bt_dl As New List(Of PictureBox)
Public PR_List As New List(Of Process)
Public WebbrowserURL As String = Nothing
Public WebbrowserText As String = Nothing
Public WebbrowserTitle 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"
Public SubFolder_automatic As String = "[automatic : Series/Season]"
Public SubFolder_Nothing As String = "[ ignore subfolder ]"
Dim DL_Path_String As String = "Please choose download directory."
Public CR_Premium_Failed As String = "Can not verify the active premium membership."
Public No_Stream As String = "Please make sure that the URL is correct."
Dim TaskNotCompleed As String = "Please wait until the current task is completed."
Dim Premium_Stream As String = "Please make sure that you logged in for this premium episode."
Dim Error_Mass_DL As String = "We run into a problem here." + vbNewLine + "You can try to download every episode individually."
Dim User_Fault_NoName As String = "no name, fallback solution : "
Dim Sub_language_NotFound As String = "Could not find the sub language" + vbNewLine + "please make sure the language is available: "
Dim Resolution_NotFound As String = "Could not find any resolution."
Dim Error_unknown As String = "We run into a unknown problem here." + vbNewLine + "Do you like to send an Bug report?"
Public CR_Unlock_Error_String As String = "unable to get an CR-US cookie."
Dim ErrorNoPermisson As String = "Access is denied."
'UI Variablen
Public GB_Resolution_Text As String = "Resolution"
Public GB_SubLanguage_Text As String = "Hardsub language"
Public GB_Sub_Path_Text As String = "Sub directory"
Public UL_US_Text As String = "enable US Cookie"
Public RBAnime_Text As String = "series name"
Public RBStaffel_Text As String = "series name + season"
Public NewStart_String As String = "to adopt all the settings, a restart is necessary."
Public DL_Count_simultaneousText As String = "Simultaneous Downloads"
Public GB_Sub_FormatText As String = "extended Sub Settings"
Public LabelResoNotFoundText As String = "resolution not found" + vbNewLine + "Select another one below"
Public LabelLangNotFoundText As String = "language not found" + vbNewLine + "Select another one below"
Public ButtonResoNotFoundText As String = "Submit"
Public CB_SuB_Nothing As String = "[ without (none) ]"
Dim StatusToolTip As ToolTip = New ToolTip()
Dim StatusToolTipText As String
Public RunGecko As String = "Startup"
#End Region
#Region "UI"
Private Sub pictureBox1_MouseHover(sender As Object, e As EventArgs) Handles pictureBox1.MouseMove
pictureBox1.BackColor = SystemColors.Control
End Sub
Private Sub pictureBox1_MouseLeave(sender As Object, e As EventArgs) Handles pictureBox1.MouseLeave
pictureBox1.BackColor = Color.Transparent
End Sub
Private Sub pictureBox2_MouseHover(sender As Object, e As EventArgs) Handles pictureBox2.MouseMove
pictureBox2.BackColor = SystemColors.Control
End Sub
Private Sub pictureBox2_MouseLeave(sender As Object, e As EventArgs) Handles pictureBox2.MouseLeave
pictureBox2.BackColor = Color.Transparent
End Sub
Private Sub pictureBox3_MouseEnter(sender As Object, e As EventArgs) Handles pictureBox3.MouseEnter
pictureBox3.BackColor = SystemColors.Control
End Sub
Private Sub pictureBox3_MouseLeave(sender As Object, e As EventArgs) Handles pictureBox3.MouseLeave
pictureBox3.BackColor = Color.Transparent
End Sub
Private Sub pictureBox4_MouseHover(sender As Object, e As EventArgs) Handles pictureBox4.MouseMove
pictureBox4.BackColor = SystemColors.Control
End Sub
Private Sub pictureBox4_MouseLeave(sender As Object, e As EventArgs) Handles pictureBox4.MouseLeave
pictureBox4.BackColor = Color.Transparent
End Sub
#End Region
Private Sub Form8_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ServicePointManager.Expect100Continue = True
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
Me.Icon = My.Resources.icon
Try
Dim rkg As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\CRDownloader")
keks = rkg.GetValue("keks").ToString
Catch ex As Exception
End Try
Try
Dim rkg As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\CRDownloader")
Pfad = rkg.GetValue("Ordner").ToString
Catch ex As Exception
End Try
Try
Dim rkg As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\CRDownloader")
Startseite = rkg.GetValue("Startseite").ToString
Catch ex As Exception
End Try
#Region "Startup IU"
StatusToolTip.Active = True
#End Region
Try
Dim rkg As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\CRDownloader")
ffmpeg_command = rkg.GetValue("ffmpeg_command").ToString
Catch ex As Exception
ffmpeg_command = "-c copy -bsf:a aac_adtstoasc -movflags +faststart"
End Try
Try
Dim rkg As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\CRDownloader")
Resu = Integer.Parse(rkg.GetValue("Resu").ToString)
'MsgBox(Resu)
Catch ex As Exception
End Try
Try
Dim rkg As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\CRDownloader")
SubSprache = rkg.GetValue("Sub").ToString
Catch ex As Exception
End Try
Try
Dim rkg As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\CRDownloader")
SubFolder = Integer.Parse(rkg.GetValue("SubFolder").ToString)
Catch ex As Exception
SubFolder = 1
End Try
Try
Dim rkg As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\CRDownloader")
MaxDL = Integer.Parse(rkg.GetValue("SL_DL").ToString)
Catch ex As Exception
MaxDL = 1
End Try
Try
Dim rkg As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\CRDownloader")
SoftSubsString = rkg.GetValue("AddedSubs").ToString
If SoftSubsString = "none" Then
Else
Dim SoftSubsStringSplit() As String = SoftSubsString.Split(New String() {","}, System.StringSplitOptions.RemoveEmptyEntries)
For i As Integer = 0 To SoftSubsStringSplit.Count - 1
SoftSubs.Add(SoftSubsStringSplit(i))
Next
End If
Catch ex As Exception
End Try
'Label10.TextAlign = ContentAlignment.MiddleCenter
If Resu = Nothing Then
Resu = 1080
End If
If SubSprache = Nothing Then
SubSprache = "enUS"
End If
End Sub
Public Sub ListAdd(ByVal NameKomplett As String, ByVal NameP1 As String, ByVal NameP2 As String, ByVal Reso As String, ByVal HardSub As String, ByVal SoftSubs As String, ByVal ThumbnialURL As String, ByVal VideoURL As String)
'MsgBox(NameKomplett)
Dim ReDl As Boolean = False
Dim index As Integer = 0
For i As Integer = 0 To PB_list.Count - 1
If PB_list.Item(i).Name = NameKomplett Then
ReDl = True
index = i
End If
Next
If ReDl = True Then
Dim PB As PictureBox = bt_dl.Item(index)
PB.Enabled = True
Else
Dim b As New Bitmap(838, 142, System.Drawing.Imaging.PixelFormat.Format24bppRgb)
Dim g As Graphics = Graphics.FromImage(b)
Dim ZeroPoint As Point = New Point(0, 0)
Dim TextPoint As Point = New Point(195, 15)
Dim TextPointL2 As Point = New Point(195, 42)
Dim TextPointL3 As Point = New Point(773, 100)
Dim TextPointL4 As Point = New Point(195, 101)
Dim TextPointL4A2 As Point = New Point(300, 101)
Dim ThumbnialPoint As Point = New Point(11, 20)
Dim ProgressbarPoint As Point = New Point(195, 70)
Dim newImage As Image = My.Resources.backgroud
Dim img As Image = My.Resources.main_del
Try
Dim wc As New WebClient()
Dim bytes As Byte() = wc.DownloadData(ThumbnialURL)
Dim ms As New MemoryStream(bytes)
img = System.Drawing.Image.FromStream(ms)
Catch ex As Exception
'MsgBox(ex.ToString)
'MsgBox(ThumbnialURL)
End Try
g.DrawImage(newImage, ZeroPoint)
Dim Thumnail As New Bitmap(168, 95, System.Drawing.Imaging.PixelFormat.Format24bppRgb)
Dim gr_dest As Graphics = Graphics.FromImage(Thumnail)
gr_dest.DrawImage(img, 0, 0,
Thumnail.Width + 1,
Thumnail.Height + 1)
g.DrawImage(Thumnail, ThumbnialPoint)
g.DrawString(NameP1, FontLabel.Font, Brushes.Black, TextPoint)
g.DrawString(NameP2, FontLabel.Font, Brushes.Black, TextPointL2)
g.DrawRectangle(Pens.Black, ProgressbarPoint.X, ProgressbarPoint.Y, 601, 20)
Dim brGradient As Brush = New SolidBrush(Color.FromArgb(247, 140, 37))
g.FillRectangle(brGradient, ProgressbarPoint.X + 1, ProgressbarPoint.Y + 1, 0, 19)
g.DrawString("0%", FontLabel2.Font, Brushes.Black, TextPointL3)
g.DrawString(Reso, FontLabel.Font, Brushes.Black, TextPointL4)
g.DrawString(HardSub, FontLabel.Font, Brushes.Black, TextPointL4A2)
g.Dispose()
gIndexH = gIndexH + 1
With ListView1.Items.Add(0)
LVPictureBox(ListView1, gIndexH, b, "Softsubs: " + SoftSubs, NameKomplett)
bt_del(ListView1, gIndexH, NameKomplett)
End With
End If
End Sub
Public Function bt_del(ByVal pListView As ListView, ByVal ItemIndex As Integer, ByVal NameKomplett As String) As PictureBox
'btn erstellen funktion
Dim r As Rectangle
Dim bt_r As New PictureBox
Dim c As Integer = ListView1.Items.Count - 1
r = pListView.Items(c).Bounds()
bt_r.Parent = pListView
bt_r.SetBounds(755, r.Y + 20, 50, 40)
bt_dl.Add(bt_r)
bt_r.Name = NameKomplett
'bt_r.FlatStyle = FlatStyle.System
bt_r.Visible = True
bt_r.BringToFront()
bt_r.Enabled = True
bt_r.Image = My.Resources.main_close
bt_r.Image = My.Resources.main_del
bt_r.BackgroundImageLayout = ImageLayout.Center
ToolTip1.SetToolTip(bt_r, NameKomplett)
'bt_r.FlatAppearance.BorderSize = 1
'bt_r.FlatAppearance.BorderColor = Color.Black
AddHandler bt_r.Click, AddressOf Me.bt_r_click
AddHandler bt_r.MouseEnter, AddressOf Me.bt_r_ME
AddHandler bt_r.MouseLeave, AddressOf Me.bt_r_ML
Return Nothing
End Function
Private Sub bt_r_click(ByVal sender As Object, ByVal e As EventArgs)
Dim b As PictureBox = sender
b.Image = My.Resources.main_close
If MessageBox.Show("Cancel this Download?", "Cancel?", MessageBoxButtons.YesNo) = DialogResult.Yes Then
AbourtList.Add(b.Name)
b.Enabled = False
Else
b.Image = My.Resources.main_del
End If
End Sub
Private Sub bt_r_ME(ByVal sender As Object, ByVal e As EventArgs)
Dim b As PictureBox = sender
b.Image = My.Resources.main_del_hover
End Sub
Private Sub bt_r_ML(ByVal sender As Object, ByVal e As EventArgs)
Dim b As PictureBox = sender
b.Image = My.Resources.main_del
End Sub
Public Function LVPictureBox(ByVal pListView As ListView, ByVal ItemIndex As Integer, ByVal img As Bitmap, ByVal SoftSubs As String, ByVal NameKomplett As String) As PictureBox
'btn erstellen funktion
Dim r As Rectangle
Dim bt_d As New PictureBox
Dim TT As New ToolTip
Dim c As Integer = ListView1.Items.Count - 1
r = pListView.Items(c).Bounds()
r.Width = 838
r.Height = 142
bt_d.Parent = pListView
bt_d.SetBounds(r.X, r.Y, r.Width, r.Height)
bt_d.Name = NameKomplett
bt_d.BackgroundImage = img
PB_list.Add(bt_d)
ToolTip1.SetToolTip(bt_d, SoftSubs)
bt_d.BackgroundImageLayout = ImageLayout.Center
'bt_d.FlatAppearance.BorderColor = Color.Orange
bt_d.Visible = True
bt_d.Enabled = True
' AddHandler LVPictureBox., AddressOf Me.LVPictureBox_MouseHover
Return Nothing
End Function
Public Sub Pause(ByVal pau As Single)
'Programmausführung verzögern *******************************************************
Dim start, finish As Single
start = Microsoft.VisualBasic.DateAndTime.Timer
finish = start + pau
Do While Microsoft.VisualBasic.DateAndTime.Timer < finish
Application.DoEvents()
Loop
End Sub
#Region "Season DL"
Public Sub MassGrapp()
Anime_Add.groupBox2.Visible = True
Anime_Add.PictureBox1.Enabled = True
Anime_Add.PictureBox1.Visible = True
Anime_Add.groupBox1.Visible = False
Anime_Add.ComboBox1.Items.Clear()
Anime_Add.comboBox3.Items.Clear()
Anime_Add.comboBox4.Items.Clear()
Anime_Add.ComboBox1.Enabled = False
Anime_Add.comboBox3.Enabled = True
Anime_Add.comboBox4.Enabled = True
Dim Anzahl As String() = WebbrowserText.Split(New String() {"wrapper container-shadow hover-classes"}, System.StringSplitOptions.RemoveEmptyEntries)
Dim Titel As String() = Anzahl(0).Split(New String() {""}, System.StringSplitOptions.RemoveEmptyEntries)
Dim Titel2 As String() = Titel(0).Split(New String() {">"}, System.StringSplitOptions.RemoveEmptyEntries)
'MsgBox(Titel2(0))
Anime_Add.ComboBox1.Items.Add(Titel2(1))
Next
End Sub
Public Async Sub MassDL()
If Anime_Add.comboBox3.Text = Nothing Then
Exit Sub
End If
Anime_Add.Add_Display.Text = "preparing ..."
Dim Website As String = WebbrowserText
If Anime_Add.ComboBox1.Enabled = True Then
Dim SeasonDropdownAnzahl As String() = Website.Split(New String() {"season-dropdown content-menu block"}, System.StringSplitOptions.RemoveEmptyEntries)
Array.Reverse(SeasonDropdownAnzahl)
Dim SDV As Integer = 0
For i As Integer = 0 To SeasonDropdownAnzahl.Count - 1
If InStr(SeasonDropdownAnzahl(i), Chr(34) + ">" + Anime_Add.ComboBox1.SelectedItem.ToString + "") Then
SDV = i
End If
Next
Website = SeasonDropdownAnzahl(SDV)
End If
Try
Dim Anzahl As String() = Website.Split(New String() {"wrapper container-shadow hover-classes"}, System.StringSplitOptions.RemoveEmptyEntries)
Array.Reverse(Anzahl)
Dim c As Integer = Anime_Add.comboBox4.SelectedIndex - Anime_Add.comboBox3.SelectedIndex + 1
'AnzahlGesamt.Text = c.ToString
Gesamt = c.ToString
Aktuell = "0"
If Anime_Add.comboBox4.SelectedIndex > Anime_Add.comboBox3.SelectedIndex Then
For i As Integer = Anime_Add.comboBox3.SelectedIndex To Anime_Add.comboBox4.SelectedIndex
For e As Integer = 0 To Integer.MaxValue
If Grapp_RDY = True Then
RemoveFinishedTask()
Pause(1)
If PR_List.Count < MaxDL Then
Exit For
Else
'MsgBox(e)
Await Task.Delay(2000)
End If
Else
Await Task.Delay(2000)
End If
Next
If Anime_Add.Mass_DL_Cancel = False Then
b = True
Exit For
Grapp_Abord = True
'MsgBox("dl_abourd")
End If
Dim d As Integer = i - Anime_Add.comboBox3.SelectedIndex + 1
Dim URLGrapp As String() = Anzahl(i).Split(New String() {"")) Then ' false on movie true on series
Dim CR_Name_1 As String() = WebbrowserText.Split(New String() {""}, System.StringSplitOptions.RemoveEmptyEntries)
Dim CR_Name_2 As String() = CR_Name_1(1).Split(New String() {"
"}, System.StringSplitOptions.RemoveEmptyEntries) '(New [Char]() {"-"})
Dim CR_Name_Staffel0_Folge1 As String()
If CBool(InStr(CR_Name_2(0), ",")) Then
CR_Name_Staffel0_Folge1 = CR_Name_2(0).Split(New [Char]() {System.Convert.ToChar(",")}, System.StringSplitOptions.RemoveEmptyEntries)
CR_Anime_Staffel = CR_Name_Staffel0_Folge1(0).Trim()
CR_Anime_Folge = CR_Name_Staffel0_Folge1(1).Trim()
CR_Anime_Folge = System.Text.RegularExpressions.Regex.Replace(CR_Anime_Folge, "[^\w\\-]", " ")
Else
CR_Anime_Staffel = Nothing
CR_Anime_Folge = CR_Name_2(0).Trim()
CR_Anime_Folge = System.Text.RegularExpressions.Regex.Replace(CR_Anime_Folge, "[^\w\\-]", " ")
End If
Dim CR_Name_4 As String() = CR_Name_1(0).Split(New String() {"class=" + Chr(34) + "text-link" + Chr(34) + ">"}, System.StringSplitOptions.RemoveEmptyEntries) '(New [Char]() {"-"})
Dim CR_Name_Anime0 As String() = CR_Name_4(CR_Name_4.Length - 1).Split(New String() {""}, System.StringSplitOptions.RemoveEmptyEntries)
CR_Name_Anime0(0) = System.Text.RegularExpressions.Regex.Replace(CR_Name_Anime0(0), "[^\w\\-]", " ")
CR_Anime_Titel = CR_Name_Anime0(0).Trim
If CR_Anime_Staffel = Nothing Then
CR_FilenName = CR_Anime_Titel + " " + CR_Anime_Folge
Else
CR_FilenName = CR_Anime_Titel + " " + CR_Anime_Staffel + " " + CR_Anime_Folge
End If
CR_FilenName_Backup = RemoveExtraSpaces(CR_FilenName)
End If
#End Region
Else
Me.Invoke(New Action(Function()
If Anime_Add.ComboBox2.Text = SubFolder_automatic Then
MsgBox(SubFolder_automatic + " is not working with a costum name", MsgBoxStyle.Information)
ElseIf Anime_Add.ComboBox2.Text = SubFolder_Nothing Then
Else
SubfolderValue = Anime_Add.ComboBox2.Text + "\"
End If
Return Nothing
End Function))
'MsgBox(TextBox2_Text)
CR_FilenName = RemoveExtraSpaces(System.Text.RegularExpressions.Regex.Replace(TextBox2_Text, "[^\w\\-]", " "))
CR_FilenName_Backup = CR_FilenName
End If
Me.Invoke(New Action(Function()
If Anime_Add.ComboBox2.Text = SubFolder_automatic Then
If SubFolder = 2 Then
SubfolderValue = CR_Anime_Titel + "\" + CR_Anime_Staffel + "\"
ElseIf SubFolder = 1 Then
SubfolderValue = CR_Anime_Titel + "\"
End If
ElseIf Anime_Add.ComboBox2.Text = SubFolder_Nothing Then
Else
SubfolderValue = Anime_Add.ComboBox2.Text + "\"
End If
Return Nothing
End Function))
'MsgBox(CR_FilenName)
CR_FilenName = System.Text.RegularExpressions.Regex.Replace(CR_FilenName, "[^\w\\-]", " ")
CR_FilenName = RemoveExtraSpaces(CR_FilenName)
If SubfolderValue = Nothing Then
Pfad2 = Pfad + "\" + CR_FilenName + ".mp4"
Else
Pfad2 = Pfad + "\" + SubfolderValue + CR_FilenName + ".mp4"
End If
If Not Directory.Exists(Path.GetDirectoryName(Pfad2)) Then
' Nein! Jetzt erstellen...
Try
Directory.CreateDirectory(Path.GetDirectoryName(Pfad2))
Catch ex As Exception
' Ordner wurde nich erstellt
Pfad2 = Pfad + "\" + CR_FilenName_Backup + ".mp4"
End Try
End If
Pfad2 = Chr(34) + Pfad2 + Chr(34)
#End Region
#Region "Subs"
Dim SoftSubs2 As New List(Of String)
If SoftSubs.Count > 0 Then
For i As Integer = 0 To SoftSubs.Count - 1
If CBool(InStr(WebbrowserText, Chr(34) + "language" + Chr(34) + ":" + Chr(34) + SoftSubs(i) + Chr(34) + ",")) Then
SoftSubs2.Add(SoftSubs(i))
Else
'MsgBox("Softsubtitle for " + SoftSubs(i) + " is not avalible.", MsgBoxStyle.Information)
End If
Next
End If
If SubSprache = "None" Then
If CBool(InStr(WebbrowserText, Chr(34) + "hardsub_lang" + Chr(34) + ":null")) Then
SubSprache2 = "null"
Else
Me.Invoke(New Action(Function()
ResoNotFoundString = WebbrowserText
DialogTaskString = "Language"
Reso.ShowDialog()
Return Nothing
End Function))
If UserCloseDialog = True Then
Throw New System.Exception(Chr(34) + "UserAbort" + Chr(34))
Else
If ResoBackString = Nothing Then
Else
SubSprache2 = ResoBackString
End If
End If
'Throw New System.Exception("Could not find the sub language")
End If
Else
If CBool(InStr(WebbrowserText, Chr(34) + "hardsub_lang" + Chr(34) + ":" + Chr(34) + SubSprache + Chr(34) + ",")) Then
SubSprache2 = Chr(34) + SubSprache + Chr(34)
ElseIf CBool(InStr(WebbrowserText, Chr(34) + "language" + Chr(34) + ":" + Chr(34) + SubSprache + Chr(34) + ",")) Then
If MessageBox.Show("It look like only Softsubtitle are avalibe." + vbNewLine + "Are you want to use Softsubtitle this time instead?", "No Hardsubtitle", MessageBoxButtons.YesNo) = DialogResult.Yes Then
SubSprache2 = "null"
SoftSubs2.Add(SubSprache)
Else
Throw New System.Exception("Could not find the sub language")
End If
Else
Me.Invoke(New Action(Function()
ResoNotFoundString = WebbrowserText
DialogTaskString = "Language"
Reso.ShowDialog()
Return Nothing
End Function))
If UserCloseDialog = True Then
Throw New System.Exception(Chr(34) + "UserAbort" + Chr(34))
Else
If ResoBackString = Nothing Then
Else
SubSprache2 = ResoBackString
End If
End If
End If
End If
#End Region
If Grapp_Abord = True Then
Grapp_RDY = True
Grapp_Abord = False
'MsgBox("grapp_abourd")
Exit Sub
End If
#Region "m3u8 suche"
Dim ii As Integer = 0
'MsgBox(Chr(34) + "hardsub_lang" + Chr(34) + ":" + SubSprache2 + "," + Chr(34) + "url" + Chr(34) + ":" + Chr(34))
Dim CR_URI_Master As String = Nothing
Dim CR_URI_Master_Split1 As String() = WebbrowserText.Split(New String() {My.Resources.hls_Value}, System.StringSplitOptions.RemoveEmptyEntries)
Dim hls_List As New List(Of String)
For i As Integer = 0 To CR_URI_Master_Split1.Count - 1
If InStr(CR_URI_Master_Split1(i), My.Resources.hls_endString) Then
Dim s As String() = CR_URI_Master_Split1(i).Split(New String() {My.Resources.hls_endString}, System.StringSplitOptions.RemoveEmptyEntries)
hls_List.Add(s(0))
End If
Next
'Dim CR_URI_Master_Split1 As String() = WebbrowserText.Split(New String() {Chr(34) + "hardsub_lang" + Chr(34) + ":" + SubSprache2 + "," + Chr(34) + "url" + Chr(34) + ":" + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries)
For i As Integer = 0 To hls_List.Count - 1
If InStr(hls_List(i), Chr(34) + "hardsub_lang" + Chr(34) + ":" + SubSprache2 + "," + Chr(34) + "url" + Chr(34) + ":" + Chr(34)) Then
Dim s() As String = hls_List(i).Split(New String() {Chr(34) + "hardsub_lang" + Chr(34) + ":" + SubSprache2 + "," + Chr(34) + "url" + Chr(34) + ":" + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries)
CR_URI_Master = s(1).Replace("\/", "/")
'MsgBox(CR_URI_Master)
End If
Next
If CBool(InStr(CR_URI_Master, "master.m3u8")) Then
Me.Invoke(New Action(Function()
Anime_Add.StatusLabel.Text = "Status: m3u8 found, looking for resolution"
Return Nothing
End Function))
Else
Throw New System.Exception("Premnium Episode")
End If
#End Region
#Region "Download softsub file"
If SoftSubs2.Count > 0 Then
For i As Integer = 0 To SoftSubs2.Count - 1
'EpisodeLabel.Text = SoftSubs2(i)
'StatusLabel.Text = "Status: downloading subtitle file"
LabelUpdate = "Status: downloading subtitle file"
LabelEpisode = SoftSubs2(i)
Dim SoftSub As String() = WebbrowserText.Split(New String() {Chr(34) + "language" + Chr(34) + ":" + Chr(34) + SoftSubs2(i) + Chr(34) + "," + Chr(34) + "url" + Chr(34) + ":" + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries)
Dim SoftSub_2 As String() = SoftSub(1).Split(New [Char]() {Chr(34)})
Dim SoftSub_3 As String = SoftSub_2(0).Replace("\/", "/")
Dim client0 As New WebClient
client0.Encoding = Encoding.UTF8
Dim str0 As String = client0.DownloadString(SoftSub_3)
Dim Pfad3 As String = Pfad2.Replace(Chr(34), "")
Dim FN As String = Path.ChangeExtension(Path.Combine(Path.GetFileNameWithoutExtension(Pfad3) + " " + SoftSubs2(i) + Path.GetExtension(Pfad3)), "ass")
'MsgBox(FN)
If i = 0 Then
FN = Path.ChangeExtension(Path.GetFileName(Pfad3), "ass")
'MsgBox(FN)
End If
Dim Pfad4 As String = Path.Combine(Path.GetDirectoryName(Pfad3), FN)
'MsgBox(Pfad4)
File.WriteAllText(Pfad4, str0, Encoding.UTF8)
Pause(1)
Next
End If
#End Region
#Region "lösche doppel download"
Dim Pfad5 As String = Pfad2.Replace(Chr(34), "")
If My.Computer.FileSystem.FileExists(Pfad5) Then 'Pfad = Kompeltter Pfad mit Dateinamen + ENdung
If MessageBox.Show("The file " + Pfad5 + " already exists." + vbNewLine + "You want to override it?", "File exists!", MessageBoxButtons.OKCancel) = DialogResult.OK Then
Try
My.Computer.FileSystem.DeleteFile(Pfad5)
Catch ex As Exception
End Try
Else
Grapp_RDY = True
Exit Sub
End If
End If
#End Region
If Resu = 42 Then
URL_DL = CR_URI_Master
Else
Dim client As New System.Net.WebClient
client.Encoding = Encoding.UTF8
'MsgBox(CR_URI_Master)
Dim str As String = client.DownloadString(CR_URI_Master)
'MsgBox(str)
If CBool(InStr(str, "x" + Resu.ToString + ",")) Then
Resu2 = "x" + Resu.ToString
Else
'MsgBox(str)
If CBool(InStr(str, ResuSave + ",")) Then
Resu2 = Resu2
Else
Me.Invoke(New Action(Function()
DialogTaskString = "Resolution"
ResoNotFoundString = str
Reso.ShowDialog()
Return Nothing
End Function))
'MsgBox(ResoBackString)
If UserCloseDialog = True Then
Throw New System.Exception(Chr(34) + "UserAbort" + Chr(34))
Else
Resu2 = ResoBackString
End If
End If
End If
'MsgBox(Resu2)
Dim VLC_URI_1 As String() = str.Split(New String() {Resu2 + ","}, System.StringSplitOptions.RemoveEmptyEntries)
Dim VLC_URI_2 As String() = VLC_URI_1(1).Split(New [Char]() {Chr(34)})
Dim VLC_URI_3 As String() = VLC_URI_2(2).Split(New [Char]() {System.Convert.ToChar("#")})
URL_DL = VLC_URI_3(0).Trim()
End If
#Region "thumbnail"
Dim thumbnail As String() = WebbrowserText.Split(New String() {My.Resources.thumbnailString}, System.StringSplitOptions.RemoveEmptyEntries)
Dim thumbnail2 As String() = thumbnail(1).Split(New String() {Chr(34) + "}"}, System.StringSplitOptions.RemoveEmptyEntries) '(New [Char]() {"-"})
Dim thumbnail3 As String = thumbnail2(0).Replace("\/", "/")
#End Region
#Region "