Esempio n. 1
0
        /// <summary>
        /// Rate a single season on trakt.tv (with show info)
        /// </summary>
        public static TraktSyncResponse AddSeasonToRatingsEx(TraktSyncSeasonRatedEx item)
        {
            var seasons = new TraktSyncSeasonsRatedEx
            {
                Shows = new List<TraktSyncSeasonRatedEx>() { item }
            };

            return AddSeasonsToRatingsEx(seasons);
        }
Esempio n. 2
0
        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;
        }
Esempio n. 3
0
        /// <summary>
        /// UnRate a single season on trakt.tv (with show info)
        /// </summary>
        public static TraktSyncResponse RemoveSeasonFromRatingsEx(TraktSyncSeasonRatedEx item)
        {
            var seasons = new TraktSyncSeasonsRatedEx
            {
                Shows = new List<TraktSyncSeasonRatedEx>() { item }
            };

            return RemoveSeasonsFromRatingsEx(seasons);
        }