//string _magnet = string.Empty; public DetailsForm(TorrentzResult sr) { InitializeComponent(); Options.ApplyTheme(this); _result = sr; }
private TorrentzResult GetSearchResult(string hash, string details) { string[] tmpArray = details.Split('|'); _searchResult = new TorrentzResult(); _searchResult.Trackers = new List <string>(); _torrentDates = new List <string>(); _torrentLinks = new List <string>(); //trackerLinks = new List<string>(); _torrentTitle = string.Empty; _torrentContents = string.Empty; _torrentSize = string.Empty; _torrentSeeders = string.Empty; _torrentLeechers = string.Empty; _searchResult.InfoHash = hash.Replace("/", string.Empty); if (tmpArray[0] == _verifiedChar.ToString()) { _torrentVerified = string.Format("[{0}]", _verifiedChar); } else { _torrentVerified = "[-]"; } _torrentSize = tmpArray[2]; _torrentSeeders = tmpArray[3]; _torrentLeechers = tmpArray[4]; _document = new HtmlAgilityPack.HtmlDocument(); _response = _client.DownloadString(_baseUrl + hash); _document.LoadHtml(_response); var downloadNode = _document.DocumentNode.SelectSingleNode("//div[@class='downlinks']"); var trackersNode = _document.DocumentNode.SelectSingleNode("//div[@class='trackers']"); var filesNode = _document.DocumentNode.SelectSingleNode("//div[@class='files']"); if (downloadNode != null) { var datesNode = downloadNode.SelectNodes("//span[@title]"); var titleNode = downloadNode.SelectSingleNode("//h2"); var dtNode = downloadNode.SelectNodes("//dt"); if (datesNode != null) { foreach (var d in datesNode) { _torrentDates.Add(d.InnerHtml.Trim()); } } if (titleNode != null) { string[] tmp = titleNode.InnerHtml.Split(new string[] { "</span>" }, StringSplitOptions.RemoveEmptyEntries); tmp[0] = tmp[0].Replace("<span>", string.Empty); _torrentTitle = tmp[0].Trim(); } if (dtNode != null) { foreach (var dt in dtNode) { var linkNode = dt.SelectNodes("//a[@href]"); //var siteNode = dt.SelectNodes("//span[@class='u']"); var nameNode = dt.SelectNodes("//span[@class='n']"); if (linkNode != null) { foreach (var c in linkNode) { if (!_torrentLinks.Contains(c.GetAttributeValue("href", string.Empty))) { _torrentLinks.Add(c.GetAttributeValue("href", string.Empty)); } } //FilterResults(ref torrentLinks); } //if (siteNode != null) //{ // foreach (var sn in siteNode) // { // if (!IsOnlyDigits(sn.InnerText)) // { // if (!trackerLinks.Contains(sn.InnerText)) // { // trackerLinks.Add(sn.InnerText); // } // } // } //} } } _searchResult.Dates = _torrentDates; _searchResult.Age = _torrentDates[0]; _searchResult.Links = _torrentLinks; _searchResult.Title = _torrentTitle; _searchResult.Dates.Remove(_searchResult.Dates.Last()); //SearchResult.Dates.Remove(SearchResult.Dates.First()); //SearchResult.Trackers = trackerLinks; _searchResult.Leechers = _torrentLeechers; _searchResult.Seeders = _torrentSeeders; _searchResult.Size = _torrentSize; _searchResult.Verified = _torrentVerified; } if (trackersNode != null) { var dtNodes = trackersNode.SelectNodes("//dt"); if (dtNodes != null) { foreach (var dt in dtNodes) { if (dt.InnerText.Contains("://")) { _searchResult.Trackers.Add(dt.InnerText.Trim()); } } } } if (filesNode != null) { var liNodes = filesNode.SelectNodes("//li[@class='t']"); if (liNodes != null) { foreach (var li in liNodes) { _torrentContents = SanitizeTorrentContents(li.InnerHtml); break; } } } _searchResult.Contents = _torrentContents; return(_searchResult); }