private void DownloadVideo(YoutubeVideoModel videoDownloader) { try { //Updates lblUpdate to show title of video that is downloading UpdateLabel(videoDownloader.Video.Title + videoDownloader.Video.VideoExtension); //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) => DownloadList(); //Link progress bar up to download progress videoDownloader.VideoDownloaderType.DownloadProgressChanged += (sender, args) => progressBar1.Value = (int)args.ProgressPercentage; //Download video FileDownloader.DownloadVideo(videoDownloader); } catch (Exception) { MessageBox.Show("Download cancelled"); EnableAccessibility(); } }
private void Download(string validatedLink) { //Download video if ((int)cboFileType.SelectedIndex == 0) //Video is selected from dropdown list { //Create new videoDownloader object YoutubeVideoModel videoDownloader = new YoutubeVideoModel(); //Set videoDownloader properties videoDownloader.Link = validatedLink; videoDownloader.FolderPath = txtPath.Text; //Download video DownloadVideo(videoDownloader); } //Download audio else { //Create new audioDownloader object YoutubeAudioModel audioDownloader = new YoutubeAudioModel(); //Set AudioDownloader properties audioDownloader.Link = validatedLink; audioDownloader.FolderPath = txtPath.Text; //Download audio DownloadAudio(audioDownloader); } }
//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 Download() { //Download video if ((int)comboBox1.SelectedIndex == 0) //Video is selected from dropdown list { //Create new videoDownloader object YoutubeVideoModel videoDownloader = new YoutubeVideoModel(); //Set videoDownloader properties videoDownloader.Link = txtLink.Text; videoDownloader.FolderPath = txtPath.Text; //Download video DownloadVideo(videoDownloader); } else //Audio is selected from dropdown list { //Create new audioDownloader object YoutubeAudioModel audioDownloader = new YoutubeAudioModel(); //Set AudioDownloader properties audioDownloader.Link = txtLink.Text; audioDownloader.FolderPath = txtPath.Text; //Download audio DownloadAudio(audioDownloader); } }
private void DisplayLinks(string validatedLink) { //Create new videoDownloader object YoutubeVideoModel videoDownloader = new YoutubeVideoModel(); //Set videoDownloader properties videoDownloader.Link = validatedLink; //Get list of Video objects videoDownloader.VideoInfo = FileDownloader.GetVideoInfos(videoDownloader); //Get Youtube ID int length = videoDownloader.Link.Length; string ID = videoDownloader.Link.Substring(length - 11, 11); //Get Youtube Thumbnail //http://stackoverflow.com/questions/2068344/how-do-i-get-a-youtube-video-thumbnail-from-the-youtube-api string thumbnailURL = "http://img.youtube.com/vi/" + ID + "/1.jpg"; Label2.Text = "Right Click and Save As to Download<br/>"; Label2.Text += "<img src='" + thumbnailURL + "'>"; Label2.Text += videoDownloader.VideoInfo.First().Title + "<br/>"; ProcessLinks(videoDownloader.VideoInfo); }
private void Download(string validatedLink) { //Create new videoDownloader object YoutubeVideoModel videoDownloader = new YoutubeVideoModel(); //Set videoDownloader properties videoDownloader.Link = validatedLink; videoDownloader.FolderPath = txtPath.Text; //Download video DownloadVideo(videoDownloader); }
private void DisplayLinks(string validatedLink) { //Create new videoDownloader object YoutubeVideoModel videoDownloader = new YoutubeVideoModel(); //Set videoDownloader properties videoDownloader.Link = validatedLink; //Get video videoDownloader.VideoInfo = FileDownloader.GetVideoInfos(videoDownloader); Label2.Text = "Right Click and Save As to Download<br/>"; foreach (VideoInfo vi in videoDownloader.VideoInfo) { Label2.Text += "<a href=" + vi.DownloadUrl + ">" + vi.Title + " " + vi.Resolution + " " + vi.VideoExtension + "</a><br/>"; } }
private void DownloadVideo(YoutubeVideoModel videoDownloader) { try { //Store VideoInfo object in model videoDownloader.VideoInfo = FileDownloader.GetVideoInfos(videoDownloader); //Stores VideoInfo object in model videoDownloader.Video = FileDownloader.GetVideoInfo(videoDownloader); //Updates lblUpdate to show title of video that is downloading UpdateLabel(videoDownloader.Video.Title + videoDownloader.Video.VideoExtension); //Stores FilePath in model videoDownloader.FilePath = FileDownloader.GetPath(videoDownloader); videoDownloader.FilePath += videoDownloader.Video.VideoExtension; //Stores VideoDownloaderType object in model videoDownloader.VideoDownloaderType = FileDownloader.GetVideoDownloader(videoDownloader); //Enable buttons once download is complete videoDownloader.VideoDownloaderType.DownloadFinished += (sender, args) => timer1.Stop(); videoDownloader.VideoDownloaderType.DownloadFinished += (sender, args) => EnableAccessibility(); videoDownloader.VideoDownloaderType.DownloadFinished += (sender, args) => OpenFolder(videoDownloader.FilePath); //Link progress bar up to download progress videoDownloader.VideoDownloaderType.DownloadProgressChanged += (sender, args) => pgDownload.Value = (int)args.ProgressPercentage; CheckForIllegalCrossThreadCalls = false; //Download video FileDownloader.DownloadVideo(videoDownloader); } catch (Exception) { MessageBox.Show("Download cancelled"); EnableAccessibility(); } }
private void CreateVideoOrAudioObject() { //Create video object if ((int)comboBox1.SelectedIndex == 0) //Video is selected from dropdown list { //Create new videoDownloader object YoutubeVideoModel videoDownloader = new YoutubeVideoModel(); //Set videoDownloader properties videoDownloader.Link = txtLink.Text; videoDownloader.FolderPath = txtPath.Text; //Store VideoInfo object in model videoDownloader.VideoInfo = FileDownloader.GetVideoInfos(videoDownloader); //Stores VideoInfo object in model videoDownloader.Video = FileDownloader.GetVideoInfo(videoDownloader); UpdateListBox(videoDownloader); } //Create audio object else { //Create new audioDownloader object YoutubeAudioModel audioDownloader = new YoutubeAudioModel(); //Set AudioDownloader properties audioDownloader.Link = txtLink.Text; audioDownloader.FolderPath = txtPath.Text; //Store VideoInfo object in model audioDownloader.VideoInfo = FileDownloader.GetVideoInfos(audioDownloader); //Stores VideoInfo object in model audioDownloader.Video = FileDownloader.GetVideoInfoAudioOnly(audioDownloader); UpdateListBox(audioDownloader); } }
//Downloads Video (Only for video model) public static void DownloadVideo(YoutubeVideoModel vidDownloader) { Task.Run(() => vidDownloader.VideoDownloaderType.Execute()); }
//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; }
//Returns VideoDownloader object (Only for video model) public static VideoDownloader GetVideoDownloader(YoutubeVideoModel videoModel) { return new VideoDownloader(videoModel.Video, videoModel.FilePath); }
//Returns VideoDownloader object (Only for video model) public static VideoDownloader GetVideoDownloader(YoutubeVideoModel videoModel) { return(new VideoDownloader(videoModel.Video, videoModel.FilePath)); }
private void DownloadVideo(YoutubeVideoModel videoDownloader) { try { //Store VideoInfo object in model videoDownloader.VideoInfo = FileDownloader.GetVideoInfos(videoDownloader); //Stores VideoInfo object in model videoDownloader.Video = FileDownloader.GetVideoInfo(videoDownloader); //Updates lblUpdate to show title of video that is downloading UpdateLabel(videoDownloader.Video.Title + videoDownloader.Video.VideoExtension); //Stores FilePath in model videoDownloader.FilePath = FileDownloader.GetPath(videoDownloader); videoDownloader.FilePath += videoDownloader.Video.VideoExtension; //Stores VideoDownloaderType object in model videoDownloader.VideoDownloaderType = FileDownloader.GetVideoDownloader(videoDownloader); //Enable buttons once download is complete videoDownloader.VideoDownloaderType.DownloadFinished += (sender, args) => EnableAccessibility(); videoDownloader.VideoDownloaderType.DownloadFinished += (sender, args) => OpenFolder(videoDownloader.FilePath); //Link progress bar up to download progress videoDownloader.VideoDownloaderType.DownloadProgressChanged += (sender, args) => pgDownload.Value = (int)args.ProgressPercentage; CheckForIllegalCrossThreadCalls = false; //Download video FileDownloader.DownloadVideo(videoDownloader); } catch (Exception) { MessageBox.Show("Download cancelled"); EnableAccessibility(); } }