public static Series ReadFromJson(StreamReader stream, int id) { var watched = new List <int>(); while (stream != null && !stream.EndOfStream) { var watchedId = stream.ReadLine(); if (watchedId == null) { throw new NullReferenceException(); } watched.Add(int.Parse(watchedId)); } var jSeries = ResourceCache.GetResourceOrUpdate("tv/" + id); if (jSeries == null) { return(null); } var show = new Series(jSeries); foreach (var season in show.Seasons) { foreach (var episode in season.Episodes) { episode.Watched = watched.Contains(episode.Id); } } show.UpdateIcon(); return(show); }
public Season(int seriesId, JToken jSeason) { SeasonNumber = (int)jSeason["season_number"]; Episodes = new ObservableCollection <Episode>(); jSeason = ResourceCache.GetResourceOrUpdate(string.Format("tv/{0}/season/{1}", seriesId, SeasonNumber)); if (jSeason == null) { return; } var jEpisodes = jSeason["episodes"].ToArray(); foreach (var jEpisode in jEpisodes) { Episodes.Add(new Episode(jEpisode)); } }