internal static void SetMovieProperties(TraktMovieSummary movie) { if (movie == null) return; SetProperty("#Trakt.Movie.Id", movie.Ids.Trakt); SetProperty("#Trakt.Movie.ImdbId", movie.Ids.Imdb); SetProperty("#Trakt.Movie.TmdbId", movie.Ids.Tmdb); SetProperty("#Trakt.Movie.Slug", movie.Ids.Slug); SetProperty("#Trakt.Movie.Certification", movie.Certification); SetProperty("#Trakt.Movie.Overview", movie.Overview.ToNullIfEmpty() == null ? Translation.NoMovieSummary : movie.Overview.RemapHighOrderChars()); SetProperty("#Trakt.Movie.Released", movie.Released); SetProperty("#Trakt.Movie.Language", Translation.GetLanguageFromISOCode(movie.Language)); SetProperty("#Trakt.Movie.Runtime", movie.Runtime); SetProperty("#Trakt.Movie.Tagline", movie.Tagline); SetProperty("#Trakt.Movie.Title", movie.Title.RemapHighOrderChars()); SetProperty("#Trakt.Movie.Trailer", movie.Trailer); SetProperty("#Trakt.Movie.Url", string.Format("http://trakt.tv/movies/{0}", movie.Ids.Slug)); SetProperty("#Trakt.Movie.Year", movie.Year); SetProperty("#Trakt.Movie.Genres", TraktGenres.Translate(movie.Genres)); SetProperty("#Trakt.Movie.InCollection", movie.IsCollected()); SetProperty("#Trakt.Movie.InWatchList", movie.IsWatchlisted()); SetProperty("#Trakt.Movie.Plays", movie.Plays()); SetProperty("#Trakt.Movie.Watched", movie.IsWatched()); SetProperty("#Trakt.Movie.Rating", movie.UserRating()); SetProperty("#Trakt.Movie.Ratings.Percentage", movie.Rating.ToPercentage()); SetProperty("#Trakt.Movie.Ratings.Votes", movie.Votes); SetProperty("#Trakt.Movie.Ratings.Icon", (movie.Rating >= 6) ? "love" : "hate"); }
internal static bool RateMovie(TraktMovieSummary movie) { var rateObject = new TraktSyncMovieRated { Ids = new TraktMovieId { Trakt = movie.Ids.Trakt, Imdb = movie.Ids.Imdb.ToNullIfEmpty(), Tmdb = movie.Ids.Tmdb }, Title = movie.Title, Year = movie.Year, RatedAt = DateTime.UtcNow.ToISO8601() }; int? prevRating = movie.UserRating(); int newRating = 0; newRating = GUIUtils.ShowRateDialog<TraktSyncMovieRated>(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.AddMovieToRatings(movie, newRating); movie.Votes++; } else if (newRating == 0) { // remove from ratings TraktCache.RemoveMovieFromRatings(movie); movie.Votes--; } else { // rating changed, remove then add TraktCache.RemoveMovieFromRatings(movie); TraktCache.AddMovieToRatings(movie, newRating); } // update ratings until next online update // if we have the ratings distribution we could calculate correctly if (movie.Votes == 0) { movie.Rating = 0; } else if (movie.Votes == 1 && newRating > 0) { movie.Rating = newRating; } return true; }