/// <summary>Remove one or more items from the user's collection by IDs</summary>
 /// <param name="movieIds">A collection of movie IDs</param>
 /// <param name="showIds">A collection of show IDs</param>
 /// <param name="episodeIds">A collection of episode IDs</param>
 /// <returns>See summary</returns>
 public async Task <TraktRemoveResponse> RemoveFromCollectionAsync(IEnumerable <string> movieIds, IEnumerable <string> showIds, IEnumerable <string> episodeIds)
 {
     return(await RemoveFromCollectionAsync(
                TraktMovieFactory.FromIds(movieIds),
                TraktShowFactory.FromIds(showIds),
                TraktEpisodeFactory.FromIds(episodeIds)));
 }
 /// <summary>Add one or more items to the user's watchlist by IDs</summary>
 /// <param name="movieIds">A collection of movie IDs</param>
 /// <param name="showIds">A collection of show IDs</param>
 /// <param name="episodeIds">A collection of episode IDs</param>
 /// <returns>See summary</returns>
 public async Task <TraktAddResponse> AddToWatchlistAsync(IEnumerable <string> movieIds, IEnumerable <string> showIds, IEnumerable <string> episodeIds)
 {
     return(await AddToWatchlistAsync(
                TraktMovieFactory.FromIds <TraktMovie>(movieIds),
                TraktShowFactory.FromIds <TraktShow>(showIds),
                TraktEpisodeFactory.FromIds <TraktEpisode>(episodeIds)));
 }
 /// <summary>Rate one or more items</summary>
 /// <param name="movieIds">A collection of movie IDs</param>
 /// <param name="showIds">A collection of show IDs</param>
 /// <param name="episodeIds">A collection of episode IDs</param>
 /// <returns>See summary</returns>
 public async Task <TraktAddResponse> AddRatingsAsync(IEnumerable <string> movieIds, IEnumerable <string> showIds, IEnumerable <string> episodeIds)
 {
     return(await AddRatingsAsync(
                TraktMovieFactory.FromIds <TraktMovieWithRatingsMetadata>(movieIds),
                TraktShowFactory.FromIds <TraktShowWithRatingsMetadata>(showIds),
                TraktEpisodeFactory.FromIds <TraktEpisodeWithRatingsMetadata>(episodeIds)));
 }
 /// <summary>Remove one or more items from a user's watched history by ID including all watches, scrobbles, and checkins</summary>
 /// <param name="movieIds">A collection of movie IDs</param>
 /// <param name="showIds">A collection of show IDs</param>
 /// <param name="episodeIds">A collection of episode IDs</param>
 /// <returns>See summary</returns>
 public async Task <TraktRemoveResponse> MarkUnwatchedAsync(IEnumerable <string> movieIds, IEnumerable <string> showIds, IEnumerable <string> episodeIds)
 {
     return(await MarkUnwatchedAsync(
                TraktMovieFactory.FromIds(movieIds),
                TraktShowFactory.FromIds(showIds),
                TraktEpisodeFactory.FromIds(episodeIds)));
 }
 /// <summary>Remove one or more items from a custom list</summary>
 /// <param name="listId">The list ID</param>
 /// <param name="movieIds">A collection of movie IDs</param>
 /// <param name="showIds">A collection of show IDs</param>
 /// <param name="episodeIds">A collection of episode IDs</param>
 /// <param name="personIds">A collection of person IDs</param>
 /// <returns>See summary</returns>
 public async Task <TraktRemoveResponse> RemoveFromListAsync(string listId, IEnumerable <string> movieIds, IEnumerable <string> showIds, IEnumerable <string> episodeIds, IEnumerable <string> personIds)
 {
     return(await RemoveFromListAsync(
                listId,
                TraktMovieFactory.FromIds <TraktMovie>(movieIds),
                TraktShowFactory.FromIds <TraktShow>(showIds),
                null,          //Seasons only have numeric IDs. For simplicity, exclude them from this overload
                TraktEpisodeFactory.FromIds <TraktEpisode>(episodeIds),
                TraktPersonFactory.FromIds <TraktPerson>(personIds)));
 }
        /// <summary>Remove a show from the user's watched history by ID including all watches, scrobbles, and checkins</summary>
        /// <param name="showId">The show ID</param>
        /// <param name="showIdType">The show ID type</param>
        /// <param name="seasonNumbers">If set, the action will be applied to the specified season numbers instead of the show itself</param>
        /// <returns>See summary</returns>
        public async Task <TraktRemoveResponse> MarkUnwatchedByShowIdAsync(string showId, TraktTextShowIdType showIdType = TraktTextShowIdType.Auto, IEnumerable <int> seasonNumbers = null)
        {
            var obj = TraktShowFactory.FromId(showId, showIdType);

            if (seasonNumbers != null)
            {
                obj.Seasons = seasonNumbers.Select(s => new TraktSeason {
                    SeasonNumber = s
                }).ToList();
            }
            return(await MarkUnwatchedAsync(obj));
        }
        /// <summary>Add a show to the user's watched history by ID</summary>
        /// <param name="showId">The show ID</param>
        /// <param name="showIdType">The show ID type</param>
        /// <param name="seasonNumbers">If set, the action will be applied to the specified season numbers instead of the show itself</param>
        /// <returns>See summary</returns>
        public async Task <TraktAddResponse> MarkWatchedByShowIdAsync(int showId, TraktNumericShowIdType showIdType, IEnumerable <int> seasonNumbers = null)
        {
            var obj = TraktShowFactory.FromId <TraktShowWithWatchedMetadata>(showId, showIdType);

            if (seasonNumbers != null)
            {
                obj.Seasons = seasonNumbers.Select(s => new TraktSeasonWithWatchedMetadata {
                    SeasonNumber = s
                }).ToList();
            }
            return(await MarkWatchedAsync(obj));
        }
        /// <summary>Add a show to the user's watchlist by ID</summary>
        /// <param name="showId">The show ID</param>
        /// <param name="showIdType">The show ID type</param>
        /// <param name="seasonNumbers">If set, the action will be applied to the specified season numbers instead of the show itself</param>
        /// <returns>See summary</returns>
        public async Task <TraktAddResponse> AddToWatchlistByShowIdAsync(int showId, TraktNumericShowIdType showIdType, IEnumerable <int> seasonNumbers = null)
        {
            var obj = TraktShowFactory.FromId(showId, showIdType);

            if (seasonNumbers != null)
            {
                obj.Seasons = seasonNumbers.Select(s => new TraktSeason {
                    SeasonNumber = s
                }).ToList();
            }
            return(await AddToWatchlistAsync(obj));
        }
Ejemplo n.º 9
0
        /// <summary>Add a show to the user's collection by ID</summary>
        /// <param name="showId">The show ID</param>
        /// <param name="showIdType">The show ID type</param>
        /// <param name="seasonNumbers">If set, the action will be applied to the specified season numbers instead of the show itself</param>
        /// <returns>See summary</returns>
        public async Task <TraktAddResponse> AddToCollectionByShowIdAsync(string showId, TraktTextShowIdType showIdType = TraktTextShowIdType.Auto, IEnumerable <int> seasonNumbers = null)
        {
            var obj = TraktShowFactory.FromId <TraktShowWithCollectionMetadata>(showId, showIdType);

            if (seasonNumbers != null)
            {
                obj.Seasons = seasonNumbers.Select(s => new TraktSeasonWithCollectionMetadata {
                    SeasonNumber = s
                }).ToList();
            }
            return(await AddToCollectionAsync(obj));
        }
        /// <summary>Rate a show by ID</summary>
        /// <param name="showId">The show ID</param>
        /// <param name="showIdType">The show ID type</param>
        /// <param name="rating">The rating</param>
        /// <param name="ratedAt">The UTC date when the rating was made</param>
        /// <param name="seasonNumbers">If set, the action will be applied to the specified season numbers instead of the show itself</param>
        /// <returns>See summary</returns>
        public async Task <TraktAddResponse> AddRatingByShowIdAsync(int showId, TraktNumericShowIdType showIdType, TraktRating rating, DateTime?ratedAt = null, IEnumerable <int> seasonNumbers = null)
        {
            var obj = TraktShowFactory.FromId <TraktShowWithRatingsMetadata>(showId, showIdType);

            obj.Rating  = rating;
            obj.RatedAt = ratedAt;
            if (seasonNumbers != null)
            {
                obj.Seasons = seasonNumbers.Select(s => new TraktSeasonWithRatingsMetadata {
                    SeasonNumber = s
                }).ToList();
            }
            return(await AddRatingsAsync(obj));
        }
 /// <summary>Remove one or more items from a custom list</summary>
 /// <param name="listId">The list ID</param>
 /// <param name="showId">The show ID</param>
 /// <param name="showIdType">The show ID type</param>
 /// <returns>See summary</returns>
 public async Task <TraktRemoveResponse> RemoveFromListByShowIdAsync(string listId, int showId, TraktNumericShowIdType showIdType)
 {
     return(await RemoveFromListAsync(listId, TraktShowFactory.FromId(showId, showIdType)));
 }
Ejemplo n.º 12
0
 /// <summary>Add a new comment to a show. If you add a review, it needs to be at least 200 words. Also make sure to allow and encourage spoilers to be indicated in your app.</summary>
 /// <param name="showId">The show ID</param>
 /// <param name="showIdType">The show ID type</param>
 /// <param name="comment">The comment</param>
 /// <param name="spoiler">Set to <c>true</c> if the comment contains spoilers</param>
 /// <param name="review">Set to <c>true</c> if the comment is a review</param>
 /// <returns>See summary</returns>
 public async Task <TraktComment> PostShowCommentAsync(int showId, TraktNumericShowIdType showIdType, string comment, bool?spoiler = null, bool?review = null)
 {
     return(await PostShowCommentAsync(TraktShowFactory.FromId(showId, showIdType), comment, spoiler, review));
 }
Ejemplo n.º 13
0
 /// <summary>Add a new comment to a show. If you add a review, it needs to be at least 200 words. Also make sure to allow and encourage spoilers to be indicated in your app.</summary>
 /// <param name="showTitle">The show title</param>
 /// <param name="showYear">The show release year (first season)</param>
 /// <param name="comment">The comment</param>
 /// <param name="spoiler">Set to <c>true</c> if the comment contains spoilers</param>
 /// <param name="review">Set to <c>true</c> if the comment is a review</param>
 /// <returns>See summary</returns>
 public async Task <TraktComment> PostShowCommentAsync(string showTitle, int?showYear, string comment, bool?spoiler = null, bool?review = null)
 {
     return(await PostShowCommentAsync(TraktShowFactory.FromTitleAndYear(showTitle, showYear), comment, spoiler, review));
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Use this method when the video is stopped or finishes playing on its own. If the progress is above 80%, the video will be scrobbled and the action will be set to scrobble.
 /// If the progress is less than 80%, it will be treated as a pause and the action will be set to pause. The playback progress will be saved and
 /// <see cref="TraktSyncModule.GetPlaybackStateAsync"/> can be used to resume the video from this exact position.
 /// </summary>
 /// <param name="showTitle">The show title</param>
 /// <param name="showYear">The show release year (first season)</param>
 /// <param name="seasonNumber">The season number</param>
 /// <param name="episodeNumber">The episode number within the specified season</param>
 /// <param name="progress">The user's current playback progress through this item as a percentage between 0 and 100</param>
 /// <param name="appVersion">Version number of the app</param>
 /// <param name="appDate">Build date of the app</param>
 /// <param name="extended">Changes which properties are populated for standard media objects. By default, minimal data is returned. Change this if additional fields are required in the returned data.</param>
 /// <returns>See summary</returns>
 public async Task <TraktScrobbleEpisodeResponse> StopEpisodeAsync(string showTitle, int?showYear, int seasonNumber, int episodeNumber, float progress, string appVersion = "", DateTime?appDate = null, TraktExtendedOption extended = TraktExtendedOption.Unspecified)
 {
     return(await StopEpisodeAsync(TraktEpisodeFactory.FromSeasonAndEpisodeNumber(seasonNumber, episodeNumber), TraktShowFactory.FromTitleAndYear(showTitle, showYear), progress, appVersion, appDate, extended));
 }
Ejemplo n.º 15
0
 /// <summary>Check into an episode. This should be tied to a user action to manually indicate they are watching something.
 /// The item will display as watching on the site, then automatically switch to watched status once the duration has elapsed.</summary>
 /// <param name="showTitle">The show title</param>
 /// <param name="showYear">The show release year (first season)</param>
 /// <param name="seasonNumber">The season number</param>
 /// <param name="episodeNumber">The episode number within the specified season</param>
 /// <param name="sharing">Control sharing to any connected social networks</param>
 /// <param name="message">Message used for sharing. If not sent, it will use the watching string in the user settings.</param>
 /// <param name="venueId">Foursquare venue ID</param>
 /// <param name="venueName">Foursquare venue name</param>
 /// <param name="appVersion">Version number of the app</param>
 /// <param name="appDate">Build date of the app</param>
 /// <param name="extended">Changes which properties are populated for standard media objects. By default, minimal data is returned. Change this if additional fields are required in the returned data.</param>
 /// <returns>See summary</returns>
 public async Task <TraktCheckinEpisodeResponse> CheckinEpisodeAsync(string showTitle, int?showYear, int seasonNumber, int episodeNumber, TraktSharing sharing = null, string message = "", string venueId = "", string venueName = "", string appVersion = "", DateTime?appDate = null, TraktExtendedOption extended = TraktExtendedOption.Unspecified)
 {
     return(await CheckinEpisodeAsync(TraktEpisodeFactory.FromSeasonAndEpisodeNumber(seasonNumber, episodeNumber), TraktShowFactory.FromTitleAndYear(showTitle, showYear), sharing, message, venueId, venueName, appVersion, appDate, extended));
 }
Ejemplo n.º 16
0
        public async Task TestCheckinCheckinEpisodeAsync()
        {
            FakeResponsePath = @"Checkin\Episode.json";

            ((Action)(() => Client.Checkin.CheckinEpisodeAsync(string.Empty, TraktTextEpisodeIdType.Auto).Wait())).Should().Throw <ArgumentException>();
            ((Action)(() => Client.Checkin.CheckinEpisodeAsync(string.Empty, TraktTextEpisodeIdType.Imdb).Wait())).Should().Throw <ArgumentException>();
            ((Action)(() => Client.Checkin.CheckinEpisodeAsync("foobar", TraktTextEpisodeIdType.Auto).Wait())).Should().Throw <ArgumentException>();
            ((Action)(() => Client.Checkin.CheckinEpisodeAsync(0, TraktNumericEpisodeIdType.Trakt).Wait())).Should().Throw <ArgumentException>();
            ((Action)(() => Client.Checkin.CheckinEpisodeAsync(0, TraktNumericEpisodeIdType.Tmdb).Wait())).Should().Throw <ArgumentException>();
            ((Action)(() => Client.Checkin.CheckinEpisodeAsync(0, TraktNumericEpisodeIdType.Tvdb).Wait())).Should().Throw <ArgumentException>();
            ((Action)(() => Client.Checkin.CheckinEpisodeAsync(0, TraktNumericEpisodeIdType.TvRage).Wait())).Should().Throw <ArgumentException>();
            ((Action)(() => Client.Checkin.CheckinEpisodeAsync(string.Empty, 1, 1, 1).Wait())).Should().Throw <ArgumentException>();
            ((Action)(() => Client.Checkin.CheckinEpisodeAsync("ttfoobar", 1, 0, 1).Wait())).Should().Throw <ArgumentException>();
            ((Action)(() => Client.Checkin.CheckinEpisodeAsync("ttfoobar", 1, 1, 0).Wait())).Should().Throw <ArgumentException>();
            ((Action)(() => Client.Checkin.CheckinEpisodeAsync(null).Wait())).Should().Throw <ArgumentException>();
            ((Action)(() => Client.Checkin.CheckinEpisodeAsync(new TraktEpisode()).Wait())).Should().Throw <ArgumentException>();

            ((Action)(() => Client.Checkin.CheckinEpisodeAsync("ttfoobar", TraktTextEpisodeIdType.Auto).Wait())).Should().NotThrow();
            ((Action)(() => Client.Checkin.CheckinEpisodeAsync("ttfoobar", TraktTextEpisodeIdType.Imdb).Wait())).Should().NotThrow();
            ((Action)(() => Client.Checkin.CheckinEpisodeAsync(1, TraktNumericEpisodeIdType.Trakt).Wait())).Should().NotThrow();
            ((Action)(() => Client.Checkin.CheckinEpisodeAsync(1, TraktNumericEpisodeIdType.Tmdb).Wait())).Should().NotThrow();
            ((Action)(() => Client.Checkin.CheckinEpisodeAsync(1, TraktNumericEpisodeIdType.Tvdb).Wait())).Should().NotThrow();
            ((Action)(() => Client.Checkin.CheckinEpisodeAsync(1, TraktNumericEpisodeIdType.TvRage).Wait())).Should().NotThrow();
            ((Action)(() => Client.Checkin.CheckinEpisodeAsync("ttfoobar", 1, 1, 1).Wait())).Should().NotThrow();
            ((Action)(() => Client.Checkin.CheckinEpisodeAsync("ttfoobar", 0, 1, 1).Wait())).Should().NotThrow();
            ((Action)(() => Client.Checkin.CheckinEpisodeAsync(TraktEpisodeFactory.FromId("ttfoobar")).Wait())).Should().NotThrow();

            var result = await Client.Checkin.CheckinEpisodeAsync(
                TraktEpisodeFactory.FromId("ttfoobar"),
                TraktShowFactory.FromId("ttfoobar"),
                new TraktSharing { Facebook = true, Tumblr = true, Twitter = true },
                "foobar",
                "foobar",
                "foobar",
                "foobar",
                DateTime.Now,
                TraktExtendedOption.Full);

            result.Should().BeOfType(typeof(TraktCheckinEpisodeResponse));
            result.WatchedAt.Should().Be(DateTime.Parse("2014-08-06T06:54:36.859Z", null, DateTimeStyles.RoundtripKind));
            result.Sharing.Facebook.Should().BeTrue();
            result.Sharing.Twitter.Should().BeTrue();
            result.Sharing.Tumblr.Should().BeFalse();
            result.Episode.SeasonNumber.Should().Be(1);
            result.Episode.EpisodeNumber.Should().Be(1);
            result.Episode.Title.Should().Be("Pilot");
            result.Episode.Ids.Trakt.Should().Be(16);
            result.Episode.Ids.Tvdb.Should().Be(349232);
            result.Episode.Ids.Imdb.Should().Be("tt0959621");
            result.Episode.Ids.Tmdb.Should().Be(62085);
            result.Episode.Ids.TvRage.Should().Be(637041);
            result.Episode.Rating.Should().NotHaveValue();
            result.Show.Title.Should().Be("Breaking Bad");
            result.Show.Year.Should().Be(2008);
            result.Show.Ids.Trakt.Should().Be(1);
            result.Show.Ids.Slug.Should().Be("breaking-bad");
            result.Show.Ids.Tvdb.Should().Be(81189);
            result.Show.Ids.Imdb.Should().Be("tt0903747");
            result.Show.Ids.Tmdb.Should().Be(1396);
            result.Show.Ids.TvRage.Should().Be(18164);
            result.Show.Rating.Should().NotHaveValue();

            FakeResponsePath = @"Checkin\Error.409.json";
            FakeResponseCode = HttpStatusCode.Conflict;
            var ex = ((Action)(() => Client.Checkin.CheckinEpisodeAsync("ttfoobar", TraktTextEpisodeIdType.Auto).Wait())).Should().Throw <TraktConflictException>().Which;

            ex.ExpiresAt.Should().Be(DateTime.Parse("2014-10-15T22:21:29.000Z", null, DateTimeStyles.RoundtripKind));
            ex.StatusCode.Should().Be(FakeResponseCode);
            ex.TraktErrorType.Should().BeNull();
        }
 /// <summary>Remove one or more items from a custom list</summary>
 /// <param name="listId">The list ID</param>
 /// <param name="showId">The show ID</param>
 /// <param name="showIdType">The show ID type</param>
 /// <returns>See summary</returns>
 public async Task <TraktRemoveResponse> RemoveFromListByShowIdAsync(string listId, string showId, TraktTextShowIdType showIdType = TraktTextShowIdType.Auto)
 {
     return(await RemoveFromListAsync(listId, TraktShowFactory.FromId(showId, showIdType)));
 }