Used to collect a list of people to SearchBy in External Plugins
Ejemplo n.º 1
0
        public static bool ShowTraktExtEpisodeMenu(string title, string year, string season, string episode, string tvdbid, string imdbid, string episodetvdbid, bool isWatched, string fanart, SearchPeople people, bool showAll)
        {
            var dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
            dlg.Reset();
            dlg.SetHeading(GUIUtils.PluginName());

            var 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.AddToWatchList);
            dlg.Add(pItem);
            pItem.ItemId = (int)TraktMenuItems.AddToWatchList;

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

            // Show Search By 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 episodes
            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.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 episode. Title = '{0}', Year = '{1}', Season = '{2}', Episode = '{3}', Show ID = '{4}', Episode ID = '{5}'", title, year.ToLogString(), season, episode, tvdbid.ToLogString(), episodetvdbid.ToLogString());
                    var show = new TraktSyncShowRatedEx
                    {
                        Ids = new TraktShowId { Tvdb = tvdbid.ToNullableInt32(), Imdb = imdbid.ToNullIfEmpty() },
                        Title = title,
                        Year = year.ToNullableInt32(),
                        Seasons = new List<TraktSyncShowRatedEx.Season>
                        {
                            new TraktSyncShowRatedEx.Season
                            {
                                Number = season.ToInt(),
                                Episodes = new List<TraktSyncShowRatedEx.Season.Episode>
                                {
                                    new TraktSyncShowRatedEx.Season.Episode
                                    {
                                        Number = episode.ToInt(),
                                        RatedAt = DateTime.UtcNow.ToISO8601()
                                    }
                                }
                            }
                        }
                    };
                    int rating = GUIUtils.ShowRateDialog<TraktSyncShowRatedEx>(show);

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

                case ((int)TraktMenuItems.Shouts):
                    TraktLogger.Info("Displaying Shouts for tv episode. Title = '{0}', Year = '{1}', Season = '{2}', Episode = '{3}'", title, year.ToLogString(), season, episode);
                    TraktHelper.ShowEpisodeShouts(title, year.ToNullableInt32(), tvdbid.ToNullableInt32(), null, imdbid.ToNullIfEmpty(), season.ToInt(), episode.ToInt(), isWatched, fanart);
                    break;

                case ((int)TraktMenuItems.AddToWatchList):
                    TraktLogger.Info("Adding tv episode to Watchlist. Title = '{0}', Year = '{1}', Season = '{2}', Episode = '{3}'", title, year.ToLogString(), season, episode);
                    TraktHelper.AddEpisodeToWatchList(title, season.ToInt(), episode.ToInt(), tvdbid.ToNullableInt32(), null, null, null);
                    break;

                case ((int)TraktMenuItems.AddToCustomList):
                    TraktLogger.Info("Adding tv episode to Custom List. Title = '{0}', Year = '{1}', Season = '{2}', Episode = '{3}', Episode ID = '{4}'", title, year.ToLogString(), season, episode, episodetvdbid.ToLogString());
                    if (string.IsNullOrEmpty(episodetvdbid))
                    {
                        TraktHelper.AddRemoveEpisodeInUserList(new TraktEpisode { Ids = new TraktEpisodeId { Tvdb = episodetvdbid.ToNullableInt32() } }, false);
                    }
                    break;

                case ((int)TraktMenuItems.SearchBy):
                    ShowSearchByMenu(people, title, fanart);
                    break;

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

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

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

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

                case ((int)TraktMenuItems.Lists):
                    GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CustomLists);
                    break;
            }
            return true;
        }
Ejemplo n.º 2
0
        public static bool GetMoviePersonInfo(int? movieID, out SearchPeople searchPeople)
        {
            searchPeople = new SearchPeople();

            if (movieID == null) return false;

            var movies = DBMovieInfo.GetAll();
            var selectedMovie = movies.Find(m => m.ID == movieID);
            if (selectedMovie == null) return false;

            foreach (var actor in selectedMovie.Actors)
            {
                searchPeople.Actors.Add(actor);
            }
            foreach (var writer in selectedMovie.Writers)
            {
                searchPeople.Writers.Add(writer);
            }
            foreach (var director in selectedMovie.Directors)
            {
                searchPeople.Directors.Add(director);
            }

            return true;
        }
Ejemplo n.º 3
0
        public static bool ShowSearchByMenu(SearchPeople people, string title, string fanart)
        {
            IDialogbox dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
            dlg.Reset();
            dlg.SetHeading(Translation.SearchBy);

            GUIListItem pItem = null;

            if (people.Actors.Count > 0)
            {
                pItem = new GUIListItem(Translation.Actors);
                dlg.Add(pItem);
                pItem.ItemId = (int)TraktSearchByItems.Actors;
                pItem.Label2 = people.Actors.Count.ToString();
            }

            if (people.Directors.Count > 0)
            {
                pItem = new GUIListItem(Translation.Directors);
                dlg.Add(pItem);
                pItem.ItemId = (int)TraktSearchByItems.Directors;
                pItem.Label2 = people.Directors.Count.ToString();
            }

            if (people.Producers.Count > 0)
            {
                pItem = new GUIListItem(Translation.Producers);
                dlg.Add(pItem);
                pItem.ItemId = (int)TraktSearchByItems.Producers;
                pItem.Label2 = people.Producers.Count.ToString();
            }

            if (people.Writers.Count > 0)
            {
                pItem = new GUIListItem(Translation.Writers);
                dlg.Add(pItem);
                pItem.ItemId = (int)TraktSearchByItems.Writers;
                pItem.Label2 = people.Writers.Count.ToString();
            }

            if (people.GuestStars.Count > 0)
            {
                pItem = new GUIListItem(Translation.GuestStars);
                dlg.Add(pItem);
                pItem.ItemId = (int)TraktSearchByItems.GuestStars;
                pItem.Label2 = people.GuestStars.Count.ToString();
            }

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

            bool retCode = false;

            if (dlg.SelectedLabelText == Translation.Actors)
                retCode = ShowSearchByPersonMenu(people.Actors, title, fanart);
            if (dlg.SelectedLabelText == Translation.Directors)
                retCode = ShowSearchByPersonMenu(people.Directors, title, fanart);
            if (dlg.SelectedLabelText == Translation.Producers)
                retCode = ShowSearchByPersonMenu(people.Producers, title, fanart);
            if (dlg.SelectedLabelText == Translation.Writers)
                retCode = ShowSearchByPersonMenu(people.Writers, title, fanart);
            if (dlg.SelectedLabelText == Translation.GuestStars)
                retCode = ShowSearchByPersonMenu(people.GuestStars, title, fanart);

            return retCode;
        }
Ejemplo n.º 4
0
 public static bool ShowTraktExtEpisodeMenu(string title, string year, string season, string episode, string tvdbid, string episodetvdbid, bool isWatched, string fanart, SearchPeople people, bool showAll)
 {
     return ShowTraktExtEpisodeMenu(title, year, season, episode, tvdbid, null, episodetvdbid, isWatched, fanart, people, showAll);
 }
Ejemplo n.º 5
0
 public static bool ShowTraktExtTVShowMenu(string title, string year, string tvdbid, string fanart, SearchPeople people, bool showAll)
 {
     return ShowTraktExtTVShowMenu(title, year, tvdbid, null, fanart, people, showAll);
 }
Ejemplo n.º 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;
        }
Ejemplo n.º 7
0
        public static bool ShowTraktExtTVSeasonMenu(string title, string year, string tvdbid, string imdbid, string season, string seasonid, 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.AddToWatchList);
            dlg.Add(pItem);
            pItem.ItemId = (int)TraktMenuItems.AddToWatchList;

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

            // 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.WatchList);
                dlg.Add(pItem);
                pItem.ItemId = (int)TraktMenuItems.WatchList;

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

            int seasonNumber = 0;
            if (!int.TryParse(season, out seasonNumber))
                return false;

            // 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 season. Title = '{0}', Year = '{1}', TVDb ID = '{2}', Season = '{3}'", title, year.ToLogString(), tvdbid.ToLogString(), season);
                    GUIUtils.ShowRateDialog<TraktSyncSeasonRatedEx>(new TraktSyncSeasonRatedEx
                    {
                        Ids = new TraktShowId { Tvdb = tvdbid.ToNullableInt32(), Imdb = imdbid.ToNullIfEmpty() },
                        Title = title,
                        Year = year.ToNullableInt32(),
                        Seasons = new List<TraktSyncSeasonRatedEx.Season>
                        {
                            new TraktSyncSeasonRatedEx.Season
                            {
                                Number = seasonNumber,
                                RatedAt = DateTime.UtcNow.ToISO8601()
                            }
                        }
                    });
                    break;

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

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

                case ((int)TraktMenuItems.AddToCustomList):
                    TraktLogger.Info("Adding tv season to Custom List. Title = '{0}', Year = '{1}', TVDb ID = '{2}', Season = '{3}'", title, year.ToLogString(), tvdbid.ToLogString(), season);
                    //TraktHelper.AddRemoveSeasonInUserList(title, year, tvdbid, false);
                    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.WatchList):
                    GUIWindowManager.ActivateWindow((int)TraktGUIWindows.WatchedListShows);
                    break;

                case ((int)TraktMenuItems.Lists):
                    GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CustomLists);
                    break;
            }
            return true;
        }
Ejemplo n.º 8
0
 public static bool ShowTraktExtMovieMenu(string title, string year, string imdbid, string fanart, SearchPeople people, bool showAll)
 {
     return ShowTraktExtMovieMenu(title, year, imdbid, false, fanart, people, showAll);
 }
Ejemplo n.º 9
0
        public static bool GetSeriesPersonInfo(Object obj, out SearchPeople searchPeople)
        {
            searchPeople = new SearchPeople();

            if (obj == null) return false;

            DBSeries series = obj as DBSeries;
            if (series == null) return false;

            try
            {
                searchPeople.Actors.AddRange(series[DBOnlineSeries.cActors].ToString().Split('|').Where(s => s.Trim().Length > 0));
            }
            catch
            {
                TraktLogger.Error("Error getting Episode Person Info.");
                return false;
            }
            return true;
        }
Ejemplo n.º 10
0
        public static bool GetEpisodePersonInfo(Object obj, out SearchPeople searchPeople)
        {
            searchPeople = new SearchPeople();

            if (obj == null) return false;

            DBEpisode episode = obj as DBEpisode;
            if (episode == null) return false;

            DBSeries series = Helper.getCorrespondingSeries(episode[DBOnlineEpisode.cSeriesID]);
            if (series == null) return false;

            try
            {
                searchPeople.Actors.AddRange(series[DBOnlineSeries.cActors].ToString().Split('|').Where(s => s.Trim().Length > 0));
                searchPeople.Directors.AddRange(episode[DBOnlineEpisode.cDirector].ToString().Split('|').Where(s => s.Trim().Length > 0));
                searchPeople.Writers.AddRange(episode[DBOnlineEpisode.cWriter].ToString().Split('|').Where(s => s.Trim().Length > 0));
                searchPeople.GuestStars.AddRange(episode[DBOnlineEpisode.cGuestStars].ToString().Split('|').Where(s => s.Trim().Length > 0));
            }
            catch
            {
                TraktLogger.Error("Error getting Episode Person Info.");
                return false;
            }
            return true;
        }
Ejemplo n.º 11
0
        void GUIWindowManager_Receivers(GUIMessage message)
        {
            bool validWatchListItem = false;
            bool validCustomListItem = false;
            bool validRateItem = false;
            bool validShoutItem = false;
            bool validRelatedItem = false;
            bool validTraktMenuItem = false;
            bool validSearchItem = false;
            bool updatePluginFilters = false;
            string title = string.Empty;
            string year = string.Empty;
            string imdbid = string.Empty;
            string tmdbid = string.Empty;
            string showtvdbid = string.Empty;
            string epTvdbId = string.Empty;
            string season = string.Empty;
            string episode = string.Empty;
            string fanart = string.Empty;
            bool isWatched = false;
            SearchPeople searchPeople = null;
            string type = "movie";

            switch (message.Message)
            {
                case GUIMessage.MessageType.GUI_MSG_CLICKED:
                    switch (GUIWindowManager.ActiveWindow)
                    {
                        case (int)ExternalPluginWindows.OnlineVideos:
                            #region WatchList/CustomList Button
                            switch (message.SenderControlId)
                            {
                                case ((int)ExternalPluginControls.WatchList):
                                case ((int)ExternalPluginControls.CustomList):
                                    // Confirm we are in IMDB/iTunes Trailer Details view
                                    // This will give us enough information to send to trakt
                                    bool isDetails = GUIPropertyManager.GetProperty("#OnlineVideos.state").ToLowerInvariant() == "details";
                                    string siteUtil = GUIPropertyManager.GetProperty("#OnlineVideos.selectedSiteUtil").ToLowerInvariant();
                                    if (isDetails && (siteUtil == "imdb" || siteUtil == "itmovietrailers"))
                                    {
                                        title = GUIPropertyManager.GetProperty("#OnlineVideos.Details.Title").Trim();
                                        year = GUIPropertyManager.GetProperty("#OnlineVideos.Details.Year").Trim();
                                        if (siteUtil == "imdb")
                                        {
                                            // IMDb site exposes IMDb ID, use this to get a better match on trakt
                                            // this property is new, check for null in case user hasn't updated site
                                            imdbid = GUIPropertyManager.GetProperty("#OnlineVideos.Details.IMDbId");
                                            if (imdbid == null) imdbid = string.Empty;

                                            // could be a TV Show
                                            type = GUIPropertyManager.GetProperty("#OnlineVideos.Details.Type").ToLowerInvariant();
                                        }
                                        if ((!string.IsNullOrEmpty(title) && !string.IsNullOrEmpty(year)) || imdbid.StartsWith("tt"))
                                        {
                                            if (message.SenderControlId == (int)ExternalPluginControls.WatchList) validWatchListItem = true;
                                            if (message.SenderControlId == (int)ExternalPluginControls.CustomList) validCustomListItem = true;
                                        }
                                        // Return focus to details list now so we dont go in a loop
                                        GUIControl.FocusControl((int)ExternalPluginWindows.OnlineVideos, 51);
                                    }
                                    break;
                            }
                            #endregion
                            break;
                        case (int)ExternalPluginWindows.Showtimes:
                            #region WatchList/CustomList Button
                            switch (message.SenderControlId)
                            {
                                case ((int)ExternalPluginControls.WatchList):
                                case ((int)ExternalPluginControls.CustomList):
                                    // Confirm we are in Showtimes Details view
                                    // This will give us enough information to send to trakt
                                    bool isDetails = GUIWindowManager.GetWindow(GUIWindowManager.ActiveWindow).GetControl(24).Visible;
                                    if (isDetails)
                                    {
                                        title = GUIPropertyManager.GetProperty("#st_title").Trim();
                                        DateTime releaseDate = DateTime.MinValue;

                                        if (DateTime.TryParse(GUIPropertyManager.GetProperty("#st_releasedate").Trim(), out releaseDate))
                                        {
                                            year = releaseDate.Year.ToString();
                                        }

                                        imdbid = GUIPropertyManager.GetProperty("#st_imdb");
                                        if (imdbid == null) imdbid = string.Empty;

                                        tmdbid = GUIPropertyManager.GetProperty("#st_tmdb");
                                        if (tmdbid == null) imdbid = string.Empty;

                                        if ((!string.IsNullOrEmpty(title) && !string.IsNullOrEmpty(year)) || imdbid.StartsWith("tt") || !string.IsNullOrEmpty(tmdbid))
                                        {
                                            if (message.SenderControlId == (int)ExternalPluginControls.WatchList) validWatchListItem = true;
                                            if (message.SenderControlId == (int)ExternalPluginControls.CustomList) validCustomListItem = true;
                                        }
                                        // set focus to next button so we dont go in a loop
                                        GUIControl.FocusControl((int)ExternalPluginWindows.Showtimes, 42);
                                    }
                                    break;
                            }
                            #endregion
                            break;
                        case (int)ExternalPluginWindows.VideoInfo:
                            #region Watchlist/CustomList/Rate/Shouts/RelatedItem/SearchBy
                            switch (message.SenderControlId)
                            {
                                case ((int)ExternalPluginControls.WatchList):
                                case ((int)ExternalPluginControls.CustomList):
                                case ((int)ExternalPluginControls.Rate):
                                case ((int)ExternalPluginControls.Shouts):
                                case ((int)ExternalPluginControls.RelatedItems):
                                case ((int)ExternalPluginControls.SearchBy):
                                case ((int)ExternalPluginControls.TraktMenu):
                                    type = "movie";
                                    title = GUIPropertyManager.GetProperty("#title").Trim();
                                    year = GUIPropertyManager.GetProperty("#year").Trim();
                                    imdbid = GUIPropertyManager.GetProperty("#imdbnumber").Trim();

                                    MediaPortal.Util.FanArt.GetFanArtfilename(title, 0, out fanart);
                                    if (fanart.ToLowerInvariant().Equals("unknown"))
                                    {
                                        string movieid = GUIPropertyManager.GetProperty("#movieid").Trim();
                                        MediaPortal.Util.FanArt.GetFanArtfilename(movieid, 0, out fanart);
                                    }

                                    searchPeople = new SearchPeople();
                                    string people = GUIPropertyManager.GetProperty("#cast").Trim();
                                    if (people != string.Empty && people != "unknown")
                                    {
                                        // actors seperated by newlines
                                        var peopleAndRoles = people.Split('\n').Select(s => s.Trim());

                                        // each actor string also includes the role: {0} as {1} &#10;
                                        // get the seperator from the localised string and then reverse the formatted string
                                        string roleSepString = GUILocalizeStrings.Get(1320).Split(' ')[1].Trim();

                                        foreach (var personAndRole in peopleAndRoles)
                                        {
                                            var personAndRoleStrings = personAndRole.Split(new string[] { string.Format(" {0} ", roleSepString) }, StringSplitOptions.None);
                                            searchPeople.Actors.Add(personAndRoleStrings.First());
                                        }
                                    }

                                    people = GUIPropertyManager.GetProperty("#director").Trim();
                                    if (people != string.Empty && people != "unknown") searchPeople.Directors.AddRange(people.Split(',').Select(s => s.Trim()));

                                    people = GUIPropertyManager.GetProperty("#credits").Trim();
                                    if (people != string.Empty && people != "unknown")
                                    {
                                        var writers = people.Split(',').Select(s => s.Trim());
                                        foreach(var writer in writers)
                                        {
                                            // remove the writer type e.g. (Story), (Screenplay)
                                            searchPeople.Writers.Add(writer.Split('(').First().Trim());
                                        }
                                    }

                                    if (!string.IsNullOrEmpty(imdbid) || (!string.IsNullOrEmpty(title) && !string.IsNullOrEmpty(year)))
                                    {
                                        if (message.SenderControlId == (int)ExternalPluginControls.WatchList) validWatchListItem = true;
                                        if (message.SenderControlId == (int)ExternalPluginControls.CustomList) validCustomListItem = true;
                                        if (message.SenderControlId == (int)ExternalPluginControls.Rate) validRateItem = true;
                                        if (message.SenderControlId == (int)ExternalPluginControls.Shouts) validShoutItem = true;
                                        if (message.SenderControlId == (int)ExternalPluginControls.RelatedItems) validRelatedItem = true;
                                        if (message.SenderControlId == (int)ExternalPluginControls.TraktMenu) validTraktMenuItem = true;
                                    }

                                    // Set focus to Play Button now so we dont go in a loop
                                    GUIControl.FocusControl((int)ExternalPluginWindows.VideoInfo, 2);
                                    break;
                            }
                            #endregion
                            break;
                        case (int)ExternalPluginWindows.MovingPictures:
                            #region WatchList/CustomList/Rate/Shouts/RelatedItem/Search
                            switch (message.SenderControlId)
                            {
                                case ((int)ExternalPluginControls.WatchList):
                                case ((int)ExternalPluginControls.CustomList):
                                case ((int)ExternalPluginControls.Rate):
                                case ((int)ExternalPluginControls.Shouts):
                                case ((int)ExternalPluginControls.RelatedItems):
                                case ((int)ExternalPluginControls.SearchBy):
                                case ((int)ExternalPluginControls.TraktMenu):
                                    type = "movie";
                                    updatePluginFilters = true;
                                    title = GUIPropertyManager.GetProperty("#MovingPictures.SelectedMovie.title").Trim();
                                    year = GUIPropertyManager.GetProperty("#MovingPictures.SelectedMovie.year").Trim();
                                    imdbid = GUIPropertyManager.GetProperty("#MovingPictures.SelectedMovie.imdb_id").Trim();
                                    fanart = GUIPropertyManager.GetProperty("#MovingPictures.SelectedMovie.backdropfullpath").Trim();
                                    isWatched = GUIPropertyManager.GetProperty("#MovingPictures.UserMovieSettings.watched").Trim() != "0";

                                    // get movie people from database
                                    searchPeople = new SearchPeople();
                                    if (TraktHelper.IsMovingPicturesAvailableAndEnabled)
                                    {
                                        int? movieID = null;
                                        int iYear = 0; int.TryParse(year, out iYear);
                                        if (MovingPictures.FindMovieID(title, iYear, imdbid, ref movieID))
                                            MovingPictures.GetMoviePersonInfo(movieID, out searchPeople);
                                    }

                                    if (!string.IsNullOrEmpty(imdbid) || (!string.IsNullOrEmpty(title) && !string.IsNullOrEmpty(year)))
                                    {
                                        if (message.SenderControlId == (int)ExternalPluginControls.WatchList) validWatchListItem = true;
                                        if (message.SenderControlId == (int)ExternalPluginControls.CustomList) validCustomListItem = true;
                                        if (message.SenderControlId == (int)ExternalPluginControls.Rate) validRateItem = true;
                                        if (message.SenderControlId == (int)ExternalPluginControls.Shouts) validShoutItem = true;
                                        if (message.SenderControlId == (int)ExternalPluginControls.RelatedItems) validRelatedItem = true;
                                        if (message.SenderControlId == (int)ExternalPluginControls.TraktMenu) validTraktMenuItem = true;
                                        if (message.SenderControlId == (int)ExternalPluginControls.SearchBy) validSearchItem = true;
                                    }

                                    // Set focus to Play Button now so we dont go in a loop
                                    GUIControl.FocusControl((int)ExternalPluginWindows.MovingPictures, 6);
                                    break;
                            }
                            #endregion
                            break;
                        case (int)ExternalPluginWindows.TVSeries:
                            #region WatchList/CustomList/Rate/Shouts/Related
                            switch (message.SenderControlId)
                            {
                                case ((int)ExternalPluginControls.WatchList):
                                case ((int)ExternalPluginControls.CustomList):
                                case ((int)ExternalPluginControls.Rate):
                                case ((int)ExternalPluginControls.Shouts):
                                case ((int)ExternalPluginControls.RelatedItems):
                                case ((int)ExternalPluginControls.SearchBy):
                                case ((int)ExternalPluginControls.TraktMenu):
                                    Object obj = TVSeries.SelectedObject;
                                    bool validItem = false;
                                    if (obj != null)
                                    {
                                        searchPeople = new SearchPeople();

                                        switch (TVSeries.GetSelectedType(obj))
                                        {
                                            case TVSeries.SelectedType.Episode:
                                                type = "episode";
                                                validItem = TVSeries.GetEpisodeInfo(obj, out title, out year, out showtvdbid, out epTvdbId, out season, out episode, out isWatched);
                                                validItem |= TVSeries.GetEpisodePersonInfo(obj, out searchPeople);
                                                break;

                                            case TVSeries.SelectedType.Series:
                                                type = "series";
                                                validItem =  TVSeries.GetSeriesInfo(obj, out title, out year, out showtvdbid);
                                                validItem |= TVSeries.GetSeriesPersonInfo(obj, out searchPeople);
                                                break;

                                            default:
                                                break;
                                        }

                                        fanart = GUIPropertyManager.GetProperty("#TVSeries.Current.Fanart").Trim();

                                        if (validItem)
                                        {
                                            if (message.SenderControlId == (int)ExternalPluginControls.WatchList) validWatchListItem = true;
                                            if (message.SenderControlId == (int)ExternalPluginControls.CustomList) validCustomListItem = true;
                                            if (message.SenderControlId == (int)ExternalPluginControls.Rate) validRateItem = true;
                                            if (message.SenderControlId == (int)ExternalPluginControls.Shouts) validShoutItem = true;
                                            if (message.SenderControlId == (int)ExternalPluginControls.RelatedItems) validRelatedItem = true;
                                            if (message.SenderControlId == (int)ExternalPluginControls.SearchBy) validSearchItem = true;
                                            if (message.SenderControlId == (int)ExternalPluginControls.TraktMenu) validTraktMenuItem = true;
                                        }
                                    }

                                    // Set focus to Facade now so we dont go in a loop
                                    GUIControl.FocusControl((int)ExternalPluginWindows.TVSeries, 50);
                                    break;
                            }
                            #endregion
                            break;
                    }
                    break;

                default:
                    break;
            }

            #region Add To Watch List
            if (validWatchListItem)
            {
                if (type == "movie")
                {
                    if (GUIUtils.ShowYesNoDialog(Translation.WatchList, string.Format("{0}\n{1} ({2})", Translation.AddThisItemToWatchList, title, year), true))
                    {
                        TraktLogger.Info("Adding movie to Watchlist. Title = '{0}', Year = '{1}', IMDb ID = '{2}'", title, year, imdbid);
                        TraktHelper.AddMovieToWatchList(title, year.ToNullableInt32(), imdbid.ToNullIfEmpty(), tmdbid.ToNullableInt32(), updatePluginFilters);
                    }
                }
                else if (type == "show")
                {
                    if (GUIUtils.ShowYesNoDialog(Translation.WatchList, Translation.AddShowToWatchList, true))
                    {
                        TraktLogger.Info("Adding show to Watchlist. Title = '{0}', Year = '{1}', TVDb ID = '{2}'", title, year, showtvdbid);
                        TraktHelper.AddShowToWatchList(title, year.ToNullableInt32(), showtvdbid.ToNullableInt32(), imdbid.ToNullIfEmpty(), tmdbid.ToNullableInt32(), null);
                    }
                }
                else if (type == "episode")
                {
                    if (GUIUtils.ShowYesNoDialog(Translation.WatchList, Translation.AddEpisodeToWatchList, true))
                    {
                        TraktLogger.Info("Adding episode to Watchlist. Title = '{0}', Year = '{1}', Season = '{2}', Episode = '{3}', Episode TVDb ID = '{4}'", title, year, season, episode, epTvdbId);
                        TraktHelper.AddEpisodeToWatchList(null, season.ToInt(), episode.ToInt(), epTvdbId.ToNullableInt32(), null, null, null);
                    }
                }
            }
            #endregion

            #region Add To Custom List
            if (validCustomListItem)
            {
                if (type == "movie")
                {
                    TraktLogger.Info("Adding movie to Custom List. Title = '{0}', Year = '{1}', IMDb ID = '{2}'", title, year, imdbid);
                    TraktHelper.AddRemoveMovieInUserList(title, year, imdbid, false);
                }
                else if (type == "show")
                {
                    TraktLogger.Info("Adding show to Custom List. Title = '{0}', Year = '{1}', TVDb ID = '{2}'", title, year, showtvdbid);
                    TraktHelper.AddRemoveShowInUserList(title, year, showtvdbid, false);
                }
                else if (type == "episode")
                {
                    TraktLogger.Info("Adding episode to Custom List. Title = '{0}', Year = '{1}', Season = '{2}', Episode = '{3}', Episode TVDb ID = '{4}'", title, year, season, episode, epTvdbId);
                    TraktHelper.AddRemoveEpisodeInUserList(new TraktEpisode
                    {
                        Ids = new TraktEpisodeId
                        {
                            Tvdb = epTvdbId.ToNullableInt32()
                        },
                        Number = episode.ToInt(),
                        Season = season.ToInt()
                    }, false);
                }
            }
            #endregion

            #region Rate
            if (validRateItem)
            {
                if (!GUICommon.CheckLogin(false)) return;

                switch (type)
                {
                    case "movie":
                        TraktLogger.Info("Showing rate dialog for movie. Title = '{0}', Year = '{1}', IMDb ID = '{2}'", title, year, imdbid);
                        GUIUtils.ShowRateDialog<TraktSyncMovieRated>(new TraktSyncMovieRated
                        {
                            Ids = new TraktMovieId { Imdb = imdbid.ToNullIfEmpty(), Tmdb = tmdbid.ToNullableInt32() },
                            Title = title,
                            Year = year.ToNullableInt32()
                        });
                        break;

                    case "series":
                        TraktLogger.Info("Showing rate dialog for tv show. Title = '{0}', Year = '{1}', TVDb ID = '{2}'", title, year, showtvdbid);
                        GUIUtils.ShowRateDialog<TraktSyncShowRated>(new TraktSyncShowRated
                        {
                            Ids = new TraktShowId { Tvdb = showtvdbid.ToNullableInt32(), Imdb = imdbid.ToNullIfEmpty() },
                            Title = title,
                            Year = year.ToNullableInt32()
                        });
                        break;

                    case "episode":
                        TraktLogger.Info("Showing rate dialog for tv episode. Title = '{0}', Year = '{1}', Season = '{2}', Episode = '{3}', Episode TVDb ID = '{4}'", title, year, season, episode, epTvdbId);
                        GUIUtils.ShowRateDialog<TraktSyncEpisodeRated>(new TraktSyncEpisodeRated
                        {
                            Ids = new TraktEpisodeId { Tvdb = showtvdbid.ToNullableInt32() },
                            Number = episode.ToInt(),
                            Season = season.ToInt(),
                            RatedAt = DateTime.UtcNow.ToISO8601()
                        });
                        break;
                }
            }
            #endregion

            #region Shouts
            if (validShoutItem)
            {
                if (!GUICommon.CheckLogin(false)) return;

                // Initialize Shout window
                switch (type)
                {
                    #region movie
                    case "movie":
                        TraktLogger.Info("Displaying Shouts for {0}. Title = '{0}', Year = '{1}', IMDb ID = '{2}'", title, year, imdbid);
                        TraktHelper.ShowMovieShouts(title, year, imdbid, isWatched, fanart);
                        break;
                    #endregion
                    #region episode
                    case "episode":
                        TraktLogger.Info("Displaying Shouts for {0}. Title = '{0}', Year = '{1}', TVDb ID = '{2}'", title, year, showtvdbid);
                        TraktHelper.ShowEpisodeShouts(title, showtvdbid, season, episode, isWatched, fanart);
                        break;
                    #endregion
                    #region series
                    case "series":
                        TraktLogger.Info("Displaying Shouts for {0}. Title = '{0}', Year = '{1}', TVDb ID = '{2}'", title, year, showtvdbid);
                        TraktHelper.ShowTVShowShouts(title, showtvdbid.ToNullableInt32(), null, isWatched, fanart);
                        break;
                    #endregion
                }
            }
            #endregion

            #region Related Movies/Shows
            if (validRelatedItem)
            {
                // Initialize Shout window
                switch (type)
                {
                    #region movie
                    case "movie":
                        TraktLogger.Info("Displaying Related Movies for {0}. Title = '{0}', Year = '{1}', IMDb ID = '{2}'", title, year, imdbid);
                        TraktHelper.ShowRelatedMovies(title, year, imdbid);
                        break;
                    #endregion
                    #region series
                    case "series":
                        TraktLogger.Info("Displaying Related Shows for {0}. Title = '{0}', Year = '{1}', TVDb ID = '{2}'", title, year, showtvdbid);
                        TraktHelper.ShowRelatedShows(title, showtvdbid);
                        break;
                    #endregion
                }
            }
            #endregion

            #region Trakt Menu
            if (validTraktMenuItem)
            {
                if (!GUICommon.CheckLogin(false)) return;

                switch (type)
                {
                    case "movie":
                        GUICommon.ShowTraktExtMovieMenu(title, year, imdbid, isWatched, fanart, searchPeople, false);
                        break;

                    case "series":
                        GUICommon.ShowTraktExtTVShowMenu(title, year, showtvdbid, imdbid, fanart, searchPeople, false);
                        break;

                    case "episode":
                        GUICommon.ShowTraktExtEpisodeMenu(title, year, season, episode, showtvdbid, isWatched, fanart, searchPeople, false);
                        break;
                }
            }
            #endregion

            #region Search Menu
            if (validSearchItem)
            {
                if (searchPeople.Count == 0)
                {
                    GUIUtils.ShowOKDialog(Translation.SearchBy, Translation.NoPeopleToSearch);
                }
                else
                {
                    GUICommon.ShowSearchByMenu(searchPeople, title, fanart);
                }
            }
            #endregion
        }