Example #1
0
        /// <summary>Create an instance of a <see cref="TraktMovie"/> subclass from an ID</summary>
        /// <typeparam name="T">A subclass of <see cref="TraktMovie"/> to be created</typeparam>
        /// <param name="movieId">The movie ID</param>
        /// <param name="movieIdType">The movie ID type</param>
        /// <returns>See summary</returns>
        public static T FromId <T>(string movieId, TraktTextMovieIdType movieIdType = TraktTextMovieIdType.Auto) where T : TraktMovie
        {
            if (string.IsNullOrEmpty(movieId))
            {
                throw new ArgumentException("movieId not set", "movieId");
            }

            if (movieIdType == TraktTextMovieIdType.Auto)
            {
                movieIdType = movieId.StartsWith("tt", StringComparison.OrdinalIgnoreCase) ? TraktTextMovieIdType.Imdb : TraktTextMovieIdType.Slug;
            }

            var ret = Activator.CreateInstance <T>();

            ret.Ids = new TraktMovieIds();

            switch (movieIdType)
            {
            case TraktTextMovieIdType.Slug:
                ret.Ids.Slug = movieId;
                break;

            case TraktTextMovieIdType.Imdb:
                ret.Ids.Imdb = movieId;
                break;

            default:
                throw new ArgumentOutOfRangeException("movieIdType");
            }

            return(ret);
        }
        /// <summary>Rate a movie by ID</summary>
        /// <param name="movieId">The movie ID</param>
        /// <param name="movieIdType">The movie ID type</param>
        /// <param name="rating">The rating</param>
        /// <param name="ratedAt">The UTC date when the rating was made</param>
        /// <returns>See summary</returns>
        public async Task <TraktAddResponse> AddRatingByMovieIdAsync(string movieId, TraktTextMovieIdType movieIdType, TraktRating rating, DateTime?ratedAt = null)
        {
            var obj = TraktMovieFactory.FromId <TraktMovieWithRatingsMetadata>(movieId, movieIdType);

            obj.Rating  = rating;
            obj.RatedAt = ratedAt;
            return(await AddRatingsAsync(obj));
        }
 /// <summary>Add a movie to the user's watchlist by ID</summary>
 /// <param name="movieId">The movie ID</param>
 /// <param name="movieIdType">The movie ID type</param>
 /// <returns>See summary</returns>
 public async Task <TraktAddResponse> AddToWatchlistByMovieIdAsync(string movieId, TraktTextMovieIdType movieIdType = TraktTextMovieIdType.Auto)
 {
     return(await AddToWatchlistAsync(TraktMovieFactory.FromId(movieId, movieIdType)));
 }
Example #4
0
 /// <summary>Create an collection of <see cref="TraktMovie"/> subclass instances from a collecion of IDs</summary>
 /// <typeparam name="T">A subclass of <see cref="TraktMovie"/> to be created</typeparam>
 /// <param name="movieIds">A collection of movie IDs</param>
 /// <param name="movieIdType">The movie ID type</param>
 /// <returns>See summary</returns>
 public static IEnumerable <T> FromIds <T>(IEnumerable <string> movieIds, TraktTextMovieIdType movieIdType = TraktTextMovieIdType.Auto) where T : TraktMovie
 {
     return(movieIds == null ? null : movieIds.Select(movieId => FromId <T>(movieId, movieIdType)));
 }
 /// <summary>Remove a movie from the user's watched history by ID including all watches, scrobbles, and checkins</summary>
 /// <param name="movieId">The movie ID</param>
 /// <param name="movieIdType">The movie ID type</param>
 /// <returns>See summary</returns>
 public async Task <TraktRemoveResponse> MarkUnwatchedByMovieIdAsync(string movieId, TraktTextMovieIdType movieIdType = TraktTextMovieIdType.Auto)
 {
     return(await MarkUnwatchedAsync(TraktMovieFactory.FromId(movieId, movieIdType)));
 }
Example #6
0
 /// <summary>Create an instance of <see cref="TraktMovie"/> from an ID</summary>
 /// <param name="movieId">The movie ID</param>
 /// <param name="movieIdType">The movie ID type</param>
 /// <returns>See summary</returns>
 public static TraktMovie FromId(string movieId, TraktTextMovieIdType movieIdType = TraktTextMovieIdType.Auto)
 {
     return(FromId <TraktMovie>(movieId, movieIdType));
 }
 /// <summary>Add a new comment to a movie. 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="movieId">The movie ID</param>
 /// <param name="movieIdType">The movie 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> PostMovieCommentAsync(string movieId, TraktTextMovieIdType movieIdType, string comment, bool?spoiler = null, bool?review = null)
 {
     return(await PostMovieCommentAsync(TraktMovieFactory.FromId(movieId, movieIdType), comment, spoiler, review));
 }
 /// <summary>Remove one or more items from a custom list</summary>
 /// <param name="listId">The list ID</param>
 /// <param name="movieId">The movie ID</param>
 /// <param name="movieIdType">The movie ID type</param>
 /// <returns>See summary</returns>
 public async Task <TraktRemoveResponse> RemoveFromListByMovieIdAsync(string listId, string movieId, TraktTextMovieIdType movieIdType = TraktTextMovieIdType.Auto)
 {
     return(await RemoveFromListAsync(listId, TraktMovieFactory.FromId(movieId, movieIdType)));
 }
Example #9
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="movieId">The movie ID</param>
 /// <param name="movieIdType">The movie ID type</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 <TraktScrobbleMovieResponse> StopMovieAsync(string movieId, TraktTextMovieIdType movieIdType, float progress, string appVersion = "", DateTime?appDate = null, TraktExtendedOption extended = TraktExtendedOption.Unspecified)
 {
     return(await StopMovieAsync(TraktMovieFactory.FromId(movieId, movieIdType), progress, appVersion, appDate, extended));
 }
Example #10
0
 /// <summary>Check into a movie. 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="movieId">The movie ID</param>
 /// <param name="movieIdType">The movie ID type</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 <TraktCheckinMovieResponse> CheckinMovieAsync(string movieId, TraktTextMovieIdType movieIdType, TraktSharing sharing = null, string message = "", string venueId = "", string venueName = "", string appVersion = "", DateTime?appDate = null, TraktExtendedOption extended = TraktExtendedOption.Unspecified)
 {
     return(await CheckinMovieAsync(TraktMovieFactory.FromId(movieId, movieIdType), sharing, message, venueId, venueName, appVersion, appDate, extended));
 }
 /// <summary>Add a movie to the user's watched history by ID</summary>
 /// <param name="movieId">The movie ID</param>
 /// <param name="movieIdType">The movie ID type</param>
 /// <returns>See summary</returns>
 public async Task <TraktAddResponse> MarkWatchedByMovieIdAsync(string movieId, TraktTextMovieIdType movieIdType = TraktTextMovieIdType.Auto)
 {
     return(await MarkWatchedAsync(TraktMovieFactory.FromId <TraktMovieWithWatchedMetadata>(movieId, movieIdType)));
 }
 /// <summary>Remove a movie from the user's collection by ID</summary>
 /// <param name="movieId">The movie ID</param>
 /// <param name="movieIdType">The movie ID type</param>
 /// <returns>See summary</returns>
 public async Task <TraktRemoveResponse> RemoveFromCollectionByMovieIdAsync(string movieId, TraktTextMovieIdType movieIdType = TraktTextMovieIdType.Auto)
 {
     return(await RemoveFromCollectionAsync(TraktMovieFactory.FromId(movieId, movieIdType)));
 }
Example #13
0
 /// <summary>Add a movie to the user's collection by ID</summary>
 /// <param name="movieId">The movie ID</param>
 /// <param name="movieIdType">The movie ID type</param>
 /// <returns>See summary</returns>
 public async Task <TraktAddResponse> AddToCollectionByMovieIdAsync(string movieId, TraktTextMovieIdType movieIdType = TraktTextMovieIdType.Auto)
 {
     return(await AddToCollectionAsync(TraktMovieFactory.FromId <TraktMovieWithCollectionMetadata>(movieId, movieIdType)));
 }