Imports System.Net
Imports System.Text
Imports System.IO
Imports Microsoft.Win32
Imports System.Threading
Imports System.Net.WebUtility
Imports System.Net.Sockets
Imports MetroFramework.Forms
Imports MetroFramework
Imports MetroFramework.Components
Public Class Main
Inherits MetroForm
Public Manager As New MetroStyleManager
Public DarkModeValue As Boolean = False
Public invalids As Char() = System.IO.Path.GetInvalidFileNameChars()
Public ErrorTolerance As Integer = 0
Public liList As New List(Of String)
Public HTMLString As String = My.Resources.Startuphtml
Public RunServer As Boolean = True
Public ListBoxList As New List(Of String)
Dim ItemList As New List(Of CRD_List_Item)
Public RunningDownloads As Integer = 0
Public UseQueue As Boolean = False
Public StartServer As Boolean = False
Public m3u8List As New List(Of String)
Public txtList As New List(Of String)
Public mpdList As New List(Of String)
Public ResoAvalibe As String = Nothing
Public ResoSearchRunning As Boolean = False
Public UsedMap As String = Nothing
Public Debug1 As Boolean = False
Public Debug2 As Boolean = False
Public LogBrowserData As Boolean = False
Public Thumbnail As String = Nothing
Public MergeSubstoMP4 As Boolean = False
Public LoginDialog As Boolean = False
Public SaveLog As Boolean = False
Public NonCR_Timeout As Integer = 5
Public NonCR_URL As String = Nothing
Public DlSoftSubsRDY As Boolean = True
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 c As Boolean = True
Public d As Boolean = True
Public LoginOnly As String = "False"
Public Pfad As String = My.Computer.FileSystem.CurrentDirectory
Public ffmpeg_command As String = " -c copy -bsf:a aac_adtstoasc" '" -c:v hevc_nvenc -preset fast -b:v 6M -bsf:a aac_adtstoasc "
Public Reso As Integer
Public AoD_Reso As Integer = 0
Dim Reso2 As String
Public ResoSave As String = "6666x6666"
Public ResoFunBackup As String = "6666x6666"
Public SubSprache As String
Public SoftSubs As New List(Of String)
Public TempSoftSubs As New List(Of String)
Public AbourtList As New List(Of String)
Public watingList As New List(Of String)
Public GeckoLogFile As String = Nothing
Dim SoftSubsString As String
Dim CR_Unlock_Error As String
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 Funimation_Grapp_RDY As Boolean = True
Public Grapp_non_cr_RDY As Boolean = True
Public Grapp_Abord As Boolean = False
Public CR_NameMethode As Integer = 0
Public MaxDL As Integer
Public ResoNotFoundString As String
Public ResoBackString As String
Public WebbrowserHeadText As String = Nothing
Public WebbrowserSoftSubURL As String = Nothing
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
Public HybridMode As Boolean = False
Public HardSubFunimation As String = "Disabled"
Public DubFunimation As String = "Disabled"
Public Funimation_srt As Boolean = False
Public Funimation_vtt As Boolean = False
Public Funimation_dfxp As Boolean = False
Public SubFunimationString As String = "en"
Public SubFunimation As New List(Of String)
#Region "Sprachen Vairablen"
Public URL_Invaild As String = "something is wrong here..."
Dim DL_Path_String As String = "Please choose download directory."
Public No_Stream As String = "Please make sure that the URL is correct or check if the Anime is available in your country."
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."
Public LoginReminder As String = "Please make sure that you logged in."
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 = "[ null ]"
Dim StatusToolTip As ToolTip = New ToolTip()
Dim StatusToolTipText As String
Public RunGecko As String = "Startup"
#End Region
#Region "UI"
Private Sub Main_TextChanged(sender As Object, e As EventArgs) Handles Me.TextChanged
Me.Invalidate()
End Sub
Public CloseImg As Bitmap = My.Resources.main_del
Public MinImg As Bitmap = My.Resources.main_mini
Public Sub DarkMode()
ListView1.BackColor = Color.FromArgb(50, 50, 50)
CloseImg = My.Resources.main_close_dark
MinImg = My.Resources.main_mini_dark
Btn_min.Image = MinImg
Btn_Close.Image = CloseImg
End Sub
Public Sub LightMode()
ListView1.BackColor = SystemColors.Control
CloseImg = My.Resources.main_close
MinImg = My.Resources.main_mini
Btn_min.Image = MinImg
Btn_Close.Image = CloseImg
End Sub
Dim ListViewHeightOffset As Integer = 7
Private Sub Btn_add_MouseEnter(sender As Object, e As EventArgs) Handles Btn_add.MouseEnter
Dim PB As PictureBox = sender
If Manager.Theme = MetroThemeStyle.Dark Then
PB.Image = My.Resources.main_add_invert_dark
Else
PB.Image = My.Resources.main_add_invert
End If
End Sub
Private Sub Btn_add_MouseLeave(sender As Object, e As EventArgs) Handles Btn_add.MouseLeave
Dim PB As PictureBox = sender
PB.Image = My.Resources.main_add
End Sub
Private Sub Btn_Browser_MouseEnter(sender As Object, e As EventArgs) Handles Btn_Browser.MouseEnter
Dim PB As PictureBox = sender
If Manager.Theme = MetroThemeStyle.Dark Then
PB.Image = My.Resources.main_browser_invert_dark
Else
PB.Image = My.Resources.main_browser_invert
End If
End Sub
Private Sub Btn_Browser_MouseLeave(sender As Object, e As EventArgs) Handles Btn_Browser.MouseLeave
Dim PB As PictureBox = sender
PB.Image = My.Resources.main_browser
End Sub
Private Sub Btn_Settings_MouseEnter(sender As Object, e As EventArgs) Handles Btn_Settings.MouseEnter
Dim PB As PictureBox = sender
If Manager.Theme = MetroThemeStyle.Dark Then
PB.Image = My.Resources.main_setting_invert_dark
Else
PB.Image = My.Resources.main_setting_invert
End If
End Sub
Private Sub Btn_Settings_MouseLeave(sender As Object, e As EventArgs) Handles Btn_Settings.MouseLeave
Dim PB As PictureBox = sender
PB.Image = My.Resources.main_settings
End Sub
Private Sub Btn_min_MouseEnter(sender As Object, e As EventArgs) Handles Btn_min.MouseEnter
Dim PB As PictureBox = sender
PB.Image = My.Resources.main_mini_red
End Sub
Private Sub Btn_min_MouseLeave(sender As Object, e As EventArgs) Handles Btn_min.MouseLeave
Dim PB As PictureBox = sender
PB.Image = MinImg
End Sub
Private Sub Btn_Close_MouseEnter(sender As Object, e As EventArgs) Handles Btn_Close.MouseEnter
Dim PB As PictureBox = sender
PB.Image = My.Resources.main_del
End Sub
Private Sub Btn_Close_MouseLeave(sender As Object, e As EventArgs) Handles Btn_Close.MouseLeave
Dim PB As PictureBox = sender
PB.Image = CloseImg
End Sub
Private Sub PictureBox6_Click(sender As Object, e As EventArgs) Handles PictureBox6.Click
If TheTextBox.Visible = True Then
TheTextBox.Visible = False
ListViewHeightOffset = 7
PictureBox6.Location = New Point(0, Me.Height - ListViewHeightOffset)
TheTextBox.Location = New Point(1, Me.Height - ListViewHeightOffset + 7)
TheTextBox.Width = Me.Width - 2
Else
ListViewHeightOffset = 103
TheTextBox.Visible = True
PictureBox6.Location = New Point(0, Me.Height - ListViewHeightOffset)
TheTextBox.Location = New Point(1, Me.Height - ListViewHeightOffset + 7)
TheTextBox.Width = Me.Width - 2
End If
End Sub
Private Sub PictureBox6_MouseEnter(sender As Object, e As EventArgs) Handles PictureBox6.MouseEnter
PictureBox6.BackgroundImage = My.Resources.balken_console
End Sub
Private Sub PictureBox6_MouseLeave(sender As Object, e As EventArgs) Handles PictureBox6.MouseLeave
PictureBox6.BackgroundImage = My.Resources.balken
End Sub
Private Sub Main_Resize(sender As Object, e As EventArgs) Handles Me.Resize
ListView1.Width = Me.Width - 2
ListView1.Height = Me.Height - 71 - ListViewHeightOffset
PictureBox5.Width = Me.Width - 40
PictureBox6.Location = New Point(1, Me.Height - ListViewHeightOffset)
PictureBox6.Width = Me.Width - 40
TheTextBox.Location = New Point(1, Me.Height - ListViewHeightOffset + 7)
TheTextBox.Width = Me.Width - 2
Btn_Close.Location = New Point(Me.Width - 40, 1)
Btn_min.Location = New Point(Me.Width - 68, 10)
Btn_Settings.Location = New Point(Me.Width - 170, 17)
Try
For s As Integer = 0 To ListView1.Items.Count - 1
Dim r As Rectangle = ListView1.Items.Item(s).Bounds
ItemList(s).SetBounds(r.X, r.Y, ListView1.Width - 2, r.Height)
If ItemList(s).GetToDispose() = True Then
ItemList(s).DisposeItem(ItemList(s).GetToDispose())
ItemList.RemoveAt(s)
ListView1.Items.RemoveAt(s)
End If
Next
Catch ex As Exception
End Try
End Sub
#End Region
Public Declare Function waveOutSetVolume Lib "winmm.dll" (ByVal uDeviceID As Integer, ByVal dwVolume As Integer) As Integer
Public Sub SetSettingsTheme()
Einstellungen.Theme = Manager.Theme
End Sub
Private Sub Form8_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim tbtl As TextBoxTraceListener = New TextBoxTraceListener(TheTextBox)
Debug.Listeners.Add(tbtl)
'Try
' Dim SettingsDone As Boolean = False
' Dim rkg As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\CRDownloader")
' SettingsDone = CBool(Integer.Parse(rkg.GetValue("SettingsDone").ToString))
'Catch ex As Exception
' FirstStartup.ShowDialog()
'End Try
'Dim Style As New MetroStyleManager
'
Try
Dim rkg As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\CRDownloader")
DarkModeValue = CBool(Integer.Parse(rkg.GetValue("Dark_Mode").ToString))
Catch ex As Exception
End Try
Manager.Style = MetroColorStyle.Orange
If DarkModeValue = True Then
Manager.Theme = MetroThemeStyle.Dark
DarkMode()
Else
Manager.Theme = MetroThemeStyle.Light
LightMode()
End If
Me.StyleManager = Manager
Manager.Owner = Me
Try
Dim rkg As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\CRDownloader")
StartServer = CBool(Integer.Parse(rkg.GetValue("StartServer").ToString))
Catch ex As Exception
End Try
If StartServer = True Then
Timer3.Enabled = True
Dim t As New Thread(AddressOf ServerStart)
t.Priority = ThreadPriority.Normal
t.IsBackground = True
t.Start()
End If
waveOutSetVolume(0, 0)
Try
Dim FileLocation As DirectoryInfo = New DirectoryInfo(Application.StartupPath)
For Each File In FileLocation.GetFiles()
If InStr(File.FullName, "gecko-network.txt") Then
My.Computer.FileSystem.DeleteFile(Path.Combine(Application.StartupPath, File.FullName))
Exit For
End If
Next
Catch ex As Exception
End Try
ServicePointManager.Expect100Continue = True
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
Try
Me.Icon = My.Resources.icon
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")
UseQueue = CBool(Integer.Parse(rkg.GetValue("QueueMode").ToString))
'MsgBox(UseQueue.ToString)
Catch ex As Exception
End Try
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 "
End Try
'If ffmpeg_command = " -c:v hevc_nvenc -preset fast -b:v 6M -bsf:a aac_adtstoasc " Then
' MaxDL = 2
'ElseIf ffmpeg_command = " -c:v libx265 -preset fast -b:v 6M -bsf:a aac_adtstoasc " Then
' MaxDL = 1
'End If
Try
Dim rkg As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\CRDownloader")
Reso = Integer.Parse(rkg.GetValue("Resu").ToString)
'MsgBox(Resu)
Catch ex As Exception
End Try
Try
Dim rkg As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\CRDownloader")
AoD_Reso = Integer.Parse(rkg.GetValue("AoD_Reso").ToString)
Catch ex As Exception
AoD_Reso = 0
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")
' SubFunimation = rkg.GetValue("Fun_Sub").ToString
'Catch ex As Exception
'End Try
Try
Dim rkg As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\CRDownloader")
SubFunimationString = rkg.GetValue("Fun_Sub").ToString
If SubFunimationString = "none" Then
Else
Dim SoftSubsStringSplit() As String = SubFunimationString.Split(New String() {","}, System.StringSplitOptions.RemoveEmptyEntries)
For i As Integer = 0 To SoftSubsStringSplit.Count - 1
SubFunimation.Add(SoftSubsStringSplit(i))
Next
End If
Catch ex As Exception
If SubFunimation.Count = 0 Then
SubFunimation.Add("en")
End If
End Try
Try
Dim rkg As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\CRDownloader")
SubFolder_Value = rkg.GetValue("SubFolder_Value").ToString
Catch ex As Exception
SubFolder_Value = SubFolder_Nothing
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")
CR_NameMethode = Integer.Parse(rkg.GetValue("CR_NameMethode").ToString)
Catch ex As Exception
CR_NameMethode = 0
End Try
Try
Dim rkg As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\CRDownloader")
ErrorTolerance = Integer.Parse(rkg.GetValue("ErrorTolerance").ToString)
Catch ex As Exception
ErrorTolerance = 0
End Try
Try
Dim rkg As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\CRDownloader")
MergeSubstoMP4 = CBool(Integer.Parse(rkg.GetValue("MergeMP4").ToString))
Catch ex As Exception
End Try
Try
Dim rkg As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\CRDownloader")
HybridMode = CBool(Integer.Parse(rkg.GetValue("HybridMode").ToString))
Catch ex As Exception
End Try
Try
Dim rkg As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\CRDownloader")
Funimation_srt = CBool(Integer.Parse(rkg.GetValue("Funimation_srt").ToString))
Catch ex As Exception
End Try
Try
Dim rkg As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\CRDownloader")
Funimation_vtt = CBool(Integer.Parse(rkg.GetValue("Funimation_vtt").ToString))
Catch ex As Exception
End Try
Try
Dim rkg As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\CRDownloader")
Funimation_dfxp = CBool(Integer.Parse(rkg.GetValue("Funimation_dfxp").ToString))
Catch ex As Exception
End Try
Try
Dim rkg As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\CRDownloader")
HardSubFunimation = rkg.GetValue("FunimationHardsub").ToString
Catch ex As Exception
End Try
Try
Dim rkg As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\CRDownloader")
DubFunimation = rkg.GetValue("FunimationDub").ToString
Catch ex As Exception
End Try
Try
Dim rkg As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\CRDownloader")
SaveLog = CBool(Integer.Parse(rkg.GetValue("SaveLog").ToString))
Catch ex As Exception
End Try
Try
Dim rkg As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\CRDownloader")
SaveLog = CBool(Integer.Parse(rkg.GetValue("SaveLog").ToString))
Catch ex As Exception
End Try
#Region "removed softsubtitle"
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
#End Region
If Reso = Nothing Then
Reso = 1080
End If
If SubSprache = Nothing Then
SubSprache = "enUS"
End If
End Sub
Public Sub ListItemAdd(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 URL_DL As String, ByVal Pfad_DL As String, Optional Service As String = "CR") ', ByVal AudioLang As String)
Dim Thumbnail 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)
Thumbnail = System.Drawing.Image.FromStream(ms)
Catch ex As Exception
'MsgBox(ex.ToString)
'MsgBox(ThumbnialURL)
End Try
With ListView1.Items.Add(0)
ItemConstructor(NameP1, NameP2, Reso, HardSub, SoftSubs, Thumbnail, URL_DL, Pfad_DL, Service)
End With
End Sub
Public Sub ItemConstructor(ByVal NameP1 As String, ByVal NameP2 As String, ByVal DisplayReso As String, ByVal HardSub As String, ByVal SoftSubs As String, ByVal Thumbnail As Image, ByVal URL_DL As String, ByVal Pfad_DL As String, ByVal Service As String)
Dim Item As New CRD_List_Item
Item.Visible = False
Item.Parent = ListView1
Item.Width = 838
Item.Height = 142
#Region "Set Variables"
'Item.SetUsedMap(UsedMap)
Item.Setffmpeg_command(ffmpeg_command)
Item.SetMergeSubstoMP4(MergeSubstoMP4)
Item.SetDebug2(Debug2)
Item.SetSaveLog(SaveLog)
#End Region
Dim r As Rectangle
Dim c As Integer = ListView1.Items.Count - 1
r = ListView1.Items(c).Bounds()
r.Width = 838
r.Height = 142
Item.SetService(Service)
Item.SetTolerance(ErrorTolerance)
Item.SetTargetReso(Reso)
Item.SetLabelWebsite(NameP1)
Item.SetLabelAnimeTitel(NameP2)
Item.SetLabelResolution(DisplayReso)
Item.SetLabelHardsub(HardSub)
Item.SetThumbnailImage(Thumbnail)
Item.SetLabelPercent("0%")
Item.SetToolTip("Softsubs: " + SoftSubs)
'MsgBox(Item.GetTextBound.ToString)
ItemList.Add(Item)
Item.SetBounds(r.X, r.Y, r.Width, r.Height)
'Item.SetLocations(r.Y)
'MsgBox("test " + r.Y.ToString)
Item.Visible = True
Dim TempHybridMode As Boolean = HybridMode
If InStr(URL_DL, ".mpd") Then
TempHybridMode = False
End If
Item.StartDownload(URL_DL, Pfad_DL, Pfad_DL, TempHybridMode)
End Sub
#Region "Manga DL"
Public Sub MangaListItemAdd(ByVal NameP2 As String, ByVal ThumbnialURL As String, ByVal BaseURL As String, ByVal SiteList As List(Of String))
Dim Thumbnail As Image = My.Resources.main_del
Try
Dim wc As New WebClient()
wc.Headers.Add(My.Resources.ffmpeg_user_agend.Replace(Chr(34), ""))
Dim bytes As Byte() = wc.DownloadData(ThumbnialURL)
Dim ms As New MemoryStream(bytes)
Thumbnail = System.Drawing.Image.FromStream(ms)
Catch ex As Exception
'MsgBox(ex.ToString)
'MsgBox(ThumbnialURL)
End Try
With ListView1.Items.Add(0)
MangaItemConstructor("proxer.me", NameP2, Thumbnail, BaseURL, SiteList)
End With
End Sub
Public Sub MangaItemConstructor(ByVal NameP1 As String, ByVal NameP2 As String, ByVal Thumbnail As Image, ByVal BaseURL As String, ByVal SiteList As List(Of String))
Dim Item As New CRD_List_Item
Item.Visible = False
Item.Parent = ListView1
Item.Width = 838
Item.Height = 142
#Region "Set Variables"
Item.SetDebug2(Debug2)
#End Region
Dim r As Rectangle
Dim c As Integer = ListView1.Items.Count - 1
r = ListView1.Items(c).Bounds()
r.Width = 838
r.Height = 142
Item.SetLabelWebsite(NameP1)
Item.SetLabelAnimeTitel(NameP2)
Item.SetLabelResolution("Manga")
Item.SetLabelHardsub("Manga")
Item.SetThumbnailImage(Thumbnail)
Item.SetLabelPercent("0%")
'MsgBox(Item.GetTextBound.ToString)
ItemList.Add(Item)
Item.SetBounds(r.X, r.Y, r.Width, r.Height)
'Item.SetLocations(r.Y)
'MsgBox("test " + r.Y.ToString)
Item.Visible = True
Item.DownloadMangaPages(Pfad, BaseURL, SiteList, NameP2)
End Sub
#End Region
#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 = 0
Aktuell = "0"
If Anime_Add.comboBox4.SelectedIndex > Anime_Add.comboBox3.SelectedIndex Or Anime_Add.comboBox4.SelectedIndex = Anime_Add.comboBox3.SelectedIndex Then
c = Anime_Add.comboBox4.SelectedIndex - Anime_Add.comboBox3.SelectedIndex + 1
Else
Dim TempCB3 As Integer = Anime_Add.comboBox3.SelectedIndex
Dim TempCB4 As Integer = Anime_Add.comboBox4.SelectedIndex
Anime_Add.comboBox3.SelectedIndex = TempCB4
Anime_Add.comboBox4.SelectedIndex = TempCB3
c = Anime_Add.comboBox4.SelectedIndex - Anime_Add.comboBox3.SelectedIndex + 1
End If
Gesamt = c.ToString
For i As Integer = Anime_Add.comboBox3.SelectedIndex To Anime_Add.comboBox4.SelectedIndex
For e As Integer = 0 To Integer.MaxValue
'FontLabel.Visible = True
'FontLabel.Text = RunningDownloads
If Grapp_RDY = True Then
If RunningDownloads < MaxDL Then
Exit For
Else
'MsgBox(e)
Await Task.Delay(1000)
End If
Else
Await Task.Delay(5000)
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() {""}, System.StringSplitOptions.RemoveEmptyEntries)
Dim Titel2 As String() = Titel(0).Split(New String() {">"}, System.StringSplitOptions.RemoveEmptyEntries)
'MsgBox(Titel2(0))
einstellungen.ComboBox2.Items.Add(Titel2(1))
Next
End Sub
Public Sub DownloadSubsOnly()
'Try
'Throw New System.Exception("Test")
DlSoftSubsRDY = False
Dim CR_Anime_Titel As String = Nothing
Dim CR_Anime_Staffel As String = Nothing
Dim CR_Anime_Folge As String = Nothing
#Region "Name + Pfad"
Dim Pfad2 As String = Nothing
Dim CR_FilenName As String = Nothing
'Dim SubfolderValue As String = Nothing
Dim CR_FilenName_Backup As String = Nothing
#Region "Name von Crunchyroll"
Dim Bug_Deutsch As String = "-"
If CBool(InStr(WebbrowserTitle, "Anschauen auf Crunchyroll")) Then
Bug_Deutsch = ":"
End If
Dim CR_Name_by_Titel_2 As String() = WebbrowserTitle.Split(New String() {Bug_Deutsch}, System.StringSplitOptions.RemoveEmptyEntries)
Dim CR_Title As String = Nothing
If CR_Name_by_Titel_2.Count > 2 Then
For i As Integer = 0 To CR_Name_by_Titel_2.Count - 2
If CR_Title = Nothing Then
CR_Title = CR_Name_by_Titel_2(i).Trim()
Else
CR_Title = CR_Title + " " + CR_Name_by_Titel_2(i).Trim()
End If
Next
End If
CR_FilenName = CR_Title
CR_FilenName_Backup = CR_Title
'MsgBox(CR_FilenName)
If CBool(InStr(WebbrowserText, "")) Then ' false on movie true on series
Dim CR_Name_1 As String() = WebbrowserText.Split(New String() {"
"}, System.StringSplitOptions.RemoveEmptyEntries)
'CR_Name_Anime0(0) = System.Text.RegularExpressions.Regex.Replace(CR_Name_Anime0(0), "[^\w\\-]", " ")
CR_Name_Anime0(0) = HtmlDecode(CR_Name_Anime0(0))
CR_Name_Anime0(0) = String.Join(" ", CR_Name_Anime0(0).Split(invalids, StringSplitOptions.RemoveEmptyEntries)).TrimEnd("."c)
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
CR_FilenName = String.Join(" ", CR_FilenName.Split(invalids, StringSplitOptions.RemoveEmptyEntries)).TrimEnd("."c) 'System.Text.RegularExpressions.Regex.Replace(CR_FilenName, "[^\w\\-]", " ")
CR_FilenName = RemoveExtraSpaces(CR_FilenName)
Pfad2 = UseSubfolder(CR_Anime_Titel, CR_Anime_Staffel, Pfad)
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 + CR_FilenName + ".mp4" + Chr(34)
#End Region
#Region "Subs"
'MsgBox(TempSoftSubs.Count.ToString)
Dim SoftSubs2 As New List(Of String)
If SoftSubs.Count > 0 Then
For i As Integer = 0 To SoftSubs.Count - 1
Dim ii As Integer = i
If CBool(InStr(WebbrowserText, Chr(34) + "language" + Chr(34) + ":" + Chr(34) + SoftSubs(i) + Chr(34) + ",")) Then
SoftSubs2.Add(SoftSubs(i))
Else
Me.Invoke(New Action(Function()
einstellungen.StatusLabel.Text = "Status: language " + HardSubValuesToDisplay(Chr(34) + SoftSubs(ii) + Chr(34)) + " not found."
Pause(10)
Return Nothing
End Function))
End If
Next
ElseIf TempSoftSubs.Count > 0 Then
For i As Integer = 0 To TempSoftSubs.Count - 1
Dim ii As Integer = i
If CBool(InStr(WebbrowserText, Chr(34) + "language" + Chr(34) + ":" + Chr(34) + TempSoftSubs(i) + Chr(34) + ",")) Then
SoftSubs2.Add(TempSoftSubs(i))
Else
Me.Invoke(New Action(Function()
einstellungen.StatusLabel.Text = "Status: language " + HardSubValuesToDisplay(Chr(34) + TempSoftSubs(ii) + Chr(34)) + " not found."
Pause(10)
Return Nothing
End Function))
'MsgBox("Softsubtitle for " + SoftSubs(i) + " is not avalible.", MsgBoxStyle.Information)
End If
Next
End If
#End Region
If Grapp_Abord = True Then
Grapp_RDY = True
Grapp_Abord = False
'MsgBox("grapp_abourd")
Exit Sub
End If
#Region "Download softsub file"
If SoftSubs2.Count > 0 Then
For i As Integer = 0 To SoftSubs2.Count - 1
Dim ii As Integer = i
Try
Me.Invoke(New Action(Function()
einstellungen.StatusLabel.Text = "Status: downloading - " + HardSubValuesToDisplay(Chr(34) + SoftSubs2(ii) + Chr(34))
Pause(1)
Return Nothing
End Function))
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)
Catch ex As Exception
Me.Invoke(New Action(Function()
einstellungen.StatusLabel.Text = "Status: failed - " + HardSubValuesToDisplay(Chr(34) + SoftSubs2(ii) + Chr(34))
Pause(3)
Return Nothing
End Function))
End Try
Next
Else
Me.Invoke(New Action(Function()
einstellungen.StatusLabel.Text = "Status: No language selected"
Pause(10)
Return Nothing
End Function))
End If
#End Region
DlSoftSubsRDY = True
Me.Invoke(New Action(Function()
einstellungen.StatusLabel.Text = "Status: idle"
Return Nothing
End Function))
'Catch ex As Exception
'End Try
End Sub
Public Async Sub MassSubsDL()
If einstellungen.comboBox3.Text = Nothing Then
Exit Sub
ElseIf einstellungen.comboBox4.Text = Nothing Then
Exit Sub
End If
einstellungen.SoftSubsMass.Text = "preparing ..."
Dim Website As String = WebbrowserText
If einstellungen.ComboBox2.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) + ">" + einstellungen.ComboBox2.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 = einstellungen.comboBox4.SelectedIndex - einstellungen.comboBox3.SelectedIndex + 1
'AnzahlGesamt.Text = c.ToString
Gesamt = c.ToString
Aktuell = "0"
If einstellungen.comboBox4.SelectedIndex > einstellungen.comboBox3.SelectedIndex Then
For i As Integer = einstellungen.comboBox3.SelectedIndex To einstellungen.comboBox4.SelectedIndex
For e As Integer = 0 To Integer.MaxValue
If DlSoftSubsRDY = True Then
Exit For
Else
Await Task.Delay(2000)
End If
Next
Dim dd As Integer = i - einstellungen.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\\-]", " ")
CR_Anime_Folge = String.Join(" ", CR_Anime_Folge.Split(invalids, StringSplitOptions.RemoveEmptyEntries)).TrimEnd("."c)
'MsgBox(CR_Anime_Folge)
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\\-]", " ")
CR_Anime_Folge = String.Join(" ", CR_Anime_Folge.Split(invalids, StringSplitOptions.RemoveEmptyEntries)).TrimEnd("."c)
'MsgBox(CR_Anime_Folge)
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)
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)
CR_Anime_Folge = String.Join(" ", CR_Anime_Folge.Split(invalids, StringSplitOptions.RemoveEmptyEntries)).TrimEnd("."c) 'System.Text.RegularExpressions.Regex.Replace(CR_Anime_Folge, "[^\w\\-]", " ")
Else
CR_Anime_Staffel = Nothing
CR_Anime_Folge = CR_Name_2(0).Trim()
'MsgBox(CR_Anime_Folge)
CR_Anime_Folge = String.Join(" ", CR_Anime_Folge.Split(invalids, StringSplitOptions.RemoveEmptyEntries)).TrimEnd("."c) '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) = String.Join(" ", CR_Name_Anime0(0).Split(invalids, StringSplitOptions.RemoveEmptyEntries)).TrimEnd("."c) 'System.Text.RegularExpressions.Regex.Replace(CR_Name_Anime0(0), "[^\w\\-]", " ")
CR_Anime_Titel = CR_Name_Anime0(0).Trim
'CR_FilenName_Backup = RemoveExtraSpaces(CR_FilenName)
End If
If CBool(InStr(WebbrowserText, My.Resources.CR_MediaName)) = True Then ' And CBool(InStr(WebbrowserText, "”"))
Dim CR_Name_1 As String() = WebbrowserText.Split(New String() {My.Resources.CR_MediaName}, System.StringSplitOptions.RemoveEmptyEntries)
Dim CR_Name_2 As String() = CR_Name_1(1).Split(New String() {My.Resources.CR_MediaName2}, System.StringSplitOptions.RemoveEmptyEntries) '(New [Char]() {"-"})
CR_Anime_Name = String.Join(" ", CR_Name_2(0).Split(invalids, StringSplitOptions.RemoveEmptyEntries)).TrimEnd("."c) 'System.Text.RegularExpressions.Regex.Replace(CR_Name_2(0), "[^\w\\-]", " ")
CR_Anime_Name = RemoveExtraSpaces(CR_Anime_Name)
End If
If CR_NameMethode = 0 Then
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
ElseIf CR_NameMethode = 1 Then
If CR_Anime_Staffel = Nothing Then
CR_FilenName = CR_Anime_Titel + " " + CR_Anime_Name
Else
CR_FilenName = CR_Anime_Titel + " " + CR_Anime_Staffel + " " + CR_Anime_Name
End If
ElseIf CR_NameMethode = 2 Then
If CR_Anime_Staffel = Nothing Then
CR_FilenName = CR_Anime_Titel + " " + CR_Anime_Folge + " " + CR_Anime_Name
Else
CR_FilenName = CR_Anime_Titel + " " + CR_Anime_Staffel + " " + CR_Anime_Folge + " " + CR_Anime_Name
End If
End If
#End Region
If TextBox2_Text = Nothing Or TextBox2_Text = "Name of the Anime" Then
Else
CR_FilenName = RemoveExtraSpaces(String.Join(" ", TextBox2_Text.Split(invalids, StringSplitOptions.RemoveEmptyEntries)).TrimEnd("."c)) 'System.Text.RegularExpressions.Regex.Replace(TextBox2_Text, "[^\w\\-]", " "))
End If
CR_FilenName = String.Join(" ", CR_FilenName.Split(invalids, StringSplitOptions.RemoveEmptyEntries)).TrimEnd("."c) 'System.Text.RegularExpressions.Regex.Replace(CR_FilenName, "[^\w\\-]", " ")
CR_FilenName = RemoveExtraSpaces(CR_FilenName)
'My.Computer.FileSystem.WriteAllText("log.log", WebbrowserText, False)
Pfad2 = UseSubfolder(CR_Anime_Titel, CR_Anime_Staffel, Pfad)
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 + ".mp4"
End Try
End If
Pfad2 = Chr(34) + Pfad2 + CR_FilenName + ".mp4" + 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"
ErrorDialog.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"
ErrorDialog.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("\/", "/")
Dim dub() As String = hls_List(i).Split(New String() {Chr(34) + "audio_lang" + Chr(34) + ":" + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries)
Dim dub2() As String = dub(0).Split(New String() {Chr(34) + ","}, System.StringSplitOptions.RemoveEmptyEntries)
CR_Anime_Dub = dub2(0)
'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"
Me.Text = "Status: m3u8 found, looking for resolution"
Me.Invalidate()
Return Nothing
End Function))
Else
Throw New System.Exception("Premium Episode")
End If
#End Region
#Region "Download softsub file or build ffmpeg cmd"
Dim SoftSubMergeURLs As String = Nothing
Dim SoftSubMergeMaps As String = " -map 0:v -map 0:a"
Dim SoftSubMergeMetatata As String = Nothing
If SoftSubs2.Count > 0 Then
If MergeSubstoMP4 = True Then
For i As Integer = 0 To SoftSubs2.Count - 1
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("\/", "/")
If SoftSubMergeURLs = Nothing Then
SoftSubMergeURLs = " -i " + Chr(34) + SoftSub_3 + Chr(34)
Else
SoftSubMergeURLs = SoftSubMergeURLs + " -i " + Chr(34) + SoftSub_3 + Chr(34)
End If
SoftSubMergeMaps = SoftSubMergeMaps + " -map " + (i + 1).ToString
If SoftSubMergeMetatata = Nothing Then
SoftSubMergeMetatata = " -metadata:s:s:" + i.ToString + " language=" + CCtoMP4CC(SoftSubs2(i)) + " -metadata:s:s:" + i.ToString + " title=" + Chr(34) + HardSubValuesToDisplay(Chr(34) + SoftSubs2(i) + Chr(34)) + Chr(34) + " -metadata:s:s:" + i.ToString + " handler_name=" + Chr(34) + HardSubValuesToDisplay(Chr(34) + SoftSubs2(i) + Chr(34)) + Chr(34)
Else
SoftSubMergeMetatata = SoftSubMergeMetatata + " -metadata:s:s:" + i.ToString + " language=" + CCtoMP4CC(SoftSubs2(i)) + " -metadata:s:s:" + i.ToString + " title=" + Chr(34) + HardSubValuesToDisplay(Chr(34) + SoftSubs2(i) + Chr(34)) + Chr(34) + " -metadata:s:s:" + i.ToString + " handler_name=" + Chr(34) + HardSubValuesToDisplay(Chr(34) + SoftSubs2(i) + Chr(34)) + Chr(34)
End If
Next
Else
For i As Integer = 0 To SoftSubs2.Count - 1
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
'SoftSubMergeMetatata = SoftSubMergeMetatata + " -disposition:s:0 default"
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
Me.Invoke(New Action(Function()
Anime_Add.StatusLabel.Text = "Status: The file video already exists."
Me.Text = "Status: The file video already exists."
Me.Invalidate()
Return Nothing
End Function))
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 Reso = 42 And HybridMode = False Then
If MergeSubstoMP4 = True Then
URL_DL = "-i " + Chr(34) + CR_URI_Master + Chr(34) + SoftSubMergeURLs + SoftSubMergeMaps + " " + ffmpeg_command + " -c:s mov_text" + SoftSubMergeMetatata + " -metadata:s:a:0 language=" + CCtoMP4CC(CR_Anime_Dub)
Else
URL_DL = "-i " + Chr(34) + CR_URI_Master + Chr(34) + " -metadata:s:a:0 language=" + CCtoMP4CC(CR_Anime_Dub) + " " + ffmpeg_command
End If
'MsgBox(URL_DL)
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" + Reso.ToString + ",")) Then
Reso2 = "x" + Reso.ToString
Else
'MsgBox(str)
If CBool(InStr(str, ResoSave + ",")) Then
Reso2 = Reso2
Else
Me.Invoke(New Action(Function()
DialogTaskString = "Resolution"
ResoNotFoundString = str
ErrorDialog.ShowDialog()
Return Nothing
End Function))
'MsgBox(ResoBackString)
If UserCloseDialog = True Then
Throw New System.Exception(Chr(34) + "UserAbort" + Chr(34))
Else
Reso2 = ResoBackString
ResoSave = ResoBackString
End If
End If
End If
#Region "old non gzip fix"
'MsgBox(Reso2)
' Dim VLC_URI_1 As String() = str.Split(New String() {Reso2 + ","}, 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("#")})
' If MergeSubstoMP4 = True Then
' URL_DL = "-i " + Chr(34) + VLC_URI_3(0).Trim() + Chr(34) + SoftSubMergeURLs + SoftSubMergeMaps + " " + ffmpeg_command + " -c:s mov_text" + SoftSubMergeMetatata + " -metadata:s:a:0 language=" + CCtoMP4CC(CR_Anime_Dub)
' 'URL_DL = "-i " + Chr(34) + VLC_URI_3(0).Trim() + Chr(34) + SoftSubMergeURLs + SoftSubMergeMaps + " " + ffmpeg_command + " -c:s mov_text" + SoftSubMergeMetatata
' Else
' URL_DL = "-i " + Chr(34) + VLC_URI_3(0).Trim() + Chr(34) + " -metadata:s:a:0 language=" + CCtoMP4CC(CR_Anime_Dub) + " " + ffmpeg_command
' 'URL_DL = VLC_URI_3(0).Trim()
' End If
' 'MsgBox(URL_DL)
'End If
#End Region
#Region "gzip fix - no cloudfront cdn"
Dim ffmpeg_url_1 As String() = str.Split(New String() {Reso2 + ","}, System.StringSplitOptions.RemoveEmptyEntries)
Dim ffmpeg_url_3 As String() = Nothing
'MsgBox(ffmpeg_url_1.Count.ToString)
If ffmpeg_url_1.Count > 2 Then
If InStr(ffmpeg_url_1(1), "&cdn=cloudfront-prod") Then
Dim ffmpeg_url_2 As String() = ffmpeg_url_1(2).Split(New [Char]() {Chr(34)})
ffmpeg_url_3 = ffmpeg_url_2(2).Split(New [Char]() {System.Convert.ToChar("#")})
Else
Dim ffmpeg_url_2 As String() = ffmpeg_url_1(1).Split(New [Char]() {Chr(34)})
ffmpeg_url_3 = ffmpeg_url_2(2).Split(New [Char]() {System.Convert.ToChar("#")})
End If
Else
Dim ffmpeg_url_2 As String() = ffmpeg_url_1(1).Split(New [Char]() {Chr(34)})
ffmpeg_url_3 = ffmpeg_url_2(2).Split(New [Char]() {System.Convert.ToChar("#")})
End If
If MergeSubstoMP4 = True Then
URL_DL = "-i " + Chr(34) + ffmpeg_url_3(0).Trim() + Chr(34) + SoftSubMergeURLs + SoftSubMergeMaps + " " + ffmpeg_command + " -c:s mov_text" + SoftSubMergeMetatata + " -metadata:s:a:0 language=" + CCtoMP4CC(CR_Anime_Dub)
'URL_DL = "-i " + Chr(34) + VLC_URI_3(0).Trim() + Chr(34) + SoftSubMergeURLs + SoftSubMergeMaps + " " + ffmpeg_command + " -c:s mov_text" + SoftSubMergeMetatata
Else
URL_DL = "-i " + Chr(34) + ffmpeg_url_3(0).Trim() + Chr(34) + " -metadata:s:a:0 language=" + CCtoMP4CC(CR_Anime_Dub) + " " + ffmpeg_command
'URL_DL = VLC_URI_3(0).Trim()
End If
'MsgBox(URL_DL)
End If
#End Region
#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 "