TraktPlugin.TraktCache.GetUnWatchedEpisodesFromTrakt C# (CSharp) Méthode

GetUnWatchedEpisodesFromTrakt() public static méthode

Get the users unwatched episodes since last sync This is something that has been previously watched but now has been removed from the users watched history either by toggling the watched state on a client or from online
public static GetUnWatchedEpisodesFromTrakt ( ) : IEnumerable
Résultat IEnumerable
        public static IEnumerable<Episode> GetUnWatchedEpisodesFromTrakt()
        {
            if (UnWatchedEpisodes != null)
                return UnWatchedEpisodes;

            TraktLogger.Info("Getting current user unwatched episodes from trakt.tv");

            // trakt.tv does not provide an unwatched API
            // There are plans after initial launch of v2 to have a re-watch API.

            // First we need to get the previously cached watched episodes
            var previouslyWatched = WatchedEpisodes;
            if (previouslyWatched == null)
                return new List<Episode>();

            // now get the latest watched
            var currentWatched = GetWatchedEpisodesFromTrakt();
            if (currentWatched == null)
                return null;

            TraktLogger.Debug("Comparing previous watched episodes against current watched episodes such that unwatched can be determined");

            // anything not in the currentwatched that is previously watched
            // must be unwatched now.
            // Note: we can add to internal cache from external events, so we can't always rely on trakt id for comparisons
            var dictCurrWatched = currentWatched.ToLookup(cwe => cwe.ShowTvdbId + "_" + cwe.Season + "_" + cwe.Number);

            var unwatchedEpisodes = from pwe in previouslyWatched
                                    where !dictCurrWatched[pwe.ShowTvdbId + "_" + pwe.Season + "_" + pwe.Number].Any()
                                    select new Episode
                                    {
                                        ShowId = pwe.ShowId,
                                        ShowTvdbId = pwe.ShowTvdbId,
                                        ShowImdbId = pwe.ShowImdbId,
                                        ShowTitle = pwe.ShowTitle,
                                        ShowYear = pwe.ShowYear,
                                        Season = pwe.Season,
                                        Number = pwe.Number
                                    };

            UnWatchedEpisodes = unwatchedEpisodes ?? new List<Episode>();

            return UnWatchedEpisodes;
        }
TraktCache