Ejemplo n.º 1
0
        private Tuple <string, IRarity> ExtractExtraInfo(string url)
        {
            string extraHtml = WebUtility.HtmlDecode(_getExtraInfo(BaseUrl + url));

            Match m = _cardImageRegex.Match(extraHtml);

            if (!m.Success)
            {
                throw new ParserException("Could not find Card image in with " + url);
            }
            string pictureUrl = BaseUrl + m.Groups["url"].Value;

            m = _cardRarityRegex.Match(extraHtml);
            if (!m.Success)
            {
                throw new ParserException("Could not find Card rarity in with " + url);
            }
            string rarityString = m.Groups["rarity"].Value.Trim();

            if (rarityString.ToLower() == "mythic")
            {
                rarityString = "mythic rare";
            }
            else if (rarityString.ToLower() == "basic")
            {
                rarityString = "basic land";
            }
            IRarity rarity = MagicDatabase.GetRarity(rarityString);

            if (rarity == null)
            {
                throw new ParserException("Unknown rarity " + rarityString);
            }
            return(new Tuple <string, IRarity>(pictureUrl, rarity));
        }