コード例 #1
0
        private TraktSyncAll GetSyncItems(TraktListItem listItem)
        {
            var syncItems = new TraktSyncAll();

            switch (listItem.Type)
            {
                case "movie":
                    var movie = new TraktMovie
                    {
                        Ids = new TraktMovieId { Trakt = listItem.Movie.Ids.Trakt }
                    };
                    syncItems.Movies = new List<TraktMovie>();
                    syncItems.Movies.Add(movie);
                    break;

                case "show":
                    var show = new TraktShow
                    {
                        Ids = new TraktShowId { Trakt = listItem.Show.Ids.Trakt }
                    };
                    syncItems.Shows = new List<TraktShow>();
                    syncItems.Shows.Add(show);
                    break;

                case "season":
                    var season = new TraktSeason
                    {
                        Ids = new TraktSeasonId { Trakt = listItem.Season.Ids.Trakt }
                    };
                    syncItems.Seasons = new List<TraktSeason>();
                    syncItems.Seasons.Add(season);
                    break;

                case "episode":
                    var episode = new TraktEpisode
                    {
                        Ids = new TraktEpisodeId { Trakt = listItem.Episode.Ids.Trakt }
                    };
                    syncItems.Episodes = new List<TraktEpisode>();
                    syncItems.Episodes.Add(episode);
                    break;

                case "person":
                    var person = new TraktPerson
                    {
                        Ids = new TraktPersonId { Trakt = listItem.Person.Ids.Trakt }
                    };
                    syncItems.People = new List<TraktPerson>();
                    syncItems.People.Add(person);
                    break;
            }

            return syncItems;
        }
コード例 #2
0
        internal static void AddRemovePersonInUserList(TraktPerson person, bool remove)
        {
            if (!GUICommon.CheckLogin(false)) return;

            GUIBackgroundTask.Instance.ExecuteInBackgroundAndCallback(() =>
            {
                return TraktLists.GetListsForUser(TraktSettings.Username);
            },
            delegate(bool success, object result)
            {
                if (success)
                {
                    var customlists = result as IEnumerable<TraktListDetail>;

                    // get slug of lists selected
                    List<int> slugs = TraktLists.GetUserListSelections(customlists.ToList());
                    if (slugs == null || slugs.Count == 0) return;

                    // add the movie to add/remove to a new sync list
                    var items = new TraktSyncAll
                    {
                        People = new List<TraktPerson>
                        {
                            new TraktPerson
                            {
                                Ids = person.Ids
                            }
                        }
                    };

                    AddRemoveItemInList(slugs, items, remove);
                }
            }, Translation.GettingLists, true);
        }