예제 #1
0
        public void DoDownloadVideo(string url)
        {
            DownloadItem downloadItem = new DownloadItem("Last Download", FormatType.None, "Pending", 0);

            downloadList.addToDownloadsList(downloadItem);
            IEnumerable <VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(url);
            VideoInfo video = videoInfos
                              .First(info => info.VideoType == VideoType.Mp4 && info.Resolution == 720 || info.Resolution == 480);

            if (video.RequiresDecryption)
            {
                DownloadUrlResolver.DecryptDownloadUrl(video);
            }
            downloadItem.Progress = 0;
            downloadItem.Status   = "Downloading";
            downloadItem.Title    = video.Title;
            downloadItem.Type     = FormatType.Mp4;

            ExtendedVideoDownloader videoDownloader = new ExtendedVideoDownloader(video, Path.Combine(SavePath, video.Title +
                                                                                                      video.VideoExtension), downloadItem);

            videoDownloader.DownloadProgressChanged += new EventHandler <ProgressEventArgs>(OnProgressChangedVideo);
            videoDownloader.DownloadFinished        += new EventHandler(OnDownloadFinishVideo);
            try{
                videoDownloader.Execute();
            }
            catch (Exception exc) {
                MessageDialog md = new MessageDialog(null, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, "Download " + video.Title + " failed!\n" + exc.Message);
                md.Run();
                md.Destroy();
            }
        }
예제 #2
0
        private void OnDownloadFinishVideoAudioHQ(object sender, EventArgs args)
        {
            ExtendedVideoDownloader videoDownloader = (ExtendedVideoDownloader)sender;

            videoDownloader.CurretDownloadItem.Status   = "Converting";
            videoDownloader.CurretDownloadItem.Progress = 0;
        }
예제 #3
0
        private void DoDownloadAudioHQ(string url)
        {
            DownloadItem downloadItem = new DownloadItem("Last Download", FormatType.None, "Pending", 0);

            downloadList.addToDownloadsList(downloadItem);
            IEnumerable <VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(url);
            VideoInfo video = videoInfos
                              .First(info => info.VideoType == VideoType.Mp4 && info.Resolution == 720 || info.Resolution == 480);

            if (video.RequiresDecryption)
            {
                DownloadUrlResolver.DecryptDownloadUrl(video);
            }
            downloadItem.Progress = 0;
            downloadItem.Status   = "Downloading";
            downloadItem.Title    = video.Title;
            downloadItem.Type     = FormatType.Mp4;
            string fromPath = Path.Combine(SavePath, video.Title +
                                           video.VideoExtension);
            string toPath = fromPath.Substring(0, fromPath.Length - 4) + ".mp3";
            ExtendedVideoDownloader videoDownloader = new ExtendedVideoDownloader(video, fromPath, downloadItem);

            videoDownloader.DownloadProgressChanged += new EventHandler <ProgressEventArgs>(OnProgressChangedVideo);
            videoDownloader.DownloadFinished        += new EventHandler(OnDownloadFinishVideoAudioHQ);
            try
            {
                videoDownloader.Execute();
                //convert the video
                M4A2MP3.ConvertToMp3(fromPath, toPath);
                File.SetAttributes(fromPath, FileAttributes.Normal);
                File.Delete(fromPath);
                videoDownloader.CurretDownloadItem.Status = "Completed";
            }
            catch (Exception exc) {
                MessageDialog md = new MessageDialog(null, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, "Download " + video.Title + " failed!\n" + exc.Message);
                md.Run();
                md.Destroy();
            }
        }
예제 #4
0
        private void OnDownloadFinishVideo(object sender, EventArgs args)
        {
            ExtendedVideoDownloader videoDownloader = (ExtendedVideoDownloader)sender;

            videoDownloader.CurretDownloadItem.Status = "Completed";
        }
예제 #5
0
        private void OnProgressChangedVideo(object sender, ProgressEventArgs args)
        {
            ExtendedVideoDownloader videoDownloader = (ExtendedVideoDownloader)sender;

            videoDownloader.CurretDownloadItem.Progress = (float)args.ProgressPercentage;
        }