/// <summary> /// Shows the Rate Dialog after playback has ended /// </summary> /// <param name="episode">The item being rated</param> internal static void ShowRateDialog(VideoInfo videoInfo) { if (!TraktSettings.ShowRateDialogOnWatched) { return; // not enabled } TraktLogger.Debug("Showing rate dialog for '{0}'", videoInfo.Title); var rateThread = new System.Threading.Thread((o) => { var itemToRate = o as VideoInfo; if (itemToRate == null) { return; } int rating = 0; if (itemToRate.Type == VideoType.Series) { var rateObject = new TraktSyncShowRatedEx { Title = itemToRate.Title, Year = itemToRate.Year.ToNullableInt32(), Seasons = new List <TraktSyncShowRatedEx.Season> { new TraktSyncShowRatedEx.Season { Number = itemToRate.SeasonIdx.ToInt(), Episodes = new List <TraktSyncShowRatedEx.Season.Episode> { new TraktSyncShowRatedEx.Season.Episode { Number = itemToRate.EpisodeIdx.ToInt(), RatedAt = DateTime.UtcNow.ToISO8601() } } } } }; // get the rating submitted to trakt rating = GUIUtils.ShowRateDialog <TraktSyncShowRatedEx>(rateObject); // add episode rated to cache if (rating > 0) { TraktCache.AddEpisodeToRatings( new TraktShow { Ids = new TraktShowId(), Title = rateObject.Title, Year = rateObject.Year, }, new TraktEpisode { Ids = new TraktEpisodeId(), Season = rateObject.Seasons[0].Number, Number = rateObject.Seasons[0].Episodes[0].Number }, rating ); } } else if (itemToRate.Type == VideoType.Movie) { var rateObject = new TraktSyncMovieRated { Ids = new TraktMovieId(), Title = itemToRate.Title, Year = itemToRate.Year.ToNullableInt32(), RatedAt = DateTime.UtcNow.ToISO8601() }; // get the rating submitted to trakt rating = GUIUtils.ShowRateDialog <TraktSyncMovieRated>(rateObject); // add movie rated to cache if (rating > 0) { TraktCache.AddMovieToRatings(rateObject, rating); } else { TraktCache.RemoveMovieFromRatings(rateObject); } } if (rating > 0) { TraktLogger.Debug("Rating {0} as {1}/10", itemToRate.Title, rating.ToString()); } }) { Name = "Rate", IsBackground = true }; rateThread.Start(videoInfo); }
/// <summary> /// Shows the Rate Dialog after playback has ended /// </summary> /// <param name="episode">The item being rated</param> private void ShowRateDialog(ITrackingInfo videoInfo) { if (!TraktSettings.ShowRateDialogOnWatched) { return; } var rateThread = new Thread((objInfo) => { var itemToRate = objInfo as ITrackingInfo; if (itemToRate == null) { return; } int rating = -1; if (itemToRate.VideoKind == VideoKind.TvSeries) { TraktLogger.Info("Showing rate dialog for episode. Title = '{0}', Year = '{1}', IMDb ID = '{2}', TMDb ID = '{3}', Season = '{4}', Episode = '{5}'", itemToRate.Title, itemToRate.Year == 0 ? "<empty>" : itemToRate.Year.ToString(), itemToRate.ID_IMDB.ToLogString(), itemToRate.ID_TMDB.ToLogString(), itemToRate.Episode, itemToRate.Season); // this gets complicated when the episode IDs are not available! var rateObject = new TraktSyncShowRatedEx { Ids = new TraktShowId { Tvdb = itemToRate.ID_TVDB.ToNullableInt32(), Tmdb = itemToRate.ID_TMDB.ToNullableInt32() }, Title = itemToRate.Title, Year = itemToRate.Year > 0 ? (int?)itemToRate.Year : null, Seasons = new List <TraktSyncShowRatedEx.Season> { new TraktSyncShowRatedEx.Season { Number = (int)itemToRate.Season, Episodes = new List <TraktSyncShowRatedEx.Season.Episode> { new TraktSyncShowRatedEx.Season.Episode { Number = (int)itemToRate.Episode, RatedAt = DateTime.UtcNow.ToISO8601() } } } } }; // get the rating submitted to trakt rating = GUIUtils.ShowRateDialog <TraktSyncShowRatedEx>(rateObject); // add episode rated to cache if (rating > 0) { TraktCache.AddEpisodeToRatings( new TraktShow { Ids = rateObject.Ids, Title = rateObject.Title, Year = rateObject.Year, }, new TraktEpisode { Ids = new TraktEpisodeId(), Season = rateObject.Seasons[0].Number, Number = rateObject.Seasons[0].Episodes[0].Number }, rating ); } } else if (itemToRate.VideoKind == VideoKind.Movie) { TraktLogger.Info("Showing rate dialog for movie. Title = '{0}', Year = '{1}', IMDb Id = '{2}', TMDb ID = '{3}'", itemToRate.Title, itemToRate.Year, itemToRate.ID_IMDB.ToLogString(), itemToRate.ID_TMDB.ToLogString()); var rateObject = new TraktSyncMovieRated { Ids = new TraktMovieId { Imdb = itemToRate.ID_IMDB, Tmdb = itemToRate.ID_TMDB.ToNullableInt32() }, Title = itemToRate.Title, Year = (int)itemToRate.Year, RatedAt = DateTime.UtcNow.ToISO8601() }; // get the rating submitted to trakt rating = GUIUtils.ShowRateDialog <TraktSyncMovieRated>(rateObject); // add movie rated to cache if (rating > 0) { TraktCache.AddMovieToRatings(rateObject, rating); } else { TraktCache.RemoveMovieFromRatings(rateObject); } } }) { Name = "Rate", IsBackground = true }; rateThread.Start(videoInfo); }