public void basic_searchbox_render() { var html = new UrlBox("foo").ToString(); html.ShouldHaveHtmlNode("foo") .ShouldBeNamed(HtmlTag.Input) .ShouldHaveAttribute(HtmlAttribute.Type).WithValue(HtmlInputType.Url); }
public void urlbox_list_renders_list() { var html = new UrlBox("foo").List("list1").ToString(); html.ShouldHaveHtmlNode("foo") .ShouldHaveAttribute(HtmlAttribute.List).WithValue("list1"); }
private void AddToQueueButton_Click(object sender, RoutedEventArgs e) { string ID = UrlBox.Text; string filename = UseVideoTitleBox.IsChecked == true ? "%(title)s.%(ext)s" : FilenameBox.Text + ".%(ext)s"; //Get around nullable bool state string path = PathBox.Text + @"\"; string filetype = formats.FirstOrDefault(x => x.Value == FiletypeBox.Text).Key; string title = videoInfo[0]; string thumbURL = videoInfo[1] == "N.A" ? null : videoInfo[1]; DownloadStatus.Text = Localization.Strings.GettingTitle; queue.ModifyQueue(title, thumbURL, ID, filename, path, filetype, formats); UrlBox.Clear(); formats.Clear(); FiletypeBox.IsEnabled = false; }
private void AddToQueueButton_Click(object sender, RoutedEventArgs e) { string ID = UrlBox.Text; string filename = UseVideoTitleBox.IsChecked == true ? "%(title)s.%(ext)s" : FilenameBox.Text + ".%(ext)s"; //Get around nullable bool state string path = PathBox.Text + @"\"; string filetype = formats.FirstOrDefault(x => x.Value == FiletypeBox.Text).Key; string thumbURL = ""; string title = ""; if (videoInfo.Count > 0) { title = videoInfo[0]; thumbURL = videoInfo[1] == "N.A" ? null : videoInfo[1]; } if (filetype == null) { MessageBox.Show(Localization.Strings.PleaseSelectFormat); return; } string fullpath = filename == "%(title)s.%(ext)s" ? path + title + "." : path + filename + "."; fullpath += formats[filetype].Contains(' ') ? formats[filetype].Substring(0, formats[filetype].IndexOf(' ')) : formats[filetype]; if (File.Exists(fullpath)) { MessageBoxResult userDialogResult = MessageBox.Show(Localization.Strings.FileExists, Localization.Strings.Error, MessageBoxButton.YesNo, MessageBoxImage.Warning); if (userDialogResult == MessageBoxResult.Yes) { File.Delete(fullpath); } else { return; } } DownloadStatus.Text = Localization.Strings.GettingTitle; queue.ModifyQueue(title, thumbURL, ID, filename, path, filetype, formats); UrlBox.Clear(); formats.Clear(); FiletypeBox.IsEnabled = false; }
private async void SelectButton_Click(object sender, RoutedEventArgs e) { DownloadStatus.Text = Localization.Strings.RetrevingFormats; UrlBox.Background = Brushes.Transparent; formats.Clear(); string Url = UrlBox.Text; if (Properties.Settings.Default.PrioritizePlaylists && UrlBox.Text.Contains(@"playlist?list=")) { formats.Add("default", "default (mp4)"); formats.Add("mp3", "mp3"); formats.Add("flac", "flac"); FiletypeBox.ItemsSource = formats; FiletypeBox.IsEnabled = AddToQueueButton.IsEnabled = true; UrlBox.Background = Brushes.DarkGreen; } else { UrlBox.Text = UrlBox.Text.Contains(@"&list=") ? UrlBox.Text.Substring(0, UrlBox.Text.IndexOf(@"&list=")) : UrlBox.Text; await Task.Run(() => formats = queue.GetFormats(Url)); await Task.Run(() => videoInfo = queue.GetInfo(Url)); if (formats.Count > 0) { FiletypeBox.IsEnabled = AddToQueueButton.IsEnabled = true; UrlBox.Background = Brushes.DarkGreen; FiletypeBox.SelectedItem = formats.First(); } else { UrlBox.Clear(); MessageBox.Show(Localization.Strings.InvalidURL, Localization.Strings.Error); } DownloadStatus.Text = Localization.Strings.NoDownload; } FiletypeBox.ItemsSource = formats; }
private void StartBtn_Click(object sender, EventArgs e) { try { // Downloading the file linkToFileFolder.Visible = false; downloader = new HttpDownloader(file, outputpath); downloader.DownloadCompleted += Downloader_DownloadCompleted; downloader.ProgressChanged += Downloader_ProgressChanged; downloader.DownloadInfoReceived += Downloader_DownloadInfoReceived; if (string.IsNullOrEmpty(UrlBox.Text) && string.IsNullOrEmpty(savingTxtbox.Text)) { MessageBox.Show("Fields can't be empty!", "Error"); UrlBox.Focus(); return; } else { downloader.Start(); if (isResume == false) { supportResumeLbl.Text = "No"; PauseBtn.Enabled = false; ResumeBtn.Enabled = false; } else { supportResumeLbl.Text = "Yes"; PauseBtn.Enabled = true; ResumeBtn.Enabled = true; } } } catch (Exception ex) { MessageBox.Show($"An error appear: {ex.Message}", "Erorr", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void ModifyQueue(string ID, string filename, string path, int filetype, bool isEdit) { switch (ID.Length) { case 43: var videoRequest = yt.Videos.List("snippet"); videoRequest.Id = ID.Contains("youtube") ? ID.Substring(ID.IndexOf("=") + 1) : ID; var videoListResponse = videoRequest.Execute(); if (videoListResponse.Items.Count < 1) { MessageBox.Show(strings.InvalidVideo, strings.Error); break; } foreach (var videoItem in videoListResponse.Items) { Video video = new Video(this); video.ID = ID; video.name = filename; video.path = path; video.filetype = filetype; video.thumbURL = videoItem.Snippet.Thumbnails.Default__.Url; video.title = videoItem.Snippet.Title; if (isEdit) { downloadQueue[DownloadGrid.SelectedRows[0].Index] = video; DownloadGrid[1, DownloadGrid.SelectedRows[0].Index].Value = video.title; DownloadGrid[2, DownloadGrid.SelectedRows[0].Index].Value = video.ID; UpdateCard(); } else { downloadQueue.Add(video); DownloadGrid.Rows.Add(DownloadGrid.Rows.Count + 1, video.title, ID); } } break; case 0: MessageBox.Show(strings.InvalidURL, strings.Error); break; default: if (ID.Contains("youtube")) { if (ID.Contains("playlist")) { Thread downloadPlaylistTask = new Thread(() => DownloadPlaylist(ID, filename, path, filetype)); downloadPlaylistTask.Start(); } else if (ID.Contains("channel")) { DownloadChannel(ID, filename, path, filetype); } } else { string HTML = ""; using (WebClient client = new WebClient()) { try { HTML = client.DownloadString(UrlBox.Text); } catch (Exception) { MessageBox.Show(strings.UnableGatherTitle, strings.Error); } } Video videoNonYoutube = new Video(this); videoNonYoutube.ID = ID; videoNonYoutube.name = filename; videoNonYoutube.path = path; videoNonYoutube.filetype = filetype; videoNonYoutube.thumbURL = null; videoNonYoutube.title = Regex.Match(HTML, @"\<title\b[^>]*\>\s*(?<Title>[\s\S]*?)\</title\>", RegexOptions.IgnoreCase).Groups["Title"].Value; if (isEdit) { downloadQueue[DownloadGrid.SelectedRows[0].Index] = videoNonYoutube; DownloadGrid[1, DownloadGrid.SelectedRows[0].Index].Value = videoNonYoutube.title; DownloadGrid[2, DownloadGrid.SelectedRows[0].Index].Value = videoNonYoutube.ID; UpdateCard(); } else { downloadQueue.Add(videoNonYoutube); DownloadGrid.Rows.Add(DownloadGrid.Rows.Count + 1, videoNonYoutube.title, ID); } } break; } UrlBox.Clear(); }