コード例 #1
0
        // Download the video
        private void DownloadVideo(YouTubeVideo video)
        {
            try
            {
                // Get video information
                video.VideoInfo           = FileDownloader.GetVideoInfos(video);
                video.Video               = FileDownloader.GetVideoInfo(video);
                lblFileDownloading.Text   = video.Video.Title;
                video.FilePath            = FileDownloader.GetPath(video) + video.Video.VideoExtension;
                video.VideoDownloaderType = FileDownloader.GetVideoDownloader(video);

                // Open file location
                video.VideoDownloaderType.DownloadFinished += (sender, args) => OpenFolder(video.FilePath);

                // Download bar
                video.VideoDownloaderType.DownloadProgressChanged +=
                    (sender, args) => pgDownload.Value             = (int)args.ProgressPercentage;
                video.VideoDownloaderType.DownloadProgressChanged +=
                    (sender, args) => lblPercent.Text              = ((int)args.ProgressPercentage).ToString() + "%";

                // Allow user to use the UI after download is finished
                video.VideoDownloaderType.DownloadFinished += (sender, args) => EnableUI();

                CheckForIllegalCrossThreadCalls = false;

                // Download
                FileDownloader.DownloadVideo(video);
            }
            catch (Exception)
            {
                EnableUI();
                lblValidation.Text = "Error Downloading Video";
            }
        }
コード例 #2
0
        //Returns VideoInfo object (Only for video model)
        public static VideoInfo GetVideoInfo(YouTubeVideo videoModel)
        {
            //Select the first .mp4 video with 360p resolution
            var video = videoModel.VideoInfo.First(info => info.VideoType == VideoType.Mp4 && info.Resolution == 360);

            return(video);
        }
コード例 #3
0
 //Downloads Video (Only for video model)
 public static void DownloadVideo(YouTubeVideo vidDownloader)
 {
     Task.Run(() => vidDownloader.VideoDownloaderType.Execute());
 }
コード例 #4
0
 //Returns VideoDownloader object (Only for video model)
 public static VideoDownloader GetVideoDownloader(YouTubeVideo videoModel)
 {
     return(new VideoDownloader(videoModel.Video, videoModel.FilePath));
 }