Пример #1
0
        private TraktRateSeries CreateSeriesRateData(DBSeries series)
        {
            if (series == null || series[DBOnlineSeries.cTraktIgnore]) return null;

            string rating = series[DBOnlineSeries.cMyRating];

            TraktRateSeries seriesData = new TraktRateSeries()
            {
                Rating = rating,
                SeriesID = series[DBOnlineSeries.cID],
                Year = series.Year,
                Title = series[DBOnlineSeries.cOriginalName],
                UserName = TraktSettings.Username,
                Password = TraktSettings.Password,
            };

            TraktLogger.Info("Rating '{0}' as '{1}/10'", series.ToString(), rating.ToString());
            return seriesData;
        }
Пример #2
0
        internal static bool RateShow(TraktShow show)
        {
            TraktRateSeries rateObject = new TraktRateSeries
            {
                SeriesID = show.Tvdb,
                Title = show.Title,
                Year = show.Year.ToString(),
                Rating = show.RatingAdvanced.ToString(),
                UserName = TraktSettings.Username,
                Password = TraktSettings.Password
            };

            int prevRating = show.RatingAdvanced;
            int newRating = int.Parse(GUIUtils.ShowRateDialog<TraktRateSeries>(rateObject));
            if (newRating == -1) return false;

            // If previous rating not equal to current rating then
            // update skin properties to reflect changes
            // This is not really needed but saves waiting for response
            // from server to calculate fields...we can do it ourselves

            if (prevRating != newRating)
            {
                show.RatingAdvanced = newRating;

                // if not rated previously bump up the votes
                if (prevRating == 0)
                {
                    show.Ratings.Votes++;
                    if (show.RatingAdvanced > 5)
                    {
                        show.Rating = "love";
                        show.Ratings.LovedCount++;
                    }
                    else
                    {
                        show.Rating = "hate";
                        show.Ratings.HatedCount++;
                    }
                }

                if (prevRating != 0 && prevRating > 5 && newRating <= 5)
                {
                    show.Rating = "hate";
                    show.Ratings.LovedCount--;
                    show.Ratings.HatedCount++;
                }

                if (prevRating != 0 && prevRating <= 5 && newRating > 5)
                {
                    show.Rating = "love";
                    show.Ratings.LovedCount++;
                    show.Ratings.HatedCount--;
                }

                if (newRating == 0)
                {
                    if (prevRating <= 5) show.Ratings.HatedCount++;
                    show.Ratings.Votes--;
                    show.Rating = "false";
                }

                // Could be in-accurate, best guess
                if (prevRating == 0)
                {
                    show.Ratings.Percentage = (int)Math.Round(((show.Ratings.Percentage * (show.Ratings.Votes - 1)) + (10 * newRating)) / (float)show.Ratings.Votes);
                }
                else
                {
                    show.Ratings.Percentage = (int)Math.Round(((show.Ratings.Percentage * (show.Ratings.Votes)) + (10 * newRating) - (10 * prevRating)) / (float)show.Ratings.Votes);
                }

                return true;
            }

            return false;
        }
        private void RateShow(TraktTrendingShow show)
        {
            TraktRateSeries rateObject = new TraktRateSeries
            {
                SeriesID = show.Tvdb,
                Title = show.Title,
                Year = show.Year.ToString(),
                Rating = show.Rating,
                UserName = TraktSettings.Username,
                Password = TraktSettings.Password
            };

            string prevRating = show.Rating;
            show.Rating = GUIUtils.ShowRateDialog<TraktRateSeries>(rateObject);

            // if previous rating not equal to current rating then
            // update skin properties to reflect changes so we dont
            // need to re-request from server
            if (prevRating != show.Rating)
            {
                if (prevRating == "false")
                {
                    show.Ratings.Votes++;
                    if (show.Rating == "love")
                        show.Ratings.LovedCount++;
                    else
                        show.Ratings.HatedCount++;
                }

                if (prevRating == "love")
                {
                    show.Ratings.LovedCount--;
                    show.Ratings.HatedCount++;
                }

                if (prevRating == "hate")
                {
                    show.Ratings.LovedCount++;
                    show.Ratings.HatedCount--;
                }

                show.Ratings.Percentage = (int)Math.Round(100 * (show.Ratings.LovedCount / (float)show.Ratings.Votes));
            }
        }
        public static TraktRateSeries CreateShowRateData(string title, string tvdb)
        {
            TraktRateSeries rateObject = new TraktRateSeries
            {
                Title = title,
                SeriesID = tvdb,
                Rating = TraktSettings.ShowAdvancedRatingsDialog ? "7" : "10",
                UserName = TraktSettings.Username,
                Password = TraktSettings.Password
            };

            return rateObject;
        }
Пример #5
0
        private TraktRateSeries CreateSeriesRateData(AnimeSeries series, string rateValue)
        {
            if (series == null || series.TvDB_ID == null) return null;

            string rating = Convert.ToInt32(rateValue).ToString();

            TraktRateSeries seriesData = new TraktRateSeries()
            {
                Rating = rating,
                SeriesID = series.TvDB_ID.ToString(),
                Year = GetStartYear(series),
                Title = series.TvDB_Name,
                UserName = TraktSettings.Username,
                Password = TraktSettings.Password,
            };

            TraktLogger.Info("Rating '{0}' as '{1}'", series.TvDB_Name, rating.ToString());
            return seriesData;
        }
Пример #6
0
        private TraktRateSeries CreateSeriesRateData(AnimeSeries series, string rateValue)
        {
            if (series == null || series.TvDB_ID == null) return null;

            TraktRateValue loveorhate = Convert.ToDouble(rateValue) >= 7.0 ? TraktRateValue.love : TraktRateValue.hate;

            TraktRateSeries seriesData = new TraktRateSeries()
            {
                Rating = loveorhate.ToString(),
                SeriesID = series.TvDB_ID.ToString(),
                Year = GetStartYear(series),
                Title = series.TvDB_Name,
                UserName = TraktSettings.Username,
                Password = TraktSettings.Password,
            };

            TraktLogger.Info("Rating '{0}' as '{1}'", series.TvDB_Name, loveorhate.ToString());
            return seriesData;
        }
        private TraktRateSeries CreateSeriesRateData(DBSeries series)
        {
            if (series == null || series[DBOnlineSeries.cTraktIgnore]) return null;

            TraktRateValue loveorhate = series[DBOnlineSeries.cMyRating] >= 7.0 ? TraktRateValue.love : TraktRateValue.hate;

            TraktRateSeries seriesData = new TraktRateSeries()
            {
                Rating = loveorhate.ToString(),
                SeriesID = series[DBOnlineSeries.cID],
                Year = series.Year,
                Title = series[DBOnlineSeries.cOriginalName],
                UserName = TraktSettings.Username,
                Password = TraktSettings.Password,
            };

            TraktLogger.Info("Rating '{0}' as '{1}'", series.ToString(), loveorhate.ToString());
            return seriesData;
        }
        public static TraktRateSeries CreateShowRateData(string title, string tvdb)
        {
            TraktRateSeries rateObject = new TraktRateSeries
            {
                Title = title,
                SeriesID = tvdb,
                Rating = "love",
                UserName = TraktSettings.Username,
                Password = TraktSettings.Password
            };

            return rateObject;
        }
        private bool RateShow(TraktShow show)
        {
            // init since its not part of the API
            show.Rating = "false";
            bool ratingChanged = false;

            TraktRateSeries rateObject = new TraktRateSeries
            {
                SeriesID = show.Tvdb,
                Title = show.Title,
                Year = show.Year.ToString(),
                Rating = show.Rating,
                UserName = TraktSettings.Username,
                Password = TraktSettings.Password
            };

            string prevRating = show.Rating;
            show.Rating = GUIUtils.ShowRateDialog<TraktRateSeries>(rateObject);

            if (prevRating != show.Rating)
            {
                ratingChanged = true;
            }

            return ratingChanged;
        }