コード例 #1
0
 public static void ShowEpisodeShouts(TraktShowSummary show, TraktEpisodeSummary episode)
 {
     var showImages = TmdbCache.GetShowImages(show.Ids.Tmdb, true);
     ShowEpisodeShouts(show.Title, show.Year, show.Ids.Tvdb, show.Ids.Trakt, show.Ids.Imdb, episode.Season, episode.Number, episode.IsWatched(show), TmdbCache.GetShowBackdropFilename(showImages), TmdbCache.GetShowBackdropUrl(showImages));
 }
コード例 #2
0
        internal static bool RateShow(TraktShowSummary show)
        {
            var rateObject = new TraktSyncShowRated
            {
                Ids = new TraktShowId
                {
                    Trakt = show.Ids.Trakt,
                    Imdb = show.Ids.Imdb.ToNullIfEmpty(),
                    Tmdb = show.Ids.Tmdb,
                    TvRage = show.Ids.TvRage,
                    Tvdb = show.Ids.Tvdb
                },
                Title = show.Title,
                Year = show.Year,
                RatedAt = DateTime.UtcNow.ToISO8601()
            };

            int? prevRating = show.UserRating();
            int newRating = 0;

            newRating = GUIUtils.ShowRateDialog<TraktSyncShowRated>(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.AddShowToRatings(show, newRating);
                show.Votes++;
            }
            else if (newRating == 0)
            {
                // remove from ratings
                TraktCache.RemoveShowFromRatings(show);
                show.Votes--;
            }
            else
            {
                // rating changed, remove then add
                TraktCache.RemoveShowFromRatings(show);
                TraktCache.AddShowToRatings(show, newRating);
            }

            // update ratings until next online update
            // if we have the ratings distribution we could calculate correctly
            if (show.Votes == 0)
            {
                show.Rating = 0;
            }
            else if (show.Votes == 1 && newRating > 0)
            {
                show.Rating = newRating;
            }

            return true;
        }
コード例 #3
0
 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");
 }
コード例 #4
0
        internal static void CheckAndPlayEpisode(TraktShowSummary show, TraktEpisodeSummary episode)
        {
            if (show == null || episode == null) return;

            CurrentMediaType = MediaType.Show;
            CurrentShow = show;

            // check for parental controls
            if (PromptForPinCode)
            {
                if (!GUIUtils.ShowPinCodeDialog(TraktSettings.ParentalControlsPinCode))
                {
                    TraktLogger.Warning("Parental controls pin code has not successfully been entered. Window ID = {0}", GUIWindowManager.ActiveWindow);
                    return;
                }
            }

            bool handled = false;

            // check if plugin is installed and enabled
            if (TraktHelper.IsMPTVSeriesAvailableAndEnabled)
            {
                // Play episode if it exists
                handled = TraktHandlers.TVSeries.PlayEpisode(show.Ids.Tvdb.GetValueOrDefault(), episode.Season, episode.Number);
            }

            if (TraktHelper.IsTrailersAvailableAndEnabled && handled == false)
            {
                TraktLogger.Info("There were no episodes found in local plugin databases. Attempting to search and/or play trailer(s) from the Trailers plugin");
                ShowTVEpisodeTrailersPluginMenu(show, episode);
                handled = true;
            }
        }
コード例 #5
0
        internal static bool RateEpisode(TraktShowSummary show, TraktEpisodeSummary episode)
        {
            // this object will work without episode ids
            var rateObjectEx = new TraktSyncShowRatedEx
            {
                Ids = show.Ids,
                Title = show.Title,
                Year = show.Year,
                Seasons = new List<TraktSyncShowRatedEx.Season>
                {
                    new TraktSyncShowRatedEx.Season
                    {
                        Number = episode.Season,
                        Episodes = new List<TraktSyncShowRatedEx.Season.Episode>
                        {
                            new TraktSyncShowRatedEx.Season.Episode
                            {
                                Number = episode.Number,
                                RatedAt = DateTime.UtcNow.ToISO8601()
                            }
                        }
                    }
                }
            };

            // only use if we have episode ids
            var rateObject = new TraktSyncEpisodeRated
            {
                Ids = new TraktEpisodeId
                {
                    Trakt = episode.Ids.Trakt,
                    Imdb = episode.Ids.Imdb.ToNullIfEmpty(),
                    Tmdb = episode.Ids.Tmdb,
                    Tvdb = episode.Ids.Tvdb,
                    TvRage = episode.Ids.TvRage
                },
                Title = episode.Title,
                Season = episode.Season,
                Number = episode.Number,
                RatedAt = DateTime.UtcNow.ToISO8601()
            };

            int? prevRating = episode.UserRating(show);
            int newRating = 0;

            if (episode.Ids == null || episode.Ids.Trakt == null)
            {
                newRating = GUIUtils.ShowRateDialog<TraktSyncShowRatedEx>(rateObjectEx);
            }
            else
            {
                newRating = GUIUtils.ShowRateDialog<TraktSyncEpisodeRated>(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.AddEpisodeToRatings(show, episode, newRating);
                episode.Votes++;
            }
            else if (newRating == 0)
            {
                // remove from ratings
                TraktCache.RemoveEpisodeFromRatings(episode);
                episode.Votes--;
            }
            else
            {
                // rating changed, remove then add
                TraktCache.RemoveEpisodeFromRatings(episode);
                TraktCache.AddEpisodeToRatings(show, episode, newRating);
            }

            // update ratings until next online update
            // if we have the ratings distribution we could calculate correctly
            if (episode.Votes == 0)
            {
                episode.Rating = 0;
            }
            else if (episode.Votes == 1 && newRating > 0)
            {
                episode.Rating = newRating;
            }

            return true;
        }
コード例 #6
0
        public static bool ShowTraktExtTVShowMenu(string title, string year, string tvdbid, string imdbid, string fanart, SearchPeople people, bool showAll)
        {
            var dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
            dlg.Reset();
            dlg.SetHeading(GUIUtils.PluginName());

            GUIListItem pItem = new GUIListItem(Translation.Comments);
            dlg.Add(pItem);
            pItem.ItemId = (int)TraktMenuItems.Shouts;

            pItem = new GUIListItem(Translation.Rate);
            dlg.Add(pItem);
            pItem.ItemId = (int)TraktMenuItems.Rate;

            pItem = new GUIListItem(Translation.RelatedShows);
            dlg.Add(pItem);
            pItem.ItemId = (int)TraktMenuItems.Related;

            pItem = new GUIListItem(Translation.ShowSeasonInfo);
            dlg.Add(pItem);
            pItem.ItemId = (int)TraktMenuItems.ShowSeasonInfo;

            pItem = new GUIListItem(Translation.AddToWatchList);
            dlg.Add(pItem);
            pItem.ItemId = (int)TraktMenuItems.AddToWatchList;

            pItem = new GUIListItem(Translation.AddToList);
            dlg.Add(pItem);
            pItem.ItemId = (int)TraktMenuItems.AddToCustomList;

            pItem = new GUIListItem(Translation.Cast);
            dlg.Add(pItem);
            pItem.ItemId = (int)TraktMenuItems.Cast;

            pItem = new GUIListItem(Translation.Crew);
            dlg.Add(pItem);
            pItem.ItemId = (int)TraktMenuItems.Crew;

            // Show SearchBy menu...
            if (people != null && people.Count != 0)
            {
                pItem = new GUIListItem(Translation.SearchBy + "...");
                dlg.Add(pItem);
                pItem.ItemId = (int)TraktMenuItems.SearchBy;
            }

            // also show non-context sensitive items related to shows
            if (showAll)
            {
                // might want to check your recently watched, stats etc
                pItem = new GUIListItem(Translation.UserProfile);
                dlg.Add(pItem);
                pItem.ItemId = (int)TraktMenuItems.UserProfile;

                pItem = new GUIListItem(Translation.Network);
                dlg.Add(pItem);
                pItem.ItemId = (int)TraktMenuItems.Network;

                pItem = new GUIListItem(Translation.Calendar);
                dlg.Add(pItem);
                pItem.ItemId = (int)TraktMenuItems.Calendar;

                pItem = new GUIListItem(Translation.Recommendations);
                dlg.Add(pItem);
                pItem.ItemId = (int)TraktMenuItems.Recommendations;

                pItem = new GUIListItem(Translation.Trending);
                dlg.Add(pItem);
                pItem.ItemId = (int)TraktMenuItems.Trending;

                pItem = new GUIListItem(Translation.Popular);
                dlg.Add(pItem);
                pItem.ItemId = (int)TraktMenuItems.Popular;

                pItem = new GUIListItem(Translation.Anticipated);
                dlg.Add(pItem);
                pItem.ItemId = (int)TraktMenuItems.Anticipated;

                pItem = new GUIListItem(Translation.WatchList);
                dlg.Add(pItem);
                pItem.ItemId = (int)TraktMenuItems.WatchList;

                pItem = new GUIListItem(Translation.Lists);
                dlg.Add(pItem);
                pItem.ItemId = (int)TraktMenuItems.Lists;
            }

            // Show Context Menu
            dlg.DoModal(GUIWindowManager.ActiveWindow);
            if (dlg.SelectedId < 0) return false;

            switch (dlg.SelectedId)
            {
                case ((int)TraktMenuItems.Rate):
                    TraktLogger.Info("Displaying rate dialog for tv show. Title = '{0}', Year = '{1}', TVDb ID = '{2}'", title, year.ToLogString(), tvdbid.ToLogString());
                    var show = new TraktSyncShowRated
                    {
                        Ids = new TraktShowId { Tvdb = tvdbid.ToNullableInt32(), Imdb = imdbid.ToNullIfEmpty() },
                        Title = title,
                        Year = year.ToNullableInt32()
                    };
                    int rating = GUIUtils.ShowRateDialog<TraktSyncShowRated>(show);

                    // update local databases
                    if (rating >= 0)
                    {
                        switch (GUIWindowManager.ActiveWindow)
                        {
                            case (int)ExternalPluginWindows.TVSeries:
                                TraktHandlers.TVSeries.SetShowUserRating(rating);
                                break;
                        }

                        if (rating == 0)
                            TraktCache.RemoveShowFromRatings(show);
                        else
                            TraktCache.AddShowToRatings(show, rating);
                    }
                    break;

                case ((int)TraktMenuItems.Shouts):
                    TraktLogger.Info("Displaying Shouts for tv show. Title = '{0}', Year = '{1}', TVDb ID = '{2}', IMDb ID = '{3}'", title, year.ToLogString(), tvdbid.ToLogString(), imdbid.ToLogString());
                    TraktHelper.ShowTVShowShouts(title, year.ToNullableInt32(), tvdbid.ToNullableInt32(), null, imdbid, false, fanart);
                    break;

                case ((int)TraktMenuItems.Related):
                    TraktLogger.Info("Displaying Related shows for tv show. Title = '{0}', Year = '{1}', TVDb ID = '{2}'", title, year.ToLogString(), tvdbid.ToLogString());
                    TraktHelper.ShowRelatedShows(title, year.ToNullableInt32(), tvdbid.ToNullableInt32(), imdbid.ToNullIfEmpty(), null, null);
                    break;

                case ((int)TraktMenuItems.ShowSeasonInfo):
                    TraktLogger.Info("Displaying Season Info for tv show. Title = '{0}', Year = '{1}', TVDb ID = '{2}'", title, year.ToLogString(), tvdbid.ToLogString());
                    var showSummary = new TraktShowSummary
                    {
                        Ids = new TraktShowId
                        {
                            Imdb = imdbid.ToNullIfEmpty(),
                            Tvdb = tvdbid.ToNullableInt32()
                        },
                        Title = title,
                        Year = year.ToNullableInt32()
                    };
                    GUIShowSeasons.Fanart = fanart;
                    GUIWindowManager.ActivateWindow((int)TraktGUIWindows.ShowSeasons, showSummary.ToJSON());
                    break;

                case ((int)TraktMenuItems.AddToWatchList):
                    TraktLogger.Info("Adding tv show to Watchlist. Title = '{0}', Year = '{1}', TVDb ID = '{2}'", title, year.ToLogString(), tvdbid.ToLogString());
                    TraktHelper.AddShowToWatchList(title, year.ToNullableInt32(), tvdbid.ToNullableInt32(), imdbid.ToNullIfEmpty(), null, null);
                    break;

                case ((int)TraktMenuItems.AddToCustomList):
                    TraktLogger.Info("Adding tv show to Custom List. Title = '{0}', Year = '{1}', TVDb ID = '{2}'", title, year.ToLogString(), tvdbid.ToLogString());
                    TraktHelper.AddRemoveShowInUserList(title, year, tvdbid, false);
                    break;

                case ((int)TraktMenuItems.Cast):
                    TraktLogger.Info("Displaying Cast for show. Title = '{0}', Year = '{1}', IMDb ID = '{2}'", title, year.ToLogString(), imdbid.ToLogString());
                    GUICreditsShow.Show = null;
                    GUICreditsShow.Type = GUICreditsShow.CreditType.Cast;
                    GUICreditsShow.Fanart = fanart;
                    GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow, imdbid);
                    break;

                case ((int)TraktMenuItems.Crew):
                    TraktLogger.Info("Displaying Crew for show. Title = '{0}', Year = '{1}', IMDb ID = '{2}'", title, year.ToLogString(), imdbid.ToLogString());
                    GUICreditsShow.Show = null;
                    GUICreditsShow.Type = GUICreditsShow.CreditType.Crew;
                    GUICreditsShow.Fanart = fanart;
                    GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow, imdbid);
                    break;
                case ((int)TraktMenuItems.SearchBy):
                    ShowSearchByMenu(people, title, fanart);
                    break;

                case ((int)TraktMenuItems.UserProfile):
                    GUIWindowManager.ActivateWindow((int)TraktGUIWindows.UserProfile);
                    break;

                case ((int)TraktMenuItems.Network):
                    GUIWindowManager.ActivateWindow((int)TraktGUIWindows.Network);
                    break;

                case ((int)TraktMenuItems.Calendar):
                    GUIWindowManager.ActivateWindow((int)TraktGUIWindows.Calendar);
                    break;

                case ((int)TraktMenuItems.Recommendations):
                    GUIWindowManager.ActivateWindow((int)TraktGUIWindows.RecommendationsShows);
                    break;

                case ((int)TraktMenuItems.Trending):
                    GUIWindowManager.ActivateWindow((int)TraktGUIWindows.TrendingShows);
                    break;

                case ((int)TraktMenuItems.Popular):
                    GUIWindowManager.ActivateWindow((int)TraktGUIWindows.PopularShows);
                    break;

                case ((int)TraktMenuItems.Anticipated):
                    GUIWindowManager.ActivateWindow((int)TraktGUIWindows.AnticipatedShows);

                    break;
                case ((int)TraktMenuItems.WatchList):
                    GUIWindowManager.ActivateWindow((int)TraktGUIWindows.WatchedListShows);
                    break;

                case ((int)TraktMenuItems.Lists):
                    GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CustomLists);
                    break;
            }
            return true;
        }
コード例 #7
0
        public static void ShowTVShowTrailersMenu(TraktShowSummary show, TraktEpisodeSummary episode = null)
        {
            if (TraktHelper.IsTrailersAvailableAndEnabled)
            {
                CurrentMediaType = MediaType.Show;
                CurrentShow = show;

                // check for parental controls
                if (PromptForPinCode)
                {
                    if (!GUIUtils.ShowPinCodeDialog(TraktSettings.ParentalControlsPinCode))
                    {
                        TraktLogger.Warning("Parental controls pin code has not successfully been entered. Window ID = {0}", GUIWindowManager.ActiveWindow);
                        return;
                    }
                }

                if (episode == null)
                    ShowTVShowTrailersPluginMenu(show);
                else
                    ShowTVEpisodeTrailersPluginMenu(show, episode);

                return;
            }
        }
コード例 #8
0
        /// <summary>
        /// Use this method when no Episode Ids are available
        /// </summary>
        public static void RemoveEpisodeFromWatchList(TraktShowSummary show, TraktEpisodeSummary episode)
        {
            var episodeSync = new TraktSyncShowEx
            {
                Title = show.Title,
                Year = show.Year,
                Ids = show.Ids,
                Seasons = new List<TraktSyncShowEx.Season>
                {
                   new TraktSyncShowEx.Season
                   {
                       Number = episode.Season,
                       Episodes = new List<TraktSyncShowEx.Season.Episode>
                       {
                           new TraktSyncShowEx.Season.Episode
                           {
                               Number = episode.Number
                           }
                       }
                   }
                }
            };

            var syncThread = new Thread((objSyncData) =>
            {
                var response = TraktAPI.TraktAPI.RemoveShowFromWatchlistEx(objSyncData as TraktSyncShowEx);
                TraktLogger.LogTraktResponse<TraktSyncResponse>(response);

                TraktCache.RemoveEpisodeFromWatchlist(show, episode);
            })
            {
                IsBackground = true,
                Name = "RemoveWatchlist"
            };

            syncThread.Start(episodeSync);
        }
コード例 #9
0
        public static bool IsWatched(this TraktSeasonSummary season, TraktShowSummary show)
        {
            if (season.EpisodeCount == 0 || season.EpisodeAiredCount == 0)
                return false;

            var watchedEpisodes = TraktCache.WatchedEpisodes;
            if (watchedEpisodes == null)
                return false;

            // check that the seasons aired episode count >= episodes watched in season
            // trakt does not include specials in count, nor should we
            int watchedEpisodeCount = watchedEpisodes.Where(e => (((e.ShowId == show.Ids.Trakt) && e.ShowId != null) || ((e.ShowTvdbId == show.Ids.Tvdb) && show.Ids.Tvdb != null)) &&
                                                                    e.Season == season.Number).Count();
            return watchedEpisodeCount >= season.EpisodeAiredCount;
        }
コード例 #10
0
 public static void AddRemoveShowInUserList(TraktShowSummary show, bool remove)
 {
     AddRemoveShowInUserList(TraktSettings.Username, show.Title, show.Year, show.Ids.Tvdb, show.Ids.Imdb, show.Ids.Tmdb, show.Ids.Trakt, remove);
 }
コード例 #11
0
 public static void AddSeasonToWatchList(TraktShowSummary show, int season)
 {
     AddSeasonToWatchList(show.Title, show.Year, season, show.Ids.Tvdb, show.Ids.Imdb, show.Ids.Tmdb, show.Ids.Trakt);
 }
コード例 #12
0
 public static void ShowTVShowShouts(TraktShowSummary show)
 {
     var images = TmdbCache.GetShowImages(show.Ids.Tmdb, true);
     ShowTVShowShouts(show.Title, show.Year, show.Ids.Tvdb, show.Ids.Trakt, show.Ids.Imdb, show.IsWatched(), TmdbCache.GetShowBackdropFilename(images), TmdbCache.GetShowBackdropUrl(images));
 }
コード例 #13
0
 public static void ShowTVSeasonShouts(TraktShowSummary show, TraktSeasonSummary season)
 {
     var showImages = TmdbCache.GetShowImages(show.Ids.Tmdb, true);
     ShowTVSeasonShouts(show.Title, show.Year, show.Ids.Tvdb, show.Ids.Trakt, show.Ids.Imdb, season.Number, season.IsWatched(show), TmdbCache.GetShowBackdropFilename(showImages), TmdbCache.GetShowBackdropUrl(showImages));
 }
コード例 #14
0
 public static void ShowRelatedShows(TraktShowSummary show)
 {
     ShowRelatedShows(show.Title, show.Year, show.Ids.Tvdb, show.Ids.Imdb, show.Ids.Tmdb, show.Ids.Trakt);
 }
コード例 #15
0
        private void GetShowDetail()
        {
            // check if we need to fetch the show detail as well
            // currently the season API does not give back any show
            // summary info except for images
            if (Show.UpdatedAt == null)
            {
                string slug = Show.Ids.Trakt.ToString();
                if (string.IsNullOrEmpty(slug))
                {
                    if (Show.Ids.Imdb != null)
                    {
                        slug = Show.Ids.Imdb;
                    }
                    else
                    {
                        slug = Show.Title.StripYear(Show.Year).ToSlug();
                    }
                }

                var showSummary = TraktAPI.TraktAPI.GetShowSummary(slug);
                if (showSummary != null)
                {
                    Show = showSummary;

                    // Load Show Properties
                    PublishShowSkinProperties(Show);

                    // Publish Fanart
                    var showImages = TmdbCache.GetShowImages(showSummary.Ids.Tmdb);
                    var showBackdropFilename = TmdbCache.GetShowBackdropFilename(showImages);
                    if (showBackdropFilename == null)
                        return;

                    if (File.Exists(showBackdropFilename))
                    {
                        GUIUtils.SetProperty("#Trakt.Show.Fanart", showBackdropFilename);
                    }
                }
            }
        }
コード例 #16
0
        public static bool IsWatchlisted(this TraktSeasonSummary season, TraktShowSummary show)
        {
            if (WatchListSeasons == null)
                return false;

            return WatchListSeasons.Any(s => ((((s.Show.Ids.Trakt == show.Ids.Trakt) && s.Show.Ids.Trakt != null) || ((s.Show.Ids.Tvdb == show.Ids.Tvdb) && show.Ids.Tvdb != null))) &&
                                                 s.Season.Number == season.Number);
        }
コード例 #17
0
 private void PublishShowSkinProperties(TraktShowSummary show)
 {
     GUICommon.SetShowProperties(show);
 }
コード例 #18
0
        public static int Plays(this TraktSeasonSummary season, TraktShowSummary show)
        {
            var watchedEpisodes = TraktCache.WatchedEpisodes;
            if (watchedEpisodes == null)
                return 0;

            // sum up all the plays per episode in season
            return watchedEpisodes.Where(e => e.ShowId == show.Ids.Trakt && e.Season == season.Number).Sum(e => e.Plays);
        }
コード例 #19
0
        public static void ShowTVSeasonTrailersPluginMenu(TraktShowSummary show, int season)
        {
            CurrentMediaType = MediaType.Show;
            CurrentShow = show;

            // check for parental controls
            if (PromptForPinCode)
            {
                if (!GUIUtils.ShowPinCodeDialog(TraktSettings.ParentalControlsPinCode))
                {
                    TraktLogger.Warning("Parental controls pin code has not successfully been entered. Window ID = {0}", GUIWindowManager.ActiveWindow);
                    return;
                }
            }

            var showImages = TmdbCache.GetShowImages(show.Ids.Tmdb, true);
            var trailerItem = new MediaItem
            {
                MediaType = MediaItemType.Season,
                IMDb = show.Ids.Imdb.ToNullIfEmpty(),
                TMDb = show.Ids.Tmdb.ToString(),
                TVDb = show.Ids.Tvdb.ToString(),
                TVRage = show.Ids.TvRage.ToString(),
                Plot = show.Overview,
                Poster = TmdbCache.GetShowPosterFilename(showImages),
                Title = show.Title,
                Year = show.Year.GetValueOrDefault(0),
                AirDate = show.FirstAired.FromISO8601().ToString("yyyy-MM-dd"),
                Season = season
            };
            Trailers.Trailers.SearchForTrailers(trailerItem);
        }
コード例 #20
0
        public static int? UserRating(this TraktSeasonSummary season, TraktShowSummary show)
        {
            if (RatedSeasons == null)
                return null;

            var ratedSeason = RatedSeasons.FirstOrDefault(s => ((((s.Show.Ids.Trakt == show.Ids.Trakt) && s.Show.Ids.Trakt != null) || ((s.Show.Ids.Tvdb == show.Ids.Tvdb) && show.Ids.Tvdb != null))) &&
                                                                 s.Season.Number == season.Number);

            if (ratedSeason == null)
                return null;

            return ratedSeason.Rating;
        }
コード例 #21
0
 public static void ShowTVShowTrailersPluginMenu(TraktShowSummary show)
 {
     var showImages = TmdbCache.GetShowImages(show.Ids.Tmdb, true);
     var trailerItem = new MediaItem
     {
         MediaType = MediaItemType.Show,
         IMDb = show.Ids.Imdb.ToNullIfEmpty(),
         TVDb = show.Ids.Tvdb.ToString(),
         TVRage = show.Ids.TvRage.ToString(),
         TMDb = show.Ids.Tmdb.ToString(),
         Plot = show.Overview,
         Poster = TmdbCache.GetShowPosterFilename(showImages),
         Title = show.Title,
         Year = show.Year.GetValueOrDefault(0),
         AirDate = show.FirstAired.FromISO8601().ToString("yyyy-MM-dd")
     };
     Trailers.Trailers.SearchForTrailers(trailerItem);
 }
コード例 #22
0
        internal static void AddEpisodeToWatchlist(TraktShowSummary show, TraktEpisodeSummary episode)
        {
            var watchlistEpisodes = (_WatchListEpisodes ?? new List<TraktEpisodeWatchList>()).ToList();

            watchlistEpisodes.Add(new TraktEpisodeWatchList
            {
                ListedAt = DateTime.UtcNow.ToISO8601(),
                Show = show,
                Episode = episode
            });

            _WatchListEpisodes = watchlistEpisodes;
        }
コード例 #23
0
        internal static void CheckAndPlayFirstUnwatchedEpisode(TraktShowSummary show, bool jumpTo)
        {
            if (show == null) return;

            CurrentMediaType = MediaType.Show;
            CurrentShow = show;

            // check for parental controls
            if (PromptForPinCode)
            {
                if (!GUIUtils.ShowPinCodeDialog(TraktSettings.ParentalControlsPinCode))
                {
                    TraktLogger.Warning("Parental controls pin code has not successfully been entered. Window ID = {0}", GUIWindowManager.ActiveWindow);
                    return;
                }
            }

            TraktLogger.Info("Attempting to play episodes for tv show. TVDb ID = '{0}', IMDb ID = '{1}'", show.Ids.Tvdb.ToLogString(), show.Ids.Imdb.ToLogString());
            bool handled = false;

            // check if plugin is installed and enabled
            if (TraktHelper.IsMPTVSeriesAvailableAndEnabled)
            {
                if (jumpTo)
                {
                    TraktLogger.Info("Looking for tv shows in MP-TVSeries database");
                    if (TraktHandlers.TVSeries.SeriesExists(show.Ids.Tvdb.GetValueOrDefault()))
                    {
                        string loadingParameter = string.Format("seriesid:{0}", show.Ids.Tvdb.GetValueOrDefault());
                        GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.TVSeries, loadingParameter);
                        handled = true;
                    }
                }
                else
                {
                    // Play episode if it exists
                    TraktLogger.Info("Checking if any episodes to watch in MP-TVSeries");
                    handled = TraktHandlers.TVSeries.PlayFirstUnwatchedEpisode(show.Ids.Tvdb.GetValueOrDefault());
                }
            }

            if (TraktHelper.IsTrailersAvailableAndEnabled && handled == false)
            {
                TraktLogger.Info("There were no episodes found in local plugin databases. Attempting to search and/or play trailer(s) from the Trailers plugin");
                ShowTVShowTrailersPluginMenu(show);
                handled = true;
            }
        }
コード例 #24
0
        public static int Collected(this TraktSeasonSummary season, TraktShowSummary show)
        {
            var collectedEpisodes = TraktCache.CollectedEpisodes;
            if (collectedEpisodes == null)
                return 0;

            // count all the episodes collected in the season
            return collectedEpisodes.Where(e => e.ShowId == show.Ids.Trakt && e.Season == season.Number).Count();
        }
コード例 #25
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;
        }
コード例 #26
0
 private void PublishShowSkinProperties(TraktShowSummary PopularItem)
 {
     GUICommon.SetShowProperties(PopularItem);
 }
コード例 #27
0
        internal static void SetEpisodeProperties(TraktShowSummary show, TraktEpisodeSummary episode)
        {
            if (episode == null) return;

            SetProperty("#Trakt.Episode.Id", episode.Ids.Trakt);
            SetProperty("#Trakt.Episode.TvdbId", episode.Ids.Tvdb);
            SetProperty("#Trakt.Episode.ImdbId", episode.Ids.Imdb);
            SetProperty("#Trakt.Episode.TmdbId", episode.Ids.Imdb);
            SetProperty("#Trakt.Episode.Number", episode.Number);
            SetProperty("#Trakt.Episode.Season", episode.Season);
            if (episode.FirstAired != null)
            {
                // FirstAired is converted to UTC from original countries timezone on trakt
                SetProperty("#Trakt.Episode.FirstAired", episode.FirstAired.FromISO8601().ToShortDateString());
                SetProperty("#Trakt.Episode.FirstAiredLocalized", episode.FirstAired.FromISO8601().ToLocalTime().ToShortDateString());
                SetProperty("#Trakt.Episode.FirstAiredLocalizedDayOfWeek", episode.FirstAired.FromISO8601().ToLocalTime().ToLocalisedDayOfWeek());
                SetProperty("#Trakt.Episode.FirstAiredLocalizedTime", episode.FirstAired.FromISO8601().ToLocalTime().ToShortTimeString());
            }
            SetProperty("#Trakt.Episode.Title", string.IsNullOrEmpty(episode.Title) ? string.Format("{0} {1}", Translation.Episode, episode.Number.ToString()) : episode.Title.RemapHighOrderChars());
            SetProperty("#Trakt.Episode.Url", string.Format("http://trakt.tv/shows/{0}/seasons/{1}/episodes/{2}", show.Ids.Slug, episode.Season, episode.Number));
            SetProperty("#Trakt.Episode.Overview", episode.Overview.ToNullIfEmpty() == null ? Translation.NoEpisodeSummary : episode.Overview.RemapHighOrderChars());
            SetProperty("#Trakt.Episode.Runtime", show.Runtime);
            SetProperty("#Trakt.Episode.InWatchList", episode.IsWatchlisted());
            SetProperty("#Trakt.Episode.InCollection", episode.IsCollected(show));
            SetProperty("#Trakt.Episode.Plays", episode.Plays(show));
            SetProperty("#Trakt.Episode.Watched", episode.IsWatched(show));
            SetProperty("#Trakt.Episode.Rating", episode.UserRating(show));
            SetProperty("#Trakt.Episode.Ratings.Percentage", episode.Rating.ToPercentage());
            SetProperty("#Trakt.Episode.Ratings.Votes", episode.Votes);
            SetProperty("#Trakt.Episode.Ratings.Icon", (episode.Rating >= 6) ? "love" : "hate");
            //if (episode.Images != null)
            //{
            //    SetProperty("#Trakt.Episode.EpisodeImageFilename", episode.Images.ScreenShot.LocalImageFilename(ArtworkType.EpisodeImage));
            //}
        }
コード例 #28
0
        private bool GetLoadingParameter()
        {
            if (_loadParameter == null)
            {
                // maybe re-loading, so check previous window id
                if (Show != null && (Show.Ids.Trakt != null || Show.Ids.Imdb != null || Show.Title != null))
                    return true;

                return false;
            }

            Show = _loadParameter.FromJSON<TraktShowSummary>();
            if (Show == null || Show.Ids == null)
                return false;

            return true;
        }
コード例 #29
0
        internal static void SetShowProperties(TraktShowSummary show)
        {
            if (show == null) return;

            SetProperty("#Trakt.Show.Id", show.Ids.Trakt);
            SetProperty("#Trakt.Show.ImdbId", show.Ids.Imdb);
            SetProperty("#Trakt.Show.TvdbId", show.Ids.Tvdb);
            SetProperty("#Trakt.Show.TmdbId", show.Ids.Tmdb);
            SetProperty("#Trakt.Show.TvRageId", show.Ids.TvRage);
            SetProperty("#Trakt.Show.Title", show.Title.RemapHighOrderChars());
            SetProperty("#Trakt.Show.Language", Translation.GetLanguageFromISOCode(show.Language));
            SetProperty("#Trakt.Show.Url", string.Format("http://trakt.tv/shows/{0}", show.Ids.Slug));
            if (show.Airs != null)
            {
                SetProperty("#Trakt.Show.AirDay", show.FirstAired.FromISO8601().ToLocalisedDayOfWeek());
                SetProperty("#Trakt.Show.AirDayLocalized", show.FirstAired.FromISO8601().ToLocalTime().ToLocalisedDayOfWeek());
                SetProperty("#Trakt.Show.AirTime", show.FirstAired.FromISO8601().ToShortTimeString());
                SetProperty("#Trakt.Show.AirTimeLocalized", show.FirstAired.FromISO8601().ToLocalTime().ToShortTimeString());
                SetProperty("#Trakt.Show.AirTimezone", show.Airs.Timezone);
                SetProperty("#Trakt.Show.AirTimezoneWindows", show.Airs.Timezone.OlsenToWindowsTimezone());
            }
            SetProperty("#Trakt.Show.Certification", show.Certification);
            SetProperty("#Trakt.Show.Country", show.Country.ToCountryName());
            SetProperty("#Trakt.Show.FirstAired", show.FirstAired.FromISO8601().ToShortDateString());
            SetProperty("#Trakt.Show.FirstAiredLocalized", show.FirstAired.FromISO8601().ToLocalTime().ToShortDateString());
            SetProperty("#Trakt.Show.Network", show.Network);
            SetProperty("#Trakt.Show.Overview", show.Overview.ToNullIfEmpty() == null ? Translation.NoShowSummary : show.Overview.RemapHighOrderChars());
            SetProperty("#Trakt.Show.Runtime", show.Runtime);
            SetProperty("#Trakt.Show.Year", show.Year);
            SetProperty("#Trakt.Show.Status", show.Status);
            SetProperty("#Trakt.Show.TranslatedStatus", (show.Status ?? "").Replace(" " ,"").Translate());
            SetProperty("#Trakt.Show.Genres", TraktGenres.Translate(show.Genres));
            SetProperty("#Trakt.Show.InWatchList", show.IsWatchlisted());
            SetProperty("#Trakt.Show.InCollection", show.IsCollected());
            SetProperty("#Trakt.Show.Collected", show.Collected());
            SetProperty("#Trakt.Show.Watched", show.IsWatched());
            SetProperty("#Trakt.Show.AiredEpisodes", show.AiredEpisodes);
            SetProperty("#Trakt.Show.Plays", show.Plays());
            SetProperty("#Trakt.Show.Rating", show.UserRating());
            SetProperty("#Trakt.Show.Ratings.Percentage", show.Rating.ToPercentage());
            SetProperty("#Trakt.Show.Ratings.Votes", show.Votes);
            SetProperty("#Trakt.Show.Ratings.Icon", (show.Rating > 6) ? "love" : "hate");
            //if (show.Images != null)
            //{
            //    SetProperty("#Trakt.Show.FanartImageFilename", show.Images.Fanart.LocalImageFilename(ArtworkType.ShowFanart));
            //    SetProperty("#Trakt.Show.PosterImageFilename", show.Images.Poster.LocalImageFilename(ArtworkType.ShowPoster));
            //    SetProperty("#Trakt.Show.BannerImageFilename", show.Images.Banner.LocalImageFilename(ArtworkType.ShowBanner));
            //}
        }
コード例 #30
0
 public static void RemoveSeasonFromWatchList(TraktShowSummary show, int season)
 {
     RemoveSeasonFromWatchList(show.Title, show.Year, season, show.Ids.Tvdb, show.Ids.Imdb, show.Ids.Tmdb, show.Ids.Trakt);
 }