TraktPlugin.TraktLists.GetListsForUser C# (CSharp) Méthode

GetListsForUser() public static méthode

Get custom lists created by a user
public static GetListsForUser ( string username ) : IEnumerable
username string
Résultat IEnumerable
        public static IEnumerable<TraktListDetail> GetListsForUser(string username)
        {
            if (!UserLists.Keys.Contains(username) || LastRequest < DateTime.UtcNow.Subtract(new TimeSpan(0, TraktSettings.WebRequestCacheMinutes, 0)))
            {
                // get all lists for user
                var userLists = TraktAPI.TraktAPI.GetUserLists(username == TraktSettings.Username ? "me" : username);
                if (userLists == null) return null;

                // remove any cached list for user
                if (UserLists.Keys.Contains(username))
                    UserLists.Remove(username);

                UserLists.Add(username, userLists);
                LastRequest = DateTime.UtcNow;
            }
            return UserLists[username];
        }

Usage Example

Exemple #1
0
        public static void AddRemoveEpisodeInUserList(string username, string title, string year, string season, string episode, string tvdbid, bool remove)
        {
            if (!GUICommon.CheckLogin(false))
            {
                return;
            }

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

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

                    TraktListItem item = new TraktListItem
                    {
                        Type    = TraktItemType.episode.ToString(),
                        Title   = title,
                        Year    = Convert.ToInt32(year),
                        Season  = Convert.ToInt32(season),
                        Episode = Convert.ToInt32(episode),
                        TvdbId  = tvdbid
                    };

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