Example #1
0
        public void Execute(FileStore dataStore)
        {
            HtmlNode contentDiv = WebClient.GetWebContentNode(SEASONS_PAGE_URL);

            if (contentDiv == null)
            {
                Log.Error("Seasons page content not found!");
                return;
            }

            var seasons =
                contentDiv.SelectNodes("table[1]//a")
                .Select(node => new Season
            {
                Name = node.InnerText.Replace('/', '-'),
                Url  = node.GetAttributeValue("href", null)
            })
                .Where(s => s.Name.CompareTo("1875") >= 0)
                .OrderBy(s => s.Name).ToList();

            AllSeasons allSeasons = dataStore.Load <AllSeasons>(KEY);

            if (allSeasons == null)
            {
                allSeasons = new AllSeasons {
                    Id = KEY, Seasons = seasons
                };
            }
            else
            {
                allSeasons.Seasons = seasons;
            }

            dataStore.Save(allSeasons, KEY);
        }
Example #2
0
        protected static IEnumerable <Season> GetSeasons(FileStore dataStore, string startSeason, string endSeason)
        {
            AllSeasons allSeasons = dataStore.Load <AllSeasons>("seasons");

            if (allSeasons == null)
            {
                Log.Warn("Seasons page has not been parsed. Please run the 'seasons' command first.");
                return(new Season[0]);
            }
            var seasons = allSeasons.Seasons
                          .Where(x => x.Name.CompareTo(startSeason) >= 0 && x.Name.CompareTo(endSeason) <= 0)
                          .OrderBy(x => x.Name);

            return(seasons);
        }