/// <summary> /// Downloads context to audio, requires Url, Optional - VideoInfo (Default: Highest Quality), Optional - BaseDirectory /// </summary> public static void ToVideo(this YoutubeContext context, VideoType customtype = VideoType.Mp4) { if (context==null) throw new ArgumentException(nameof(context)); if (string.IsNullOrEmpty(context.Url)) throw new ArgumentException(nameof(context.Url)); if (context.VideoInfo == null) DownloadUrlResolver.FindHighestVideoQualityDownloadUrl(context, customtype); var vd = new VideoDownloader(context); vd.Execute(); }
/// <summary> /// Downloads context to audio, requires Url, Optional - VideoInfo (Default: Highest Quality), Optional - BaseDirectory /// </summary> public async static Task ToVideoAsync(this YoutubeContext context, VideoType customtype = VideoType.Mp4) { if (context==null) throw new ArgumentException(nameof(context)); if (string.IsNullOrEmpty(context.Url)) throw new ArgumentException(nameof(context.Url)); if (context.VideoInfo == null) await context.FindHighestVideoQualityDownloadUrlAsync(customtype); var vd = new VideoDownloader(context); await vd.ExecuteAsync(); }
private void DownloadMp4(LinkInfo link, string downloadDir) { Directory.CreateDirectory(downloadDir); IEnumerable <VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(link.Link); VideoInfo video; switch (link.QualityInfo) { case Quality.Low: video = videoInfos.Where(info => info.Resolution < 480).OrderByDescending(info => info.Resolution).First(); break; case Quality.Medium: video = videoInfos.Where(info => info.Resolution < 720).OrderByDescending(info => info.Resolution).First(); break; case Quality.High: video = videoInfos.Where(info => info.Resolution < 1080).OrderByDescending(info => info.Resolution).First(); break; case Quality.SuperHigh: video = videoInfos.OrderByDescending(info => info.Resolution).First(); break; default: throw new ArgumentOutOfRangeException(); } if (video.RequiresDecryption) { DownloadUrlResolver.DecryptDownloadUrl(video); } var videoDownloader = new VideoDownloader(video, Path.Combine(downloadDir, RemoveIllegalPathCharacters(video.Title) + "-" + video.Resolution + video.VideoExtension)); videoDownloader.DownloadStarted += (sender, argss) => Console.WriteLine("Started downloading " + video.Title + "-" + video.Resolution + video.VideoExtension); videoDownloader.DownloadProgressChanged += (sender, argss) => { downloader.ReportProgress((int)argss.ProgressPercentage); }; videoDownloader.Execute(); }
public void bw_DoWork(object sender, DoWorkEventArgs e) { progressBar1.Value = 0; var split = lines[currentLine].Split(','); for (int i = 0; i < split.Length; i++) { IEnumerable <VideoInfo> videolar = DownloadUrlResolver.GetDownloadUrls(split[i]); VideoInfo video = videolar.First(p => p.VideoType == VideoType.Mp4 && p.Resolution == Convert.ToInt32(resolution)); if (video.RequiresDecryption) { DownloadUrlResolver.DecryptDownloadUrl(video); } VideoDownloader downloader = new VideoDownloader(video, System.IO.Path.Combine(Application.StartupPath + "\\ " + GetSafeFileName(video.Title) + '_' + video.VideoExtension)); downloader.DownloadProgressChanged += downloader_DownloadProgressChanged; downloader.Execute(); } }
private void metroButtonStart_Click(object sender, EventArgs e) { if (IsConnectedToInternet()) { if (!(metroTextBoxUrl.Text.Equals("") || txtDiretorio.Text.Equals(""))) { pictureBox1.Visible = true; try { metroButtonStart.Enabled = false; progressBar.Minimum = 0; progressBar.Maximum = 100; IEnumerable <VideoInfo> videos = DownloadUrlResolver.GetDownloadUrls(metroTextBoxUrl.Text); VideoInfo video = videos.First(p => p.VideoType == VideoType.Mp4 && p.Resolution == Convert.ToInt32(cboResolucao.Text)); if (video.RequiresDecryption) { DownloadUrlResolver.DecryptDownloadUrl(video); } VideoDownloader download = new VideoDownloader(video, Path.Combine(txtDiretorio.Text, video.Title + video.VideoExtension)); download.DownloadProgressChanged += Downloder_DownloadProgressChanged; tituloVideo = video.Title; Thread thread = new Thread(() => { download.Execute(); }) { IsBackground = true }; thread.Start(); } catch (Exception ex) { MessageBox.Show("Erro: " + ex); metroButtonStart.Enabled = true; } } else { MessageBox.Show("Campo URL ou LOCAL vazio."); } } else { MessageBox.Show("Erro ao tentar conectar com a internet."); } }
private void DownloadToolStripMenuItem_Click(object sender, EventArgs e) { if (listView1.SelectedItems.Count == 0) { return; } var video = listView1.SelectedItems[0].Tag as VideoInfo; /* * If the video has a decrypted signature, decipher it */ if (video.RequiresDecryption) { DownloadUrlResolver.DecryptDownloadUrl(video); } /* * Create the video downloader. * The first argument is the video to download. * The second argument is the path to save the video file. */ SaveFileDialog sfd = new SaveFileDialog(); sfd.DefaultExt = video.VideoExtension; sfd.FileName = RemoveIllegalPathCharacters(video.Title) + video.VideoExtension; if (sfd.ShowDialog() == DialogResult.OK) { toolStripProgressBar1.Visible = true; Thread th = new Thread(() => { var videoDownloader = new VideoDownloader(video, sfd.FileName ); videoDownloader.DownloadProgressChanged += VideoDownloader_DownloadProgressChanged; videoDownloader.Execute(); }); th.IsBackground = true; th.Start(); } }
public IFile Save(string url) { if (url == null) { throw new ArgumentNullException(nameof(url)); } url = url.Trim(); if (!new Regex(YoutuberRegexp).Match(url).Success) { throw new Exception("Link is not valid for youtube video"); } url = UrlFormatter.RemoveParametersFromUrl(url); IEnumerable <VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(url); VideoInfo videoInfo = videoInfos.First(info => info.VideoType == VideoType.Mp4 && info.Resolution == 360); if (videoInfo.RequiresDecryption) { DownloadUrlResolver.DecryptDownloadUrl(videoInfo); } string videoFolderPath = _fileResolver.GetVideoFolderPath(StorageType.FileSystem); string fileName = UrlFormatter.GetYoutubeVideoIdentifier(url); string fullPath = Path.Combine(videoFolderPath, fileName + videoInfo.VideoExtension); if (File.Exists(fullPath)) { File.Delete(fullPath); } var videoDownloader = new VideoDownloader(videoInfo, fullPath); videoDownloader.Execute(); return(new PCFile() { Extension = videoInfo.VideoExtension, Filename = fileName, StorageType = StorageType.FileSystem, }); }
private void button1_Click(object sender, EventArgs e) { IEnumerable <VideoInfo> videos = DownloadUrlResolver.GetDownloadUrls(textBox1.Text); VideoInfo video = videos.First(p => p.VideoType == VideoType.Mp4 && p.Resolution == Convert.ToInt32(comboBox1.Text)); if (video.RequiresDecryption) { DownloadUrlResolver.DecryptDownloadUrl(video); } VideoDownloader Downloader = new VideoDownloader(video, Path.Combine(textBox2.Text + "\\", video.Title + video.VideoExtension)); Downloader.DownloadProgressChanged += Downloader_DownloadProgressChanged; Thread thread = new Thread(() => { Downloader.Execute(); }) { IsBackground = true }; thread.Start(); }
static Task DoVoiceURL(DiscordVoiceClient vc, string url, string name) { return(Task.Run(() => { Console.WriteLine("Beginning URL Play..."); IEnumerable <VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(url); VideoInfo video = videoInfos.First(info => info.VideoType == VideoType.Mp4 && info.Resolution == 360); if (video.RequiresDecryption) { DownloadUrlResolver.DecryptDownloadUrl(video); } var videoDownloader = new VideoDownloader(video, Path.Combine("./downloads/", "temp" + name + video.VideoExtension)); videoDownloader.DownloadProgressChanged += (sender, args) => Console.WriteLine(args.ProgressPercentage); videoDownloader.DownloadFinished += (sender, args) => { Console.WriteLine("Beginning conversion..."); var inputFile = new MediaFile { Filename = @"./downloads/temp" + name + video.VideoExtension }; var outputFile = new MediaFile { Filename = @"./music/" + name + ".mp3" }; using (var engine = new Engine()) { Console.WriteLine("Converting..."); engine.Convert(inputFile, outputFile); System.Threading.Thread.Sleep(2000); Console.WriteLine("Done."); File.Delete("downloads/temp" + name + video.VideoExtension); } }; Console.WriteLine("Downloading youtube video..."); videoDownloader.Execute(); })); }
public async Task DownloadVideo() { IEnumerable <VideoInfo> videoInfos = await DownloadUrlResolver.GetDownloadUrlsAsync("https://www.youtube.com/watch?v=vxMxYgkUcdU"); var downloader = new VideoDownloader(); var stream = await downloader.Execute(videoInfos.FirstOrDefault()); Assert.IsTrue(stream.Length > 0); byte[] buffer = new byte[16 * 1024]; using (MemoryStream ms = new MemoryStream()) { int read; while ((read = await stream.ReadAsync(buffer, 0, buffer.Length)) > 0) { ms.Write(buffer, 0, read); } File.WriteAllBytes("video.flv", ms.ToArray()); } }
private static void DownloadAudio(IEnumerable <VideoInfo> videoInfos) { /* * We want the first extractable video with the highest audio quality. */ VideoInfo video = videoInfos.First(info => info.VideoType == VideoType.Mp4 && info.Resolution == 0); var path = "c:\\temp\\audio" + video.AudioExtension; //Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), //RemoveIllegalPathCharacters(video.Title) + video.AudioExtension); var audioDownloader = new VideoDownloader(video, path); // Register the progress events. We treat the download progress as 85% of the progress // and the extraction progress only as 15% of the progress, because the download will // take much longer than the audio extraction. audioDownloader.DownloadProgressChanged += (sender, args) => Console.WriteLine(args.ProgressPercentage * 0.85); audioDownloader.DownloadProgressChanged += (sender, args) => Console.WriteLine(85 + args.ProgressPercentage * 0.15); audioDownloader.Execute(); }
//VideoDownload void videoDownload() { try { IEnumerable <VideoInfo> videos = DownloadUrlResolver.GetDownloadUrls(UrlTextBox.Text); VideoInfo video = videos.First(p => p.VideoType == VideoType.Mp4 && p.Resolution == Convert.ToInt32(480)); if (video.RequiresDecryption) { DownloadUrlResolver.DecryptDownloadUrl(video); } VideoDownloader down = new VideoDownloader(video, Path.Combine("F:\\ChromeDownloads\\" + Environment.UserName + "\\Videos\\", video.Title + video.VideoExtension)); down.DownloadProgressChanged += Down_DownloadProgressChanged; Thread t = new Thread(() => { down.Execute(); }) { IsBackground = true }; t.Start(); } catch { return; } }
private void download(ListViewItem lvi) { int i = lvi.Index; IEnumerable <VideoInfo> videos = DownloadUrlResolver.GetDownloadUrls(lvi.SubItems[5].Text); VideoInfo video = videos.First(p => p.VideoType == VideoType.Mp4); if (video.RequiresDecryption) { DownloadUrlResolver.DecryptDownloadUrl(video); } VideoDownloader downloader = new VideoDownloader(video, Path.Combine(lvi.SubItems[6].Text + "\\", video.Title + video.VideoExtension)); downloader.DownloadProgressChanged += downloader_DownloadProgressChangedTag; threads[i] = new Thread(() => { downloader.Execute(); }) { IsBackground = true }; threads[i].Start(); downloader.DownloadFinished += downloader_DownloadFinshedTag; }
private void DescargarVideo(IEnumerable <VideoInfo> videoInfo) { VideoInfo video = videoInfo.First(info => info.VideoType == VideoType.Mp4 && info.Resolution == 360); if (video.RequiresDecryption) { DownloadUrlResolver.DecryptDownloadUrl(video); } var videoDownloader = new VideoDownloader(video, Path.Combine(Directorio, video.Title + video.AudioExtension)); videoDownloader.DownloadProgressChanged += VideoDownloader_DownloadProgressChanged; FormatearProgreso(); Thread thread = new Thread(() => { videoDownloader.Execute(); }) { IsBackground = true }; thread.Start(); }
private void DownloadVideo(IEnumerable <VideoInfo> videoInfos) { try { VideoInfo video = videoInfos .First(info => info.VideoType == VideoType.Mp4 && info.Resolution == res); if (video.RequiresDecryption) { DownloadUrlResolver.DecryptDownloadUrl(video); } try { var videoDownloader = new VideoDownloader(video, Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), RemoveIllegalPathCharacters(video.Title) + video.VideoExtension)); S = RemoveIllegalPathCharacters(video.Title) + video.VideoExtension; double x = Convert.ToDouble(videoDownloader.BytesToDownload); videoDownloader.DownloadProgressChanged += (sender, args) => bw.ReportProgress(Convert.ToInt32(args.ProgressPercentage)); // label3.Text = videoDownloader.BytesToDownload.ToString(); videoDownloader.Execute(); MessageBox.Show("Video Download Completed on your Desktop"); Application.Restart(); bw.ReportProgress(0); } catch (Exception exe) { MessageBox.Show("An error has occured while downloading this video.This might be because of problems in your network connection"); Application.Restart(); } } catch (Exception ex) { MessageBox.Show(res.ToString() + "p not supported by this video"); Application.Restart(); } }
static void ProcessInfo(string[] args) { // Our test youtube link string link = args[0]; /* * Get the available video formats. * We'll work with them in the video and audio download examples. */ IEnumerable <VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(link); /* * Select the first .mp4 video with 360p resolution */ VideoInfo video = videoInfos .First(info => info.VideoType == VideoType.Mp4 && info.Resolution == 360); /* * If the video has a decrypted signature, decipher it */ if (video.RequiresDecryption) { DownloadUrlResolver.DecryptDownloadUrl(video); } /* * Create the video downloader. * The first argument is the video to download. * The second argument is the path to save the video file. */ var videoDownloader = new VideoDownloader(video, Path.Combine("", "asdf" + video.VideoExtension)); // Register the ProgressChanged event and print the current progress videoDownloader.DownloadProgressChanged += (sender, arg) => Console.Instance.WriteLine(arg.ProgressPercentage); /* * Execute the video downloader. * For GUI applications note, that this method runs synchronously. */ videoDownloader.Execute(); }
public static async Task DownloadAudio(string link, Channel voice) { /* * Get the available video formats. * We'll work with them in the video and audio download examples. */ Channel voiceChan = voice; IEnumerable <VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(link); /* * Select the first .mp4 video with 360p resolution */ VideoInfo video = videoInfos .First(info => info.VideoType == VideoType.Mp4 && info.Resolution == 360); /* * If the video has a decrypted signature, decipher it */ if (video.RequiresDecryption) { DownloadUrlResolver.DecryptDownloadUrl(video); } /* * Create the video downloader. * The first argument is the video to download. * The second argument is the path to save the video file. */ string path = @"C:\music\tempvid.mp4"; var videoDownloader = new VideoDownloader(video, path); // Register the ProgressChanged event and print the current progress //videoDownloader.DownloadProgressChanged += (sender, args) => Console.WriteLine(args.ProgressPercentage); /* * Execute the video downloader. * For GUI applications note, that this method runs synchronously. */ videoDownloader.Execute(); await wavConvert(path, voiceChan); }
private void btnDownload_Click(object sender, EventArgs e) { // Our test youtube link string link = "https://www.youtube.com/watch?v=pv-6rweZR_s"; /* * Get the available video formats. * We'll work with them in the video and audio download examples. */ IEnumerable <VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(link); /* * Select the first .mp4 video with 360p resolution */ VideoInfo video = videoInfos .First(info => info.VideoType == VideoType.Mp4 && info.Resolution == 360); /* * If the video has a decrypted signature, decipher it */ if (video.RequiresDecryption) { DownloadUrlResolver.DecryptDownloadUrl(video); } /* * Create the video downloader. * The first argument is the video to download. * The second argument is the path to save the video file. */ var videoDownloader = new VideoDownloader(video, Path.Combine(txtDownloadFolder.Text, video.Title + video.VideoExtension)); // Register the ProgressChanged event and print the current progress //videoDownloader.DownloadProgressChanged += (sender, args) => Console.WriteLine(args.ProgressPercentage); /* * Execute the video downloader. * For GUI applications note, that this method runs synchronously. */ videoDownloader.Execute(); }
public void kekfuntion() { progressBar1.Minimum = 0; progressBar1.Maximum = 100; IEnumerable <VideoInfo> videos = DownloadUrlResolver.GetDownloadUrls(tekstilaatikko.Text); VideoInfo video = videos.First(p => p.VideoType == VideoType.Mp4 && p.Resolution == Convert.ToInt32(comboBox1.Text)); if (video.RequiresDecryption) { DownloadUrlResolver.DecryptDownloadUrl(video); } VideoDownloader downloader = new VideoDownloader(video, Path.Combine(@"D:\musiikkia\", video.Title + video.VideoExtension)); downloader.DownloadProgressChanged += Downloader_DownloadProgressChanged; Thread thread = new Thread(() => { downloader.Execute(); }) { IsBackground = true }; thread.Start(); }
private void downloadButton_Click(object sender, EventArgs e) { downloadProgressBar.Minimum = 0; downloadProgressBar.Maximum = 100; var videos = DownloadUrlResolver.GetDownloadUrls(youtubePathTextbox.Text); var video = videos.First(q => q.VideoType == VideoType.Mp4 && q.Resolution == Convert.ToInt32(resolutionCombobox.Text)); if (video.RequiresDecryption) { DownloadUrlResolver.DecryptDownloadUrl(video); } VideoDownloader videoDownloader = new VideoDownloader(video, @"C:\Users\Selectra\Desktop\MP4-to-MP3-Converter-master"); videoDownloader.DownloadProgressChanged += VideoDownloader_DownloadProgressChanged; Thread thread = new Thread(() => { videoDownloader.Execute(); }) { IsBackground = true }; thread.Start(); }
static string DownloadVideo() { string link = ArgList.Get(Arg.YOUTUBE).AsString(); IEnumerable <VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(link); VideoInfo vi = videoInfos.OrderByDescending(x => x.Resolution).First(x => x.VideoType == VideoType.Mp4 && x.AudioExtension != null); if (vi.RequiresDecryption) { DownloadUrlResolver.DecryptDownloadUrl(vi); } VideoDownloader vd = new VideoDownloader(vi, Path.Combine(Environment.CurrentDirectory, vi.Title + vi.VideoExtension)); using (Mutex mutex = new Mutex()) { vd.DownloadFinished += (sender, e) => { try { mutex.ReleaseMutex(); } catch { } }; vd.DownloadProgressChanged += (sender, e) => { Console.WriteLine("Downloading {0}%", e.ProgressPercentage); }; vd.Execute(); mutex.WaitOne(); } return(vd.SavePath); }
private void btnDownload_Click(object sender, EventArgs e) { progressBar.Minimum = 0; progressBar.Maximum = 100; IEnumerable <VideoInfo> videos = DownloadUrlResolver.GetDownloadUrls(txtUrl.Text); VideoInfo video = videos.First(p => p.VideoType == VideoType.Mp4 && p.Resolution == Convert.ToInt32(cboResolution.Text)); if (video.RequiresDecryption) { DownloadUrlResolver.DecryptDownloadUrl(video); } VideoDownloader downloader = new VideoDownloader(video, Path.Combine(Application.StartupPath + "\\", video.Title + video.VideoExtension)); downloader.DownloadProgressChanged += Downloader_DownloadProgressChanged; Thread thread = new Thread(() => { downloader.Execute(); }) { IsBackground = true }; thread.Start(); }
private void btnDownload_Click(object sender, EventArgs e) { txtBoxLog.AppendText("Downloading " + comBoxRes.Text); txtBoxLog.AppendText("\n"); VideoInfo vid = videoInfos.First(p => p.VideoType == VideoType.Mp4 && p.Resolution == Convert.ToInt32(comBoxRes.Text)); if (vid.RequiresDecryption) { DownloadUrlResolver.DecryptDownloadUrl(vid); } //var vidDown = new VideoDownloader(vid, txtPath.ToString() + "\\" + vid.Title + vid.VideoExtension); var vidDown = new VideoDownloader(vid, txtPath.Text + "\\" + vid.Title + ".mp4"); vidDown.DownloadProgressChanged += Downloader_DownloadProgressChanged; vidDown.Execute(); //Thread thr = new Thread(() => { vidDown.Execute(); }) { IsBackground = true }; //thr.Start(); progBar.Value = 0; }
private static void bw_downloadVideo(object send, DoWorkEventArgs e) { BackgroundWorker worker = send as BackgroundWorker; if (dir_ != " ") { IEnumerable <VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(url_); //Select the first .mp4 video with 360p resolution VideoInfo video = videoInfos.First(info => info.VideoType == VideoType.Mp4); //If the video has a decrypted signature, decipher it if (video.RequiresDecryption) { DownloadUrlResolver.DecryptDownloadUrl(video); } /* * Create the video downloader. * The first argument is the video to download. * The second argument is the path to save the video file. */ var videoDownloader = new VideoDownloader(video, dir_); // Register the ProgressChanged event and print the current progress videoDownloader.DownloadProgressChanged += (sender, args) => progBar_.Invoke((Action)(() => { worker.ReportProgress((int)(args.ProgressPercentage)); })); /* * Execute the video downloader. * For GUI applications note, that this method runs synchronously. */ try { videoDownloader.Execute(); } catch (WebException we) { MessageBox.Show("The video returned an error, please try again later", we.Response.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private Task DownloadVideoAsync(string url) { return(Task.Run(() => { IEnumerable <VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(url); VideoInfo videoInfo = videoInfos.FirstOrDefault(); if (videoInfo != null) { if (videoInfo.RequiresDecryption) { DownloadUrlResolver.DecryptDownloadUrl(videoInfo); } string savePath = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.Desktop), Path.ChangeExtension("myVideo", videoInfo.VideoExtension)); var downloader = new VideoDownloader(videoInfo, savePath); downloader.DownloadProgressChanged += downloader_DownloadProgressChanged; downloader.Execute(); } })); }
/// <summary> /// Downloads the YouTube video to a .mp4 format /// </summary> /// <param name="v"></param> /// <param name="url"></param> /// <param name="dir"></param> /// <param name="progressBar1"></param> private static void downloadVideo(ref string v, ref string url, ref string dir, ProgressBar progressBar1) { IEnumerable <VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(url); //Select the first .mp4 video with 360p resolution VideoInfo video = videoInfos .First(info => info.VideoType == VideoType.Mp4 && info.Resolution == 360); //If the video has a decrypted signature, decipher it if (video.RequiresDecryption) { DownloadUrlResolver.DecryptDownloadUrl(video); } /* * Create the video downloader. * The first argument is the video to download. * The second argument is the path to save the video file. */ var videoDownloader = new VideoDownloader(video, dir); // Register the ProgressChanged event and print the current progress videoDownloader.DownloadProgressChanged += (sender, args) => progressBar1.Invoke((Action)(() => { progressBar1.Value = (int)(args.ProgressPercentage); })); videoDownloader.DownloadFinished += (sender, args) => completedDownload(); /* * Execute the video downloader. * For GUI applications note, that this method runs synchronously. */ try { videoDownloader.Execute(); } catch (WebException e) { MessageBox.Show("The video returned an error, please try again later", e.Response.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void DownloadVideo(IEnumerable <VideoInfo> videoInfos, out string fileName) { progressFile.Value = 0; /* * Select the first .mp4 video with 360p resolution */ VideoInfo video = videoInfos .FirstOrDefault(info => info.VideoType == VideoType.Mp4 && info.Resolution == 360); /* * If the video has a decrypted signature, decipher it */ if (video.RequiresDecryption) { DownloadUrlResolver.DecryptDownloadUrl(video); } /* * Create the video downloader. * The first argument is the video to download. * The second argument is the path to save the video file. */ fileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), RemoveIllegalPathCharacters(video.Title) + video.VideoExtension); label1.Text = fileName; var videoDownloader = new VideoDownloader(video, fileName); // Register the ProgressChanged event and print the current progress //videoDownloader.DownloadProgressChanged += (sender, args) => Console.WriteLine(args.ProgressPercentage); videoDownloader.DownloadProgressChanged += (sender, args) => progressFile.Value = (int)args.ProgressPercentage; progressFile.Update(); /* * Execute the video downloader. * For GUI applications note, that this method runs synchronously. */ videoDownloader.Execute(); }
void Initialize(VideoDownloader downloader, Video video) { var inflater = (LayoutInflater)this.Context.GetSystemService(Context.LayoutInflaterService); var view = inflater.Inflate(Resource.Layout.DownloadItem, this, true); var titleView = view.FindViewById <TextView>(Resource.Id.titleTextView); titleView.Text = downloader.Video.Title; var progressBar = view.FindViewById <ProgressBar>(Resource.Id.downloadProgressBar); downloader.DownloadProgressChanged += (sender, e) => { progressBar.SetProgress((int)e.ProgressPercentage, true); ProgressChanged?.Invoke(this, video); }; downloader.DownloadFinished += (sender, e) => { DownloadFinished?.Invoke(this, video); }; }
private void button1_Click(object sender, EventArgs e) { progressBar1.Minimum = 0; progressBar1.Maximum = 100; IEnumerable <VideoInfo> videos = DownloadUrlResolver.GetDownloadUrls(txturl.Text); VideoInfo video = videos.First(p => p.VideoType == VideoType.Mp4 && p.Resolution == Convert.ToInt32(comboBox1.Text)); if (video.RequiresDecryption) { DownloadUrlResolver.DecryptDownloadUrl(video); } var VideoDownloader = new VideoDownloader(video, Path.Combine("C://Downloads", video.Title + video.VideoExtension)); VideoDownloader.DownloadProgressChanged += Downloader_DownloadProgressChanged; VideoDownloader.Execute(); }
private void btnYes_Click(object sender, EventArgs e) {/* * string link = "https://www.youtube.com/watch?v=jIpawdg48U4"; * * IEnumerable<VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(link); * * VideoInfo video = videoInfos.First(info => info.VideoType == VideoType.Mp4 && info.Resolution == 360); * * if (video.RequiresDecryption) * { * DownloadUrlResolver.DecryptDownloadUrl(video); * } * * * var videoDownloader = new VideoDownloader(video, System.IO.Path.Combine("D:/Song", video.Title + video.VideoExtension)); * * videoDownloader.DownloadProgressChanged += (SendKeys, args) => Console.WriteLine(args.ProgressPercentage); * * videoDownloader.Execute();*/ IEnumerable <VideoInfo> videos = DownloadUrlResolver.GetDownloadUrls(txtURL.Text); VideoInfo video = videos.First(p => p.VideoType == VideoType.Mp4 && p.Resolution == 360); if (video.RequiresDecryption) { DownloadUrlResolver.DecryptDownloadUrl(video); } try { VideoDownloader downloader = new VideoDownloader(video, System.IO.Path.Combine(Application.StartupPath + "\\", video.Title + video.VideoExtension)); downloader.DownloadProgressChanged += Downloader_DownloadProgressChanged; Thread thread = new Thread(() => { downloader.Execute(); }) { IsBackground = true }; } catch { } }
public void PresentationFunctionCauseWebWontWork() { if (!Directory.Exists("output")) { Directory.CreateDirectory("output"); } var videoURL = "https://www.youtube.com/watch?v=pN_gruOjM9I"; var firstNote = new NoteInstance() { Note = Notes.D, Octave = 3 }; //------------------------------------------------------------------------// //var videoURL = "https://www.youtube.com/watch?v=aCJxjDzyAT8"; // //var firstNote = new NoteInstance() { Note = Notes.F, Octave = 3 }; // // // //var videoURL = "https://www.youtube.com/watch?v=M4hAK4bTdl4"; // //var firstNote = new NoteInstance() { Note = Notes.A, Octave = 3 }; // // // //var videoURL = "https://www.youtube.com/watch?v=p1WCR7vNcIw"; // //var firstNote = new NoteInstance() { Note = Notes.E, Octave = 3 }; // //------------------------------------------------------------------------// var videoDownloader = new VideoDownloader(); var video = videoDownloader.GetVideoByUrl(new Uri(videoURL)); var keyboardTiles = new NoteParser().ParseToKeyboardTiles(video, firstNote); var musicXmlParser = new MusicXMLParser(); var musicXML = musicXmlParser.KeyboardTilesToMusicXML(keyboardTiles.ToList(), video.Framecount); File.WriteAllText(@"output\musicxml.xml", musicXML); // The output file will be inside the /bin/output folder of the NotesheetR.AppTests project // Webiste to view the musicxml.xml => https://www.soundslice.com/musicxml-viewer/ }
private void button1_Click(object sender, EventArgs e) { progressBar1.Minimum = 0; progressBar1.Maximum = 100; IEnumerable <VideoInfo> videolar = DownloadUrlResolver.GetDownloadUrls(textBox1.Text); var allowedResolutions = new List <int>() { 1080, 720, 480, 360 }; VideoInfo video = videolar.OrderByDescending(info => info.Resolution) .Where(info => allowedResolutions.Contains(info.Resolution)) .First(info => info.VideoType == VideoType.Mp4); if (video.RequiresDecryption) { DownloadUrlResolver.DecryptDownloadUrl(video); } string yol = ""; SaveFileDialog kaydetme = new SaveFileDialog(); kaydetme.Filter = "Video Dosyası |*.mp4"; kaydetme.Title = "Kaydedilecek yeri seçin."; kaydetme.ShowDialog(); string KaydetmeDosyaYolu = kaydetme.FileName; VideoDownloader indirici = new VideoDownloader(video, KaydetmeDosyaYolu); MessageBox.Show(Path.GetDirectoryName(KaydetmeDosyaYolu) + "\\" + Path.GetFileNameWithoutExtension(KaydetmeDosyaYolu) + ".mp3"); indirici.DownloadProgressChanged += Downloader_DownloadProgressChanged; indirici.DownloadFinished += Downloader_DownloadFinished; Thread thread = new Thread(() => { indirici.Execute(); }) { IsBackground = true }; giris = KaydetmeDosyaYolu; cikis = KaydetmeDosyaYolu.Substring(0, giris.IndexOf(".")); thread.Start(); }
private void Downloader (YouTubeVideo video, MainProgramElements mainWindow, bool isAudio) { string temporaryDownloadPath = Path.Combine(this.UserSettings.TemporarySaveLocation, video.FullName); string movingPath = Path.Combine(this.UserSettings.MainSaveLocation, video.FullName); if (this.UserSettings.ValidationLocations.All(path => !File.Exists(Path.Combine(path, video.FullName)) && !File.Exists(movingPath)) { if(isAudio) { var audioDownloader = new AudioDownloader (video, temporaryDownloadPath);; audioDownloader.AudioExtractionProgressChanged += (sender, args) => mainWindow.CurrentDownloadProgress = (int)(85 + args.ProgressPercentage * 0.15); audioDownloader.Execute(); } else { var videoDownloader = new VideoDownloader (video, temporaryDownloadPath); videoDownloader.DownloadProgressChanged += ((sender, args) => mainWindow.CurrentDownloadProgress = (int)args.ProgressPercentage); videoDownloader.Execute(); } if (!temporaryDownloadPath.Equals(movingPath, StringComparison.OrdinalIgnoreCase)) File.Move(temporaryDownloadPath, movingPath); } else { throw new DownloadCanceledException(string.Format(CultureInfo.CurrentCulture, "The download of #{0} '{1}({2})' has been canceled because it already existed.", videoToUse.Position, RemoveIllegalPathCharacters(video.Title).Truncate(10), videoToUse.Location.Truncate(100))); } }