Inheritance: YoutubeModel
コード例 #1
0
ファイル: Form1.cs プロジェクト: freephys/Youtube-Downloader
        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();
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: Twrgonix/Youtube-Downloader
        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);
            }
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
        //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);
        }
コード例 #5
0
ファイル: Form1.cs プロジェクト: freephys/Youtube-Downloader
        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);
            }
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        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/>";
            }
        }
コード例 #10
0
ファイル: Form1.cs プロジェクト: freephys/Youtube-Downloader
        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();
            }
        }
コード例 #11
0
ファイル: Form1.cs プロジェクト: freephys/Youtube-Downloader
        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);
            }
        }
コード例 #12
0
 //Downloads Video (Only for video model)
 public static void DownloadVideo(YoutubeVideoModel vidDownloader)
 {
     Task.Run(() => vidDownloader.VideoDownloaderType.Execute());
 }
コード例 #13
0
        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);
            }
        }
コード例 #14
0
 //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;
 }
コード例 #15
0
 //Returns VideoDownloader object (Only for video model)
 public static VideoDownloader GetVideoDownloader(YoutubeVideoModel videoModel)
 {
     return new VideoDownloader(videoModel.Video, videoModel.FilePath);
 }
コード例 #16
0
 //Downloads Video (Only for video model)
 public static void DownloadVideo(YoutubeVideoModel vidDownloader)
 {
     Task.Run(() => vidDownloader.VideoDownloaderType.Execute());
 }
コード例 #17
0
 //Returns VideoDownloader object (Only for video model)
 public static VideoDownloader GetVideoDownloader(YoutubeVideoModel videoModel)
 {
     return(new VideoDownloader(videoModel.Video, videoModel.FilePath));
 }
コード例 #18
0
        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);
            }
        }
コード例 #19
0
        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();
            }
        }
コード例 #20
0
        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();
            }
        }