Beispiel #1
0
        /// <summary>
        /// Gets the current users liked items (comments and/or lists)
        /// </summary>
        /// <param name="type">The type of liked item: all (default), lists or comments</param>
        /// <param name="extendedInfoParams">Extended Info: min, full, images (comma separated)</param>
        /// <param name="page">Page Number</param>
        /// <param name="maxItems">Maximum number of items to request per page (this should be consistent per page request)</param>
        public static TraktLikes GetLikedItems(string type = "all", string extendedInfoParams = "min", int page = 1, int maxItems = 10)
        {
            var headers = new WebHeaderCollection();

            var response = TraktWeb.GetFromTrakt(string.Format(TraktURIs.UserLikedItems, type, extendedInfoParams, page, maxItems), out headers);

            if (response == null)
            {
                return(null);
            }

            try
            {
                return(new TraktLikes
                {
                    CurrentPage = page,
                    TotalItemsPerPage = maxItems,
                    TotalPages = int.Parse(headers["X-Pagination-Page-Count"]),
                    TotalItems = int.Parse(headers["X-Pagination-Item-Count"]),
                    Likes = response.FromJSONArray <TraktLike>()
                });
            }
            catch
            {
                // most likely bad header response
                return(null);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Returns the current users collected episodes
        /// </summary>
        public static IEnumerable <TraktShowCollected> GetCollectedShows()
        {
            string collectedShows = TraktWeb.GetFromTrakt(TraktURIs.CollectedShows);
            var    result         = collectedShows.FromJSONArray <TraktShowCollected>();

            if (result == null)
            {
                return(null);
            }

            // filter out anything invalid
            return(result.Where(r => r.Show.Title != null && r.Show.Ids != null));
        }
Beispiel #3
0
        /// <summary>
        /// Returns the current users watchlist seasons
        /// </summary>
        public static IEnumerable <TraktSeasonWatchlist> GetWatchlistSeasons()
        {
            string watchlistSeasons = TraktWeb.GetFromTrakt(TraktURIs.WatchlistSeasons);
            var    result           = watchlistSeasons.FromJSONArray <TraktSeasonWatchlist>();

            if (result == null)
            {
                return(null);
            }

            // filter out anything invalid
            return(result.Where(r => r.Show.Title != null && r.Show.Ids != null));
        }
Beispiel #4
0
        /// <summary>
        /// Returns the current users watched movies and play counts
        /// </summary>
        public static IEnumerable <TraktMoviePlays> GetWatchedMovies()
        {
            string watchedMovies = TraktWeb.GetFromTrakt(TraktURIs.WatchedMovies);
            var    result        = watchedMovies.FromJSONArray <TraktMoviePlays>();

            if (result == null)
            {
                return(null);
            }

            // filter out anything invalid
            return(result.Where(r => r.Movie.Title != null && r.Movie.Ids != null));
        }
Beispiel #5
0
        /// <summary>
        /// Returns the current users Rated Seasons
        /// </summary>
        public static IEnumerable <TraktUserSeasonRating> GetRatedSeasons()
        {
            string ratedSeasons = TraktWeb.GetFromTrakt(TraktURIs.RatedSeasons);
            var    result       = ratedSeasons.FromJSONArray <TraktUserSeasonRating>();

            if (result == null)
            {
                return(null);
            }

            // filter out anything invalid
            return(result.Where(r => r.Show.Title != null && r.Show.Ids != null));
        }
Beispiel #6
0
        /// <summary>
        /// Gets the seasons for a show
        /// </summary>
        /// <param name="id">the id of the tv show. Trakt ID, Trakt slug, or IMDb ID Example: game-of-thrones.</param>
        public static IEnumerable <TraktSeasonSummary> GetShowSeasons(string id, string extendedParameter = "full")
        {
            var response = TraktWeb.GetFromTrakt(string.Format(TraktURIs.SeasonSummary, id));

            return(response.FromJSONArray <TraktSeasonSummary>());
        }
Beispiel #7
0
        public static IEnumerable <TraktSyncPausedEpisode> GetPausedEpisodes()
        {
            var response = TraktWeb.GetFromTrakt(TraktURIs.SyncPausedEpisodes);

            return(response.FromJSONArray <TraktSyncPausedEpisode>());
        }
Beispiel #8
0
        public static IEnumerable <TraktListItem> GetCustomListItems(string listId, string username = "******", string extendedInfoParams = "min")
        {
            var response = TraktWeb.GetFromTrakt(string.Format(TraktURIs.UserListItems, username, listId, extendedInfoParams));

            return(response.FromJSONArray <TraktListItem>());
        }
Beispiel #9
0
        /// <summary>
        /// Returns all custom lists for a user
        /// </summary>
        /// <param name="username">Username of person's list</param>
        public static IEnumerable <TraktListDetail> GetCustomLists(string username = "******")
        {
            var response = TraktWeb.GetFromTrakt(string.Format(TraktURIs.UserLists, username));

            return(response.FromJSONArray <TraktListDetail>());
        }