//Returns VideoInfo object (Only for video model) public static VideoInfo GetVideoInfo(YoutubeVideoModel videoModel) { //Select the first .mp4 video with 360p resolution VideoInfo video = videoModel.VideoInfo.First(info => info.VideoType == VideoType.Mp4 && info.Resolution == 360); 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; }
private void DownloadVideo(YoutubeVideoModel videoDownloader) { try { //Stores FilePath in model videoDownloader.FilePath = FileDownloader.GetPath(videoDownloader); videoDownloader.FilePath += videoDownloader.Video.VideoExtension; //Stores VideoDownloaderType object in model videoDownloader.VideoDownloaderType = FileDownloader.GetVideoDownloader(videoDownloader); //Call DownloadList method until all items in list are downloaded videoDownloader.VideoDownloaderType.DownloadFinished += (sender, args) => this.mDownloadComplete = true; //Link progress bar up to download progress videoDownloader.VideoDownloaderType.DownloadProgressChanged += (sender, args) => { if (this.pgbDownload.InvokeRequired) { this.pgbDownload.Invoke(new MethodInvoker(delegate() { this.pgbDownload.Value = (int)args.ProgressPercentage; })); } else { this.pgbDownload.Value = (int)args.ProgressPercentage; } }; //Download video FileDownloader.DownloadVideo(videoDownloader); } catch (Exception) { MessageBox.Show("Download cancelled"); } }
//Downloads Video (Only for video model) public static void DownloadVideo(YoutubeVideoModel vidDownloader) { Task.Run(() => vidDownloader.VideoDownloaderType.Execute()); }
//Returns VideoDownloader object (Only for video model) public static VideoDownloader GetVideoDownloader(YoutubeVideoModel videoModel) { return(new VideoDownloader(videoModel.Video, videoModel.FilePath)); }