private static bool ProcessXml([NotNull] XElement x, [NotNull] LocalCache cache) { // Will have one or more series, and episodes // all wrapped in <Data> </Data> // e.g.: //<Data> // <Series> // <id>...</id> // etc. // </Series> // <Episode> // <id>...</id> // blah blah // </Episode> // <Episode> // <id>...</id> // blah blah // </Episode> // ... //</Data> try { string time = x.Attribute("time")?.Value; cache.LatestUpdateTime.Load(time); Logger.Info($"Loaded file with updates until {cache.LatestUpdateTime.LastSuccessfulServerUpdateDateTime()}"); foreach (SeriesInfo si in x.Descendants("Series").Select(seriesXml => new SeriesInfo(seriesXml))) { // The <series> returned by GetSeries have // less info than other results from // thetvdb.com, so we need to smartly merge // in a <Series> if we already have some/all // info on it (depending on which one came // first). cache.UpdateSeries(si); } foreach (XElement episodeXml in x.Descendants("Episode")) { Episode e = new Episode(episodeXml); if (e.Ok()) { cache.AddOrUpdateEpisode(e); } else { Logger.Error($"problem with XML recieved {episodeXml}"); } } foreach (XElement banners in x.Descendants("BannersCache")) { //this wil not be found in a standard response from the TVDB website //will only be in the response when we are reading from the cache ProcessXmlBannerCache(banners, cache); } } catch (XmlException e) { string message = "Error processing data from TheTVDB (top level)."; message += "\r\n" + x; message += "\r\n" + e.Message; Logger.Error(message); Logger.Error(x.ToString()); throw new TVDBException(message); } return(true); }