private void radListViewMovieSearch_DoubleClick(object sender, EventArgs e) { var selectedItem = radListViewMovieSearch.SelectedItem; try { ImdbDetails = new OmdbAPI().GetMovieDetailsByImdbId(selectedItem["imdbID"].ToString()); DialogResult = System.Windows.Forms.DialogResult.OK; }catch (Exception) { DialogResult = System.Windows.Forms.DialogResult.Abort; } this.Close(); }
// constructor overloading public FormLinks(string link, XmlMovieElement selectedXme, ListViewItem selectedLvi, XmlMovieElement.LinkDetails linkDetail) { InitializeComponent(); _selectedXme = selectedXme; _selectedLvi = selectedLvi; _linkDetail = linkDetail; // set checked all radCheckBoxSelectAll.Checked = true; // break links and add to checked list box foreach (var currentLink in link.Split(XmlMovieElement.LINK_FILENAME_SEPARATOR)) { Uri currentUri = null; try { currentUri = new Uri(currentLink); } catch (UriFormatException) { } // not an url, get the next one if (currentUri == null) { continue; } var listBoxChecked = true; // add the last Segment to list box and its full URI if (currentLink.Contains(".rev")) { listBoxChecked = false; } checkedListBoxLink.Items.Add( new Link(currentUri.Segments[currentUri.Segments.Length - 1], currentLink), listBoxChecked); } UpdateCheckedCount(); }
private void FormDownloadStatus_Load(object sender, EventArgs e) { if (xmlDownloadingMovies != null) { DataTable dt = new DataTable("xmlDownloadingMovies"); dt.Columns.Add("Title", typeof(string)); dt.Columns.Add("XmlMovieElement", typeof(XmlMovieElement)); foreach (var movie in xmlDownloadingMovies) { var dr = dt.NewRow(); dr["Title"] = movie.Title; dr["XmlMovieElement"] = movie; dt.Rows.Add(dr); } radGridViewMovieDownloading.DataSource = dt; radGridViewMovieDownloading.Columns.Add("Progress", "Progress"); radGridViewMovieDownloading.Columns.Add(new GridViewCheckBoxColumn("Extracted", "Extracted")); //var gvcbc = new GridViewComboBoxColumn("Status", "Status"); //radGridViewMovieDownloading.Columns.Add(gvcbc); radGridViewMovieDownloading.Columns.Add("Status", "Status"); radGridViewMovieDownloading.Columns["Title"].ReadOnly = true; radGridViewMovieDownloading.Columns["Title"].Width = 250; radGridViewMovieDownloading.Columns["Progress"].ReadOnly = true; radGridViewMovieDownloading.Columns["Progress"].Width = 50; radGridViewMovieDownloading.Columns["Extracted"].ReadOnly = true; radGridViewMovieDownloading.Columns["Extracted"].Width = 50; radGridViewMovieDownloading.Columns["XmlMovieElement"].IsVisible = false; // manipulate rows' values foreach (var gvr in radGridViewMovieDownloading.Rows) { XmlMovieElement xmeCurrentRow = (XmlMovieElement)gvr.Cells["XmlMovieElement"].Value; var fileNames = xmeCurrentRow.Filenames.Split(XmlMovieElement.LINK_FILENAME_SEPARATOR); double percentPerFilename = 100.0 / (double)fileNames.Length; double percentage = 0.0; foreach (var filename in fileNames) { if (File.Exists(Path.Combine(ConfigurationManager.AppSettings["Path.Download"], filename))) { // increment percentage percentage += percentPerFilename; } } gvr.Cells["Progress"].Value = String.Format("{0:N0} %", percentage); var extractFolder = Path.Combine(ConfigurationManager.AppSettings["Path.Download"], ConfigurationManager.AppSettings["Name.Transfer"], xmeCurrentRow.TitleCleaned()); if (Directory.Exists(extractFolder)) { long totalSize = 0; // check if file is present foreach (var filename in Directory.EnumerateFiles(extractFolder)) { FileInfo info = new FileInfo(filename); totalSize += info.Length; } if (totalSize > (long)300000000) { gvr.Cells["Extracted"].Value = true; gvr.Cells["Status"].Value = String.Format("{0:N2} GB - OK", (double)totalSize / (double)(1024 * 1024 * 1024)); } } } } }
private void LaunchAction(string data) { if (radGridViewMovieDownloading.SelectedRows.Count != 1) { return; } XmlMovieElement selectedXme = (XmlMovieElement)radGridViewMovieDownloading.SelectedRows[0].Cells["XmlMovieElement"].Value; var extracted = radGridViewMovieDownloading.SelectedRows[0].Cells["Extracted"].Value == null ? false : true; var parent = this.Owner as FormMain; switch (data) { case "Unrar": if (extracted) { var responseExtracted = MessageBox.Show("Already extracted. Want to extract again ?", "RAR Extraction", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (responseExtracted == System.Windows.Forms.DialogResult.No) { break; } } if (parent != null) { parent.LaunchAction("Unrar", null, null, selectedXme); } break; case "CheckFile": var found = false; var extractFolder = Path.Combine(ConfigurationManager.AppSettings["Path.Download"], ConfigurationManager.AppSettings["Name.Transfer"], selectedXme.TitleCleaned()); if (Directory.Exists(extractFolder)) { var filenames = Directory.EnumerateFiles(extractFolder, "*.mkv", SearchOption.AllDirectories).ToList(); if (filenames.Count > 0) { found = true; Process.Start(filenames[0]); } } if (!found) { ShowToolTipMessage("Not yet extracted", "File is not present, please extract first", ToolTipIcon.Error); } break; case "DeleteRAR": var fileNames = selectedXme.Filenames.Split(XmlMovieElement.LINK_FILENAME_SEPARATOR); List <string> rarToDelete = new List <string>(fileNames.Length); StringBuilder sb = new StringBuilder(); sb.AppendLine("Are you sure to delete these files : "); foreach (var filename in fileNames) { var fullFilename = Path.Combine(ConfigurationManager.AppSettings["Path.Download"], filename); FileInfo info = new FileInfo(fullFilename); double fileSize = 0.0; try { fileSize = info.Length; // FileNotFoundException } catch (FileNotFoundException) { } finally { sb.AppendFormat("{0:N2} GB - {1}", (double)fileSize / (double)(1024 * 1024 * 1024), fullFilename); sb.AppendLine(); rarToDelete.Add(fullFilename); } } var responseDelete = MessageBox.Show(sb.ToString(), "Delete RAR files", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (responseDelete == System.Windows.Forms.DialogResult.Yes) { foreach (var rar in rarToDelete) { File.Delete(rar); } selectedXme.Status = XmlMovieElement.DownloadStatus.Completed; radGridViewMovieDownloading.Rows.Remove(radGridViewMovieDownloading.SelectedRows[0]); if (parent != null) { parent.WriteDownload(); } } break; } }
private void radButtonDownload_Click(object sender, EventArgs e) { var sbLink = new StringBuilder(); foreach (Link l in checkedListBoxLink.CheckedItems) { sbLink.Append(l.Linkname).Append("\n"); } if (sbLink.ToString().Trim().Length <= 0) { return; } sbLink = sbLink.Remove(sbLink.Length - 1, 1); UtilitySelenium.GetInstance.OpenChromeDriver(); // navigate to the movie page entered UtilitySelenium.GetInstance.NavigateChromeDriver(ConfigurationManager.AppSettings["DownloadUrl"]); IWebElement linksElement; try { // download now link linksElement = UtilitySelenium.GetInstance.ChromeDriver.FindElement(By.Name("links")); } catch (NoSuchElementException) { // failed to get the links textarea, stay on login page return; } linksElement.SendKeys(sbLink.ToString()); if (radCheckBoxHDDLocal.Checked) { UtilitySelenium.GetInstance.ChromeDriver.FindElement(By.Name("local")).Click(); } UtilitySelenium.GetInstance.ChromeDriver.FindElement(By.Name("download")).Click(); while (true) { try { UtilitySelenium.GetInstance.ChromeDriver.FindElement(By.Id("progress")); } catch (NoSuchElementException) { // failed to get the progress loader, continue execution break; } Thread.Sleep(3000); } // check the new links var newLinks = UtilitySelenium.GetInstance.ChromeDriver.FindElement(By.Name("links")).Text; if (!newLinks.Contains("HDD download initiated for file")) { var sbLinks = new StringBuilder(); if (!String.IsNullOrEmpty(newLinks)) { foreach (var newlink in newLinks.Split('\n')) { var uriLink = new Uri(newlink); sbLinks.Append(uriLink.Segments[uriLink.Segments.Length - 1]).Append(XmlMovieElement.LINK_FILENAME_SEPARATOR.ToString()); } // update the selectedXme if (String.IsNullOrEmpty(_selectedXme.Filenames)) { _selectedXme.Filenames = sbLinks.ToString(0, sbLinks.Length - 1); } else { _selectedXme.Filenames = String.Concat(_selectedXme.Filenames, XmlMovieElement.LINK_FILENAME_SEPARATOR.ToString(), sbLinks.ToString(0, sbLinks.Length - 1)); } // remove duplicates filenames _selectedXme.Filenames = XmlMovieElement.CheckDuplicateFilenames(_selectedXme.Filenames); // change download status _selectedXme.Status = XmlMovieElement.DownloadStatus.Downloading; _linkDetail.DownloadLinkStatus = XmlMovieElement.DownloadStatus.OK; // send to massdownloader (via Clipboard) Clipboard.SetText(newLinks); // 28/11/2014 Integrating uGet as default Download Manager // uget.exe --quiet https://www.google.com/test.exe http://ideaof.me/test.exe ftp://server.com/test.exe //var uGet = new Process //{ // StartInfo = // { // FileName = ConfigurationManager.AppSettings["Path.uGet"], // Arguments = String.Format(" --quiet {0}", newLinks.Replace("\r\n", " ")), // WindowStyle = ProcessWindowStyle.Normal // } //}; //uGet.Start(); } else { // error in download links ( 404 or other errors) //TODO replace with balloon message //MessageBox.Show("No links generated.", "Error downloading", MessageBoxButtons.OK, MessageBoxIcon.Error); // change download status _selectedXme.Status = XmlMovieElement.DownloadStatus.New; _linkDetail.DownloadLinkStatus = XmlMovieElement.DownloadStatus.KO; } } else { // MessageBox.Show(@"HDD download", @"You need to check manually."); _selectedXme.Status = XmlMovieElement.DownloadStatus.Downloading; _linkDetail.DownloadLinkStatus = XmlMovieElement.DownloadStatus.OK; } // update image color _selectedLvi.ImageIndex = (int)_selectedXme.Status; // update all nodes in XML _selectedXme.DateModified = DateTime.Now.ToString("dd/MM/yyyy-HH:mm:ss"); var parent = this.Owner as FormMain; if (parent != null) { parent.WriteDownload(); } UtilitySelenium.GetInstance.CloseChromeDriver(true); // close this window Close(); }