/// <summary> /// Processes all badges on page /// </summary> /// <param name="document">HTML document (1 page) from x</param> private void ProcessBadgesOnPage(HtmlDocument document) { foreach (var badge in document.DocumentNode.SelectNodes("//div[@class=\"badge_row is_link\"]")) { var appIdNode = badge.SelectSingleNode(".//a[@class=\"badge_row_overlay\"]").Attributes["href"].Value; var appid = Regex.Match(appIdNode, @"gamecards/(\d+)/").Groups[1].Value; if (string.IsNullOrWhiteSpace(appid) || Settings.Default.blacklist.Contains(appid) || appid == "368020" || appid == "335590" || appIdNode.Contains("border=1")) { continue; } var hoursNode = badge.SelectSingleNode(".//div[@class=\"badge_title_stats_playtime\"]"); var hours = hoursNode == null ? string.Empty : Regex.Match(hoursNode.InnerText, @"[0-9\.,]+").Value; var nameNode = badge.SelectSingleNode(".//div[@class=\"badge_title\"]"); var name = WebUtility.HtmlDecode(nameNode.FirstChild.InnerText).Trim(); var cardNode = badge.SelectSingleNode(".//span[@class=\"progress_info_bold\"]"); var cards = cardNode == null ? string.Empty : Regex.Match(cardNode.InnerText, @"[0-9]+").Value; var badgeInMemory = AllBadges.FirstOrDefault(b => b.StringId == appid); if (badgeInMemory != null) { badgeInMemory.UpdateStats(cards, hours); } else { AllBadges.Add(new Badge(appid, name, cards, hours)); } } }
/// <summary> /// Processes all badges on page /// </summary> /// <param name="document">HTML document (1 page) from x</param> private void ProcessBadgesOnPage(HtmlDocument document) // AKA6 { foreach (var badge in document.DocumentNode.SelectNodes("//div[@class=\"badge_row is_link\"]")) { var appIdNode = badge.SelectSingleNode(".//a[@class=\"badge_row_overlay\"]").Attributes["href"].Value; var appid = Regex.Match(appIdNode, @"gamecards/(\d+)/").Groups[1].Value; if (string.IsNullOrWhiteSpace(appid) || Settings.Default.blacklist.Contains(appid) || appid == "368020" || appid == "335590" || appIdNode.Contains("border=1")) { continue; } var hoursNode = badge.SelectSingleNode(".//div[@class=\"badge_title_stats_playtime\"]"); var hours = hoursNode == null ? string.Empty : Regex.Match(hoursNode.InnerText, @"[0-9\.,]+").Value; var nameNode = badge.SelectSingleNode(".//div[@class=\"badge_title\"]"); var name = WebUtility.HtmlDecode(nameNode.FirstChild.InnerText).Trim(); var cardNode = badge.SelectSingleNode(".//span[@class=\"progress_info_bold\"]"); var cards = cardNode == null ? string.Empty : Regex.Match(cardNode.InnerText, @"[0-9]+").Value; var badgeInMemory = AllBadges.FirstOrDefault(b => b.StringId == appid); if (badgeInMemory != null) { badgeInMemory.UpdateStats(cards, hours); } else { // un 0 antes = desactivado var ets2 = "227300"; var ats = "270880"; // en blacklist var gtav = "271590"; // si no tiene cromos no pasa por la lista var rocket = "0252950"; // Agregamos if para regular que juegos ingresan a la lista // WhiteList if (String.Equals(appid, gtav) || String.Equals(appid, ets2) || String.Equals(appid, ats) || String.Equals(appid, rocket)) { AllBadges.Add(new Badge(appid, name, cards, hours)); } } } }
public async Task LoadBadgesAsync() { var profileLink = Settings.Default.myProfileURL + "/badges"; var document = new HtmlDocument(); var pages = new List <string>() { "?p=1" }; try { for (var i = 0; i < pages.Count; i++) { var response = await CookieClient.GetHttpAsync(profileLink + pages[i]); document.LoadHtml(response); var pageNodes = document.DocumentNode.SelectNodes("//a[@class=\"pagelink\"]"); if (pageNodes != null) { pages.AddRange(pageNodes.Select(p => p.Attributes["href"].Value).Distinct()); pages = pages.Distinct().ToList(); } foreach (var badge in document.DocumentNode.SelectNodes("//div[@class=\"badge_row is_link\"]")) { var appIdNode = badge.SelectSingleNode(".//a[@class=\"badge_row_overlay\"]").Attributes["href"].Value; var appid = Regex.Match(appIdNode, @"gamecards/(\d+)/").Groups[1].Value; if (string.IsNullOrWhiteSpace(appid) || Settings.Default.blacklist.Contains(appid) || appid == "368020" || appid == "335590") { continue; } var hoursNode = badge.SelectSingleNode(".//div[@class=\"badge_title_stats_playtime\"]"); var hours = hoursNode == null ? string.Empty : Regex.Match(hoursNode.InnerText, @"[0-9\.,]+").Value; var nameNode = badge.SelectSingleNode(".//div[@class=\"badge_title\"]"); var name = WebUtility.HtmlDecode(nameNode.FirstChild.InnerText).Trim(); var cardNode = badge.SelectSingleNode(".//span[@class=\"progress_info_bold\"]"); var cards = cardNode == null ? string.Empty : Regex.Match(cardNode.InnerText, @"[0-9]+").Value; var badgeInMemory = AllBadges.FirstOrDefault(b => b.StringId == appid); if (badgeInMemory != null) { badgeInMemory.UpdateStats(cards, hours); } else { AllBadges.Add(new Badge(appid, name, cards, hours)); } } } } catch (Exception ex) { Logger.Exception(ex, "Badge -> LoadBadgesAsync, for profile = " + Settings.Default.myProfileURL); // badge page didn't load picReadingPage.Image = null; lblDrops.Text = "Badge page didn't load, will retry in 10 seconds"; ReloadCount = 10; tmrBadgeReload.Enabled = true; return; } SortBadges(Settings.Default.sort); picReadingPage.Visible = false; UpdateStateInfo(); if (CardsRemaining == 0) { IdleComplete(); } }