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); }
public void AddToCollection(TraktCollectShowsResource payload, string accessToken) { var request = BuildTraktRequest("sync/collection", HttpMethod.POST, accessToken); request.Headers.ContentType = "application/json"; request.SetContent(payload.ToJson()); try { _httpClient.Execute(request); } catch (HttpException ex) { _logger.Error(ex, "Unable to post payload {0}", payload); throw new TraktException("Unable to post payload", ex); } }
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); }
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); }