Ejemplo n.º 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;
        }
Ejemplo n.º 2
0
        internal static void RemoveSeasonFromWatchlist(TraktShow show, TraktSeason season)
        {
            if (_WatchListSeasons == null || show.Ids == null)
                return;

            var watchlistSeasons = _WatchListSeasons.ToList();
            watchlistSeasons.RemoveAll(s => (((s.Show.Ids.Trakt == show.Ids.Trakt) && s.Show.Ids.Trakt != null) ||
                                             ((s.Show.Ids.Imdb == show.Ids.Imdb) && s.Show.Ids.Imdb.ToNullIfEmpty() != null) ||
                                             ((s.Show.Ids.Tvdb == show.Ids.Tvdb) && s.Show.Ids.Tvdb != null)) &&
                                               s.Season.Number == season.Number);

            // remove using Title + Year
            if (show.Ids.Trakt == null && show.Ids.Imdb.ToNullIfEmpty() == null && show.Ids.Tvdb == null)
            {
                watchlistSeasons.RemoveAll(s => s.Show.Title.ToLowerInvariant() == show.Title.ToLower() && s.Show.Year == show.Year &&
                                                s.Season.Number == season.Number);
            }

            _WatchListSeasons = watchlistSeasons;
        }
Ejemplo n.º 3
0
        internal static void AddSeasonToRatings(TraktShow show, TraktSeason season, int rating)
        {
            var ratedSeasons = (_RatedSeasons ?? new List<TraktSeasonRated>()).ToList();

            ratedSeasons.Add(new TraktSeasonRated
            {
                RatedAt = DateTime.UtcNow.ToISO8601(),
                Rating = rating,
                Show = new TraktShow
                {
                    Ids = show.Ids,
                    Title = show.Title,
                    Year = show.Year
                },
                Season = new TraktSeason
                {
                    Ids = season.Ids,
                    Number = season.Number
                }
            });

            _RatedSeasons = ratedSeasons;
        }
Ejemplo n.º 4
0
        internal static void AddSeasonToWatchlist(TraktShow show, TraktSeason season)
        {
            var watchlistSeasons = (_WatchListSeasons ?? new List<TraktSeasonWatchList>()).ToList();

            watchlistSeasons.Add(new TraktSeasonWatchList
            {
                ListedAt = DateTime.UtcNow.ToISO8601(),
                Show = new TraktShowSummary
                {
                    Ids = show.Ids,
                    Title = show.Title,
                    Year = show.Year
                },
                Season = new TraktSeasonSummary
                {
                    Ids = season.Ids,
                    Number = season.Number
                }
            });

            _WatchListSeasons = watchlistSeasons;
        }
Ejemplo n.º 5
0
        internal static void AddRemoveSeasonInUserList(TraktSeason season, 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
                    {
                        Seasons = new List<TraktSeason>
                        {
                            new TraktSeason
                            {
                                Ids = new TraktSeasonId { Trakt = season.Ids.Trakt }
                            }
                        }
                    };

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