Imports System.ComponentModel Imports System.IO Imports System.Net Imports VideoLibrary Public Class YouTube_Downloader Dim folder As String Dim drive As Integer = 0 Private Sub YouTube_Downloader_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim lines1a() As String = File.ReadAllLines(théme) If lines1a(0) = 2 Then Me.BackColor = Color.FromArgb(64, 64, 64) Button1.BackColor = Color.FromArgb(64, 64, 64) Button1.ForeColor = Color.White Label1.ForeColor = Color.White TextBox1.BackColor = Color.FromArgb(64, 64, 64) TextBox1.ForeColor = Color.White ElseIf lines1a(0) = 3 Then Me.BackColor = Color.FromArgb(Form1.colorbackA, Form1.colorbackR, Form1.colorbackG, Form1.colorbackB) Button1.BackColor = Color.FromArgb(Form1.colorbackA, Form1.colorbackR, Form1.colorbackG, Form1.colorbackB) Button1.ForeColor = Color.FromArgb(Form1.themeforecoloA, Form1.themeforecoloR, Form1.themeforecoloG, Form1.themeforecoloB) Label1.ForeColor = Color.FromArgb(Form1.themeforecoloA, Form1.themeforecoloR, Form1.themeforecoloG, Form1.themeforecoloB) TextBox1.BackColor = Color.FromArgb(Form1.colorbackA, Form1.colorbackR, Form1.colorbackG, Form1.colorbackB) TextBox1.ForeColor = Color.FromArgb(Form1.themeforecoloA, Form1.themeforecoloR, Form1.themeforecoloG, Form1.themeforecoloB) End If Dim lines1() As String = File.ReadAllLines(comtpeco2) If lines1(0) = 1 Then Dim maj As New WebClient Dim vri As String = maj.DownloadString("http://lecteur.lecteur-media.fr/lecteur/server%20temps.txt") If vri = 1 Then If FolderBrowserDialog1.ShowDialog = 1 Then folder = FolderBrowserDialog1.SelectedPath Label1.Text = Label1.Text & " " & folder TextBox1.Text = Clipboard.GetText Else Close() End If Else Dim msg = MsgBox("Voulez-vous enregistrer cette vidéo sur votre drive", MsgBoxStyle.YesNo) If msg = MsgBoxResult.Yes Then Label1.Text = "Sur votre drive" drive = 1 Else If FolderBrowserDialog1.ShowDialog = 1 Then folder = FolderBrowserDialog1.SelectedPath Label1.Text = Label1.Text & " " & folder TextBox1.Text = Clipboard.GetText Else Close() End If End If End If Else If FolderBrowserDialog1.ShowDialog = 1 Then folder = FolderBrowserDialog1.SelectedPath Label1.Text = Label1.Text & " " & folder TextBox1.Text = Clipboard.GetText Else Close() End If End If End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click If TextBox1.Text = "" Then MsgBox("Merci entrer une url", MsgBoxStyle.Information) Else If drive = 1 Then SaveVideoToDisk2(TextBox1.Text) Else SaveVideoToDisk(TextBox1.Text) End If End If End Sub Sub SaveVideoToDisk(ByVal link As String) Try Dim video = YouTube.Default.GetVideo(link) If File.Exists(FolderBrowserDialog1.SelectedPath & "\" & video.FullName) = True Then MsgBox("Le ficher: " & FolderBrowserDialog1.SelectedPath & "\" & video.FullName & " existe déjà", MsgBoxStyle.Exclamation) Else Me.Text = "Téléchargement de: " & video.FullName File.WriteAllBytes(FolderBrowserDialog1.SelectedPath & "\" & video.FullName, video.GetBytes()) MsgBox("La vidéo: " & video.FullName & " a bien été télécharger", MsgBoxStyle.Information) TextBox1.Clear() Dim ov = MsgBox("Voulez-vous ouvrir la vidéo sur le lecteur média", MsgBoxStyle.YesNo) If ov = MsgBoxResult.Yes Then Form1.TextBox1.Clear() Form1.TextBox1.Text = "youtube" Dim sw4 As New StreamWriter(historique) Form1.AxWindowsMediaPlayer1.URL = FolderBrowserDialog1.SelectedPath & "\" & video.FullName Form1.PictureBox1.Hide() Form1.Text = "lecteur média: " & Form1.AxWindowsMediaPlayer1.currentMedia.name Form1.NotifyIcon1.BalloonTipTitle = "lecteur média" Form1.NotifyIcon1.BalloonTipText = "vous regarder:" & " " & Form1.AxWindowsMediaPlayer1.currentMedia.name Form1.NotifyIcon1.ShowBalloonTip(1) Form1.PictureBox2.Hide() Form1.PictureBox7.Hide() Form1.PictureBox1.Hide() Form1.PictureBox4.Show() Form1.VitesseToolStripMenuItem.Enabled = True Form1.AllaiAToolStripMenuItem.Enabled = True Form1.PictureBox5.Enabled = True Form1.PictureBox6.Enabled = True Form1.PictureBox7.Enabled = True Form1.PictureBox4.Enabled = True Form1.PauseToolStripMenuItem.Enabled = True Form1.StopToolStripMenuItem.Enabled = True Form1.PleinToolStripMenuItem.Enabled = True Button1.Enabled = True Form1.ListBox1.Items.Add(Form1.AxWindowsMediaPlayer1.currentMedia.name & " : " & Today & " : " & TimeOfDay) For Each item In Form1.ListBox1.Items sw4.WriteLine(item) Next sw4.Close() Close() Else End If Close() End If Catch ex As Exception MsgBox("Une erreur est survenue merci de ressayer plus tard", MsgBoxStyle.Exclamation) Close() End Try End Sub Private Sub YouTube_Downloader_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing TextBox1.Clear() Label1.Text = "" Me.Text = "YouTube Downloader" End Sub Private Sub TextBox1_Click(sender As Object, e As EventArgs) Handles TextBox1.Click TextBox1.Text = Clipboard.GetText End Sub Private Sub YouTube_Downloader_Click(sender As Object, e As EventArgs) Handles Me.Click TextBox1.Text = Clipboard.GetText End Sub Sub SaveVideoToDisk2(ByVal link As String) Dim lines1() As String = File.ReadAllLines(compteco) Try Dim video = YouTube.Default.GetVideo(link) If File.Exists(compte & "\" & video.FullName) = True Then MsgBox("Le ficher: " & compte & "\" & video.FullName & " existe déjà", MsgBoxStyle.Exclamation) Else Me.Text = "Téléchargement de: " & video.FullName File.WriteAllBytes(compte & "\" & video.FullName, video.GetBytes()) Me.Text = "Importation de: " & video.FullName My.Computer.Network.UploadFile(compte & video.FullName, ipserver & "/utilisateur/" & lines1(0) & "/Dirve/" & video.FullName) File.Delete(compte & video.FullName) MsgBox("La vidéo: " & video.FullName & " a bien été importer sur votre drive", MsgBoxStyle.Information) Dim ov = MsgBox("Voulez-vous ouvrir la vidéo sur le lecteur média", MsgBoxStyle.YesNo) If ov = MsgBoxResult.Yes Then Form1.TextBox1.Clear() Form1.TextBox1.Text = "youtube" Dim sw4 As New StreamWriter(historique) Form1.AxWindowsMediaPlayer1.URL = ipsite & "/utilisateur/" & lines1(0) & "/Dirve/" & video.FullName Form1.PictureBox1.Hide() Form1.Text = "lecteur média: " & Form1.AxWindowsMediaPlayer1.currentMedia.name Form1.NotifyIcon1.BalloonTipTitle = "lecteur média" Form1.NotifyIcon1.BalloonTipText = "vous regarder:" & " " & Form1.AxWindowsMediaPlayer1.currentMedia.name Form1.NotifyIcon1.ShowBalloonTip(1) Form1.PictureBox2.Hide() Form1.PictureBox7.Hide() Form1.PictureBox1.Hide() Form1.PictureBox4.Show() Form1.VitesseToolStripMenuItem.Enabled = True Form1.AllaiAToolStripMenuItem.Enabled = True Form1.PictureBox5.Enabled = True Form1.PictureBox6.Enabled = True Form1.PictureBox7.Enabled = True Form1.PictureBox4.Enabled = True Form1.PauseToolStripMenuItem.Enabled = True Form1.StopToolStripMenuItem.Enabled = True Form1.PleinToolStripMenuItem.Enabled = True Button1.Enabled = True Form1.ListBox1.Items.Add(Form1.AxWindowsMediaPlayer1.currentMedia.name & " : " & Today & " : " & TimeOfDay) For Each item In Form1.ListBox1.Items sw4.WriteLine(item) Next sw4.Close() Close() Else End If Close() End If Catch ex As Exception MsgBox("Une erreur est survenue merci de ressayer plus tard", MsgBoxStyle.Exclamation) Close() End Try End Sub End Class