Skip to content

Commit

Permalink
MP3 Downloader Added
Browse files Browse the repository at this point in the history
  • Loading branch information
theasern committed Oct 18, 2018
1 parent 62c81bd commit 90d2dc1
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
28 changes: 27 additions & 1 deletion YTDownloader/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using System.IO;
using System.Windows.Forms;
using VideoLibrary;
using MediaToolkit;
using MediaToolkit.Model;

namespace YTDownloader
{
Expand Down Expand Up @@ -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!");
}
}

}
}
}
3 changes: 3 additions & 0 deletions YTDownloader/YTDownloader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
<Reference Include="libvideo, Version=2.0.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\VideoLibrary.2.0.2\lib\netstandard1.1\libvideo.dll</HintPath>
</Reference>
<Reference Include="MediaToolkit, Version=1.1.0.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MediaToolkit.1.1.0.1\lib\net40\MediaToolkit.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.6.0.6\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
Expand Down
1 change: 1 addition & 0 deletions YTDownloader/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<packages>
<package id="Costura.Fody" version="3.1.4" targetFramework="net45" />
<package id="Fody" version="3.2.9" targetFramework="net45" developmentDependency="true" />
<package id="MediaToolkit" version="1.1.0.1" targetFramework="net45" />
<package id="Microsoft.NETCore.Platforms" version="1.1.0" targetFramework="net45" />
<package id="NETStandard.Library" version="1.6.1" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.6" targetFramework="net45" />
Expand Down

0 comments on commit 90d2dc1

Please sign in to comment.