private static void DownloadImageWDefaultFolder(WebClient webClient, string url) { if (Validator.IsValidDefaultFolder()) { webClient.DownloadFile(new Uri(url), DefaultFolder.GetDefaultPath() + @"\" + GenerateRandomName.Generate() + ".jpeg"); return; } else { Console.WriteLine("You still doesn't configured a default folder path. Try '" + Strings.SETPATH + "'!"); } }
//download mp4 and mp3 private static void DownloadMP4MP3WDefaultFolder(string url, string folder) { if (!DefaultFolder.DefaultPathExists()) { Console.WriteLine("You still doesn't configured a default folder path. Try '" + Strings.SETPATH + "'!"); return; } if (Validator.IsValidDefaultFolder()) { var youtube = YouTube.Default; var video = youtube.GetVideo(url); /* When user copy/paste the path, Windows doesn't put the last '\'. Ex.: (C:\Users\User\Documents). * So the '\' is added, */ folder = DefaultFolder.GetDefaultPath() + @"\"; File.WriteAllBytes(folder + video.FullName, video.GetBytes()); var MP4Video = new MediaFile { Filename = folder + video.FullName }; var MP3Audio = new MediaFile { Filename = folder + video.FullName + ".mp3" }; using (var engine = new Engine()) { engine.GetMetadata(MP4Video); engine.Convert(MP4Video, MP3Audio); } } }
// Default path validations; public static bool IsValidDefaultFolder() { return(DefaultFolder.GetDefaultPath().Length > 0); }