Beispiel #1
0
        public void AddMovieToCollection(TraktSettings settings, Movie movie, MovieFile movieFile)
        {
            var payload = new TraktCollectMoviesResource
            {
                Movies = new List <TraktCollectMovie>()
            };

            var traktResolution = MapResolution(movieFile.Quality.Quality.Resolution, movieFile.MediaInfo?.ScanType);
            var mediaType       = MapMediaType(movieFile.Quality.Quality.Source);
            var audio           = MapAudio(movieFile);
            var audioChannels   = MapAudioChannels(movieFile, audio);

            payload.Movies.Add(new TraktCollectMovie
            {
                Title         = movie.Title,
                Year          = movie.Year,
                CollectedAt   = DateTime.Now,
                Resolution    = traktResolution,
                MediaType     = mediaType,
                AudioChannels = audioChannels,
                Audio         = audio,
                Ids           = new TraktMovieIdsResource
                {
                    Tmdb = movie.TmdbId,
                    Imdb = movie.ImdbId ?? "",
                }
            });

            _proxy.AddToCollection(payload, settings.AccessToken);
        }
Beispiel #2
0
        public ValidationFailure Test(TraktSettings settings)
        {
            try
            {
                GetUserName(settings.AccessToken);

                return(null);
            }
            catch (HttpException ex)
            {
                if (ex.Response.StatusCode == HttpStatusCode.Unauthorized)
                {
                    _logger.Error(ex, "Access Token is invalid: " + ex.Message);

                    return(new ValidationFailure("Token", "Access Token is invalid"));
                }

                _logger.Error(ex, "Unable to send test message: " + ex.Message);

                return(new ValidationFailure("Token", "Unable to send test message"));
            }
            catch (Exception ex)
            {
                _logger.Error(ex, "Unable to send test message: " + ex.Message);

                return(new ValidationFailure("", "Unable to send test message"));
            }
        }
Beispiel #3
0
        public void AddEpisodeToCollection(TraktSettings settings, Series series, EpisodeFile episodeFile)
        {
            var payload = new TraktCollectShowsResource
            {
                Shows = new List <TraktCollectShow>()
            };

            var traktResolution = MapResolution(episodeFile.Quality.Quality.Resolution, episodeFile.MediaInfo?.ScanType);
            var mediaType       = MapMediaType(episodeFile.Quality.Quality.Source);
            var audio           = MapAudio(episodeFile);
            var audioChannels   = MapAudioChannels(episodeFile, audio);

            var payloadEpisodes = new List <TraktEpisodeResource>();

            foreach (var episode in episodeFile.Episodes.Value)
            {
                payloadEpisodes.Add(new TraktEpisodeResource
                {
                    Number        = episode.EpisodeNumber,
                    CollectedAt   = DateTime.Now,
                    Resolution    = traktResolution,
                    MediaType     = mediaType,
                    AudioChannels = audioChannels,
                    Audio         = audio,
                });
            }

            var payloadSeasons = new List <TraktSeasonResource>();

            payloadSeasons.Add(new TraktSeasonResource
            {
                Number   = episodeFile.SeasonNumber,
                Episodes = payloadEpisodes
            });

            payload.Shows.Add(new TraktCollectShow
            {
                Title = series.Title,
                Year  = series.Year,
                Ids   = new TraktShowIdsResource
                {
                    Tvdb = series.TvdbId,
                    Imdb = series.ImdbId ?? "",
                },
                Seasons = payloadSeasons,
            });

            _proxy.AddToCollection(payload, settings.AccessToken);
        }
Beispiel #4
0
        public void RemoveMovieFromCollection(TraktSettings settings, Movie movie, MovieFile movieFile)
        {
            var payload = new TraktCollectMoviesResource
            {
                Movies = new List <TraktCollectMovie>()
            };

            payload.Movies.Add(new TraktCollectMovie
            {
                Title = movie.Title,
                Year  = movie.Year,
                Ids   = new TraktMovieIdsResource
                {
                    Tmdb = movie.TmdbId,
                    Imdb = movie.ImdbId ?? "",
                }
            });

            _proxy.RemoveFromCollection(payload, settings.AccessToken);
        }
Beispiel #5
0
        public void RemoveSeriesFromCollection(TraktSettings settings, Series series)
        {
            var payload = new TraktCollectShowsResource
            {
                Shows = new List <TraktCollectShow>()
            };

            payload.Shows.Add(new TraktCollectShow
            {
                Title = series.Title,
                Year  = series.Year,
                Ids   = new TraktShowIdsResource
                {
                    Tvdb = series.TvdbId,
                    Imdb = series.ImdbId ?? "",
                },
            });

            _proxy.RemoveFromCollection(payload, settings.AccessToken);
        }
Beispiel #6
0
        public void RemoveEpisodeFromCollection(TraktSettings settings, Series series, EpisodeFile episodeFile)
        {
            var payload = new TraktCollectShowsResource
            {
                Shows = new List <TraktCollectShow>()
            };

            var payloadEpisodes = new List <TraktEpisodeResource>();

            foreach (var episode in episodeFile.Episodes.Value)
            {
                payloadEpisodes.Add(new TraktEpisodeResource
                {
                    Number = episode.EpisodeNumber
                });
            }

            var payloadSeasons = new List <TraktSeasonResource>();

            payloadSeasons.Add(new TraktSeasonResource
            {
                Number   = episodeFile.SeasonNumber,
                Episodes = payloadEpisodes
            });

            payload.Shows.Add(new TraktCollectShow
            {
                Title = series.Title,
                Year  = series.Year,
                Ids   = new TraktShowIdsResource
                {
                    Tvdb = series.TvdbId,
                    Imdb = series.ImdbId ?? "",
                },
                Seasons = payloadSeasons,
            });

            _proxy.RemoveFromCollection(payload, settings.AccessToken);
        }