/* * private static void DownloadAudio(IEnumerable<VideoInfo> videoInfos, string dir, ProgressBar progress) * { * * p = progress; * * * VideoInfo video = videoInfos.First(info => info.VideoType == VideoType.Mp4); // youtube gives always mp4 * if (video.RequiresDecryption) * { * DownloadUrlResolver.DecryptDownloadUrl(video); * } * * string tempF =dir + "\\Downloaded"; * if (!Directory.Exists(tempF)) Directory.CreateDirectory(tempF); * * var videoDownloader = new VideoDownloader(video, Path.Combine(dir+ "/Downloaded", video.Title + video.AudioExtension)); * videoDownloader.DownloadStarted += progress_zero; * videoDownloader.DownloadProgressChanged += pregress_changed; * videoDownloader.DownloadFinished += progress_full; * videoDownloader.Execute(); * * // Convert mp4 to mp3 * // ------------------- * var inputFile = new MediaFile { Filename = Path.Combine(dir + "/Downloaded", video.Title + video.AudioExtension) }; * var outputFile = new MediaFile { Filename = Path.Combine(dir + "/Downloaded", video.Title + ".mp3") }; * progress.Value = 0; * using (var engine = new Engine()) * { * engine.GetMetadata(inputFile); * progress.Value = 70; * engine.Convert(inputFile, outputFile); * progress.Value = 100; * } * File.Delete(Path.Combine(dir + "/Downloaded", video.Title + video.AudioExtension)); * * } * * private static void progress_full(object sender, EventArgs e) * { * p.Value = 100; * } * * private static void pregress_changed(object sender, ProgressEventArgs e) * { * if(p.Value<100) p.Value ++; * } * * private static void progress_zero(object sender, EventArgs e) * { * p.Value = 0; * } */ private void a_button_Click(object sender, EventArgs e) { if (URL.Text.Equals("") || URL.Text.Equals("Paste URL here")) { MessageBox.Show("No URL here, man"); } else { Clipboard.Clear(); string[] targets = URL.Lines; string rejected = ""; foreach (string target in targets) { if (!target.Equals("") && (target.Contains("youtube") || target.Contains("youtu.be")) && target.Contains("http")) { IEnumerable <VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(target, false); VideoInfo video = videoInfos.First(info => info.VideoType == VideoType.Mp4); // youtube gives always mp4 YoutubeVideo add = new YoutubeVideo(video.Title, target); URLS.Items.Add(add); } else { rejected += target + "\n"; } } URL.Text = rejected; } }
private void mostrathumbnail(object sender, EventArgs e) { /* DEPRECATO */ WebClient wc = new WebClient(); byte[] thumb = wc.DownloadData(((YoutubeVideo)risultati.SelectedItem).GetThumbnail()); Image img = byteArrayToImage(thumb); Bitmap background = new Bitmap(img, new Size(747, 413)); Bitmap pannello = new Bitmap(img, new Size(323, 262)); Search.BackgroundImage = background; panel1.BackgroundImage = pannello; YoutubeVideo selected = (YoutubeVideo)risultati.SelectedItem; if (player1.playlist.isPlaying) { player1.playlist.stop(); } player1.playlist.items.clear(); player1.playlist.add(selected.Url); }