Esempio n. 1
0
        private static Match ParseMatch(HtmlNode node, bool playoffs)
        {
            Regex pattern = new Regex(UrlRegex);

            System.Text.RegularExpressions.Match regexMatch = pattern.Match(EventFactory.GetLinkFromUrlNode(node.ChildNodes[6].SelectSingleNode("a")));
            if (!regexMatch.Success)
            {
                throw new Exception($"unable to parse match id {node.ChildNodes[6].InnerHtml}");
            }

            string id = regexMatch.Groups["id"].Value;

            if (CachedMatchExists(id))
            {
                return(null);
            }

            Match match = MatchParser.ParseMatch(id, ParseDateTime(node.ChildNodes[0].InnerText, node.ChildNodes[1].InnerText), playoffs);

            CacheMatch(match, id);
            return(match);
        }
Esempio n. 2
0
        private static List <Player> ParseMatchBoxScore(HtmlNode tableNode)
        {
            List <Player> players = new List <Player>();

            foreach (HtmlNode node in tableNode.ChildNodes)
            {
                if (node.ChildNodes.Count == 0 || node.HasClass("thead"))
                {
                    continue;
                }

                Player player = new Player(node.ChildNodes[0].InnerText);
                player.Id = EventFactory.GetLinkFromUrlNode(node.ChildNodes[0].SelectSingleNode("a"));
                players.Add(player);

                if (node.ChildNodes.Count == 2)
                {
                    switch (node.ChildNodes[1].InnerText)
                    {
                    case "Did Not Play":
                    case "Did Not Dress":
                    case "Player Suspended":
                    case "Not With Team":
                        player.DidNotPlay = true;
                        continue;

                    default:
                        throw new Exception($"could not parse inactive player {node.ChildNodes[1].InnerText}");
                    }
                }

                player.Points = int.Parse(node.ChildNodes[19].InnerText);
            }

            return(players);
        }