//Returns VideoInfo object (Only for audio model) public static VideoInfo GetVideoInfoAudioOnly(YoutubeAudioModel audioModel) { //We want the first extractable video with the highest audio quality. VideoInfo video = audioModel.VideoInfo .Where(info => info.CanExtractAudio) .OrderByDescending(info => info.AudioBitrate) .First(); return(video); }
private void CreateVideoOrAudioObject(string aLink) { this.Cursor = Cursors.WaitCursor; if (this.GetDownloadType().Equals(LHJ.Common.Definition.ConstValue.YoutubeDownloaderDownloadType.Video)) { //Create new videoDownloader object YoutubeVideoModel videoDownloader = new YoutubeVideoModel(); //Set videoDownloader properties videoDownloader.Link = this.tbxYoutubeUrl.Text; videoDownloader.FolderPath = this.tbxDownloadPath.Text; //Store VideoInfo object in model videoDownloader.VideoInfo = FileDownloader.GetVideoInfos(videoDownloader); //Stores VideoInfo object in model videoDownloader.Video = FileDownloader.GetVideoInfo(videoDownloader); UpdateDownloadList(videoDownloader, aLink); } //Create audio object else { //Create new audioDownloader object YoutubeAudioModel audioDownloader = new YoutubeAudioModel(); //Set AudioDownloader properties audioDownloader.Link = this.tbxYoutubeUrl.Text; audioDownloader.FolderPath = this.tbxDownloadPath.Text; //Store VideoInfo object in model audioDownloader.VideoInfo = FileDownloader.GetVideoInfos(audioDownloader); //Stores VideoInfo object in model audioDownloader.Video = FileDownloader.GetVideoInfoAudioOnly(audioDownloader); UpdateDownloadList(audioDownloader, aLink); } this.Cursor = Cursors.Default; }
//Downloads Audio (Only for Audio model) public static void DownloadAudio(YoutubeAudioModel audioModel) { Task.Run(() => audioModel.AudioDownloaderType.Execute()); }
//Returns AudioDownloader object (Only for audio model) public static AudioDownloader GetAudioDownloader(YoutubeAudioModel audioModel) { //Create AudioDownloader object return(new AudioDownloader(audioModel.Video, audioModel.FilePath)); }