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

GetRatedEpisodesFromTrakt() public static méthode

Get the users rated episodes from Trakt
public static GetRatedEpisodesFromTrakt ( bool ignoreLastSyncTime = false ) : IEnumerable
ignoreLastSyncTime bool
Résultat IEnumerable
        public static IEnumerable<TraktEpisodeRated> GetRatedEpisodesFromTrakt(bool ignoreLastSyncTime = false)
        {
            // get from cache regardless of last sync time
            if (ignoreLastSyncTime)
                return RatedEpisodes;

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

            // get the last time we did anything to our library online
            var lastSyncActivities = LastSyncActivities;

            // something bad happened e.g. site not available
            if (lastSyncActivities == null || lastSyncActivities.Episodes == null)
                return null;

            // check the last time we have against the online time
            // if the times are the same try to load from cache
            if (lastSyncActivities.Episodes.Rating == TraktSettings.LastSyncActivities.Episodes.Rating)
            {
                var cachedItems = RatedEpisodes;
                if (cachedItems != null)
                    return cachedItems;
            }

            TraktLogger.Info("TV episode ratings cache is out of date, requesting updated data. Local Date = '{0}', Online Date = '{1}'", TraktSettings.LastSyncActivities.Episodes.Rating ?? "<empty>", lastSyncActivities.Episodes.Rating ?? "<empty>");

            // we get from online, local cache is not up to date
            var onlineItems = TraktAPI.TraktAPI.GetRatedEpisodes();
            if (onlineItems != null)
            {
                _RatedEpisodes = onlineItems;

                // save to local file cache
                SaveFileCache(EpisodesRatedFile, _RatedEpisodes.ToJSON());

                // save new activity time for next time
                TraktSettings.LastSyncActivities.Episodes.Rating = lastSyncActivities.Episodes.Rating;
            }

            return onlineItems;
        }
TraktCache