/// <summary> /// Retrieve information about shows in a specific season /// </summary> /// <param name="year">Year for which season data should be retrieved</param> /// <param name="season">Season for which data should be retrieved</param> /// <returns>Collection of show for the selected season</returns> public async Task <RetrievalWrapper <SeasonShowCollection> > GetSeasonData(int year, Seasons season) { var collectionWrapper = new SeasonShowCollection(); try { var doc = await _pageRetriever.RetrieveHtmlPageAsync(MalRouteBuilder.SeasonUrl(year, season)); if (doc.ResponseStatusCode == null) { throw doc.Exception; } var links = doc.Document.DocumentNode .SelectNodes("//a[@class='link-title']"); foreach (var link in links) { var url = link.Attributes["href"].Value; var idString = url.Split('/')[4]; int id; int.TryParse(idString, out id); var title = link.InnerHtml; var tmpData = new SeasonData { Id = id, Title = title }; collectionWrapper.SeasonShows.Add(tmpData); } return(new RetrievalWrapper <SeasonShowCollection>(doc.ResponseStatusCode.Value, doc.Success, collectionWrapper)); } catch (Exception exception) { return(new RetrievalWrapper <SeasonShowCollection>(exception, collectionWrapper)); } }