From 90d2dc1f9e287666cfb9e7cd2fc4781938776735 Mon Sep 17 00:00:00 2001 From: Git Date: Thu, 18 Oct 2018 18:20:55 +0200 Subject: [PATCH] MP3 Downloader Added --- YTDownloader/Form1.cs | 28 +++++++++++++++++++++++++++- YTDownloader/YTDownloader.csproj | 3 +++ YTDownloader/packages.config | 1 + 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/YTDownloader/Form1.cs b/YTDownloader/Form1.cs index a486be9..efe88d6 100644 --- a/YTDownloader/Form1.cs +++ b/YTDownloader/Form1.cs @@ -2,6 +2,8 @@ using System.IO; using System.Windows.Forms; using VideoLibrary; +using MediaToolkit; +using MediaToolkit.Model; namespace YTDownloader { @@ -55,7 +57,31 @@ public void button2_Click(object sender, EventArgs e) private void button3_Click(object sender, EventArgs e) { - MessageBox.Show("Coming Soon..."); + string path = label2.Text; + string link = textBox1.Text; + if (link == "Paste link here") + { + MessageBox.Show("Please input a youtube video URL"); + } + else + { + var youtube = YouTube.Default; + var vid = youtube.GetVideo(link); + string mp4filepath = path + vid.FullName; + File.WriteAllBytes(path + vid.FullName, vid.GetBytes()); + + var inputFile = new MediaFile { Filename = path + vid.FullName }; + var outputFile = new MediaFile { Filename = $"{path + vid.FullName}.mp3" }; + + using (var engine = new Engine()) + { + engine.GetMetadata(inputFile); + engine.Convert(inputFile, outputFile); + File.Delete(mp4filepath); + MessageBox.Show("Downloaded!"); + } + } + } } } diff --git a/YTDownloader/YTDownloader.csproj b/YTDownloader/YTDownloader.csproj index 15c590a..79e8bfd 100644 --- a/YTDownloader/YTDownloader.csproj +++ b/YTDownloader/YTDownloader.csproj @@ -55,6 +55,9 @@ ..\packages\VideoLibrary.2.0.2\lib\netstandard1.1\libvideo.dll + + ..\packages\MediaToolkit.1.1.0.1\lib\net40\MediaToolkit.dll + ..\packages\Newtonsoft.Json.6.0.6\lib\net45\Newtonsoft.Json.dll True diff --git a/YTDownloader/packages.config b/YTDownloader/packages.config index f82f2ec..164c08f 100644 --- a/YTDownloader/packages.config +++ b/YTDownloader/packages.config @@ -2,6 +2,7 @@ +