protected virtual int?GetPeers(XElement item)
        {
            if (ParseSeedersInDescription && item.Element("description") != null)
            {
                var matchPeers = ParsePeersRegex.Match(item.Element("description").Value);

                if (matchPeers.Success)
                {
                    return(int.Parse(matchPeers.Groups["value"].Value));
                }

                var matchSeeders  = ParseSeedersRegex.Match(item.Element("description").Value);
                var matchLeechers = ParseLeechersRegex.Match(item.Element("description").Value);

                if (matchSeeders.Success && matchLeechers.Success)
                {
                    return(int.Parse(matchSeeders.Groups["value"].Value) + int.Parse(matchLeechers.Groups["value"].Value));
                }
            }

            if (PeersElementName.IsNotNullOrWhiteSpace())
            {
                var itempeers = item.FindDecendants(PeersElementName).SingleOrDefault();
                return(int.Parse(itempeers.Value));
            }

            return(null);
        }
        protected virtual int?GetSeeders(XElement item)
        {
            // safe to always use the element if it's present (and valid)
            // fall back to description if ParseSeedersInDescription is enabled

            if (ParseSeedersInDescription && item.Element("description") != null)
            {
                var matchSeeders = ParseSeedersRegex.Match(item.Element("description").Value);

                if (matchSeeders.Success)
                {
                    return(int.Parse(matchSeeders.Groups["value"].Value));
                }

                var matchPeers    = ParsePeersRegex.Match(item.Element("description").Value);
                var matchLeechers = ParseLeechersRegex.Match(item.Element("description").Value);

                if (matchPeers.Success && matchLeechers.Success)
                {
                    return(int.Parse(matchPeers.Groups["value"].Value) - int.Parse(matchLeechers.Groups["value"].Value));
                }
            }
            var seeds = item.FindDecendants(SeedsElementName).SingleOrDefault();

            if (seeds != null)
            {
                return((int)seeds);
            }

            return(null);
        }
Exemple #3
0
        protected virtual int?GetSeeders(XElement item)
        {
            if (ParseSeedersInDescription && item.Element("description") != null)
            {
                var matchSeeders = ParseSeedersRegex.Match(item.Element("description").Value);

                if (matchSeeders.Success)
                {
                    return(int.Parse(matchSeeders.Groups["value"].Value));
                }

                var matchPeers    = ParsePeersRegex.Match(item.Element("description").Value);
                var matchLeechers = ParseLeechersRegex.Match(item.Element("description").Value);

                if (matchPeers.Success && matchLeechers.Success)
                {
                    return(int.Parse(matchPeers.Groups["value"].Value) - int.Parse(matchLeechers.Groups["value"].Value));
                }
            }

            return(null);
        }