internal static void SetSeasonProperties(TraktShowSummary show, TraktSeasonSummary season) { SetProperty("#Trakt.Season.TmdbId", season.Ids.Tmdb); SetProperty("#Trakt.Season.TvdbId", season.Ids.Tvdb); SetProperty("#Trakt.Season.TvRageId", season.Ids.TvRage); SetProperty("#Trakt.Season.Number", season.Number); SetProperty("#Trakt.Season.Url", string.Format("http://trakt.tv/shows/{0}/seasons/{1}", show.Ids.Slug, season.Number)); //SetProperty("#Trakt.Season.PosterImageFilename", season.Images == null ? string.Empty : season.Images.Poster.LocalImageFilename(ArtworkType.SeasonPoster)); SetProperty("#Trakt.Season.EpisodeCount", season.EpisodeCount); SetProperty("#Trakt.Season.EpisodeAiredCount", season.EpisodeAiredCount); SetProperty("#Trakt.Season.Overview", season.Overview ?? show.Overview); SetProperty("#Trakt.Season.Watched", season.IsWatched(show)); SetProperty("#Trakt.Season.Plays", season.Plays(show)); SetProperty("#Trakt.Season.InCollection", season.IsCollected(show)); SetProperty("#Trakt.Season.InWatchList", season.IsWatchlisted(show)); SetProperty("#Trakt.Season.Collected", season.Collected(show)); SetProperty("#Trakt.Season.Rating", season.UserRating(show)); SetProperty("#Trakt.Season.Ratings.Percentage", season.Rating.ToPercentage()); SetProperty("#Trakt.Season.Ratings.Votes", season.Votes); SetProperty("#Trakt.Season.Ratings.Icon", (season.Rating >= 6) ? "love" : "hate"); }
internal static bool RateSeason(TraktShowSummary show, TraktSeasonSummary season) { var rateObject = new TraktSyncSeasonRatedEx { Ids = show.Ids, Title = show.Title, Year = show.Year, Seasons = new List<TraktSyncSeasonRatedEx.Season> { new TraktSyncSeasonRatedEx.Season { Number = season.Number, RatedAt = DateTime.UtcNow.ToISO8601() } } }; int? prevRating = season.UserRating(show); int newRating = 0; newRating = GUIUtils.ShowRateDialog<TraktSyncSeasonRatedEx>(rateObject); if (newRating == -1) return false; // If previous rating not equal to current rating then // update skin properties to reflect changes if (prevRating == newRating) return false; if (prevRating == null || prevRating == 0) { // add to ratings TraktCache.AddSeasonToRatings(show, season, newRating); season.Votes++; } else if (newRating == 0) { // remove from ratings TraktCache.RemoveSeasonFromRatings(show, season); season.Votes--; } else { // rating changed, remove then add TraktCache.RemoveSeasonFromRatings(show, season); TraktCache.AddSeasonToRatings(show, season, newRating); } // update ratings until next online update // if we have the ratings distribution we could calculate correctly if (season.Votes == 0) { season.Rating = 0; } else if (season.Votes == 1 && newRating > 0) { season.Rating = newRating; } return true; }