public void TestTvSeasonExtrasAll() { TvEpisodeMethods combinedEnum = _methods.Keys.Aggregate((methods, tvEpisodeMethods) => methods | tvEpisodeMethods); TvEpisode tvEpisode = _config.Client.GetTvEpisode(BreakingBad, 1, 1, combinedEnum); TestBreakingBadSeasonOneEpisodeOneBaseProperties(tvEpisode); TestMethodsHelper.TestAllNotNull(_methods, tvEpisode); }
public void TestTvEpisodeExtrasAll() { TvEpisodeMethods combinedEnum = _methods.Keys.Aggregate((methods, tvEpisodeMethods) => methods | tvEpisodeMethods); TvEpisode tvEpisode = _config.Client.GetTvEpisode(BreakingBad, 1, 1, combinedEnum); TestBreakingBadSeasonOneEpisodeOneBaseProperties(tvEpisode); Assert.IsNotNull(tvEpisode.Images); Assert.IsNotNull(tvEpisode.Images.Stills); Assert.IsTrue(tvEpisode.Images.Stills.Count > 0); TestMethodsHelper.TestAllNotNull(_methods, tvEpisode); }
public void TestTvEpisodeExtrasAll() { _config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession); // Account states will only show up if we've done something _config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, 5).Wait(); TvEpisodeMethods combinedEnum = _methods.Keys.Aggregate((methods, tvEpisodeMethods) => methods | tvEpisodeMethods); TvEpisode tvEpisode = _config.Client.GetTvEpisodeAsync(IdHelper.BreakingBad, 1, 1, combinedEnum).Result; TestBreakingBadSeasonOneEpisodeOneBaseProperties(tvEpisode); Assert.IsNotNull(tvEpisode.Images); Assert.IsNotNull(tvEpisode.Images.Stills); Assert.IsTrue(tvEpisode.Images.Stills.Count > 0); TestMethodsHelper.TestAllNotNull(_methods, tvEpisode); }
public void TestTvEpisodeExtrasAll() { IgnoreMissingJson("credits / id", "external_ids / id", "images / id", "videos / id"); Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession); // Account states will only show up if we've done something Config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, 5).Sync(); TvEpisodeMethods combinedEnum = _methods.Keys.Aggregate((methods, tvEpisodeMethods) => methods | tvEpisodeMethods); TvEpisode tvEpisode = Config.Client.GetTvEpisodeAsync(IdHelper.BreakingBad, 1, 1, combinedEnum).Result; TestBreakingBadSeasonOneEpisodeOneBaseProperties(tvEpisode); Assert.NotNull(tvEpisode.Images); Assert.NotNull(tvEpisode.Images.Stills); Assert.True(tvEpisode.Images.Stills.Count > 0); TestMethodsHelper.TestAllNotNull(_methods, tvEpisode); }
/// <summary> /// Retrieve a specific episode using TMDb id of the associated tv show. /// </summary> /// <param name="tvShowId">TMDb id of the tv show the desired episode belongs to.</param> /// <param name="seasonNumber">The season number of the season the episode belongs to. Note use 0 for specials.</param> /// <param name="episodeNumber">The episode number of the episode you want to retrieve.</param> /// <param name="extraMethods">Enum flags indicating any additional data that should be fetched in the same request.</param> /// <param name="language">If specified the api will attempt to return a localized result. ex: en,it,es </param> /// <param name="includeImageLanguage">If specified the api will attempt to return localized image results eg. en,it,es.</param> /// <param name="cancellationToken">A cancellation token</param> public async Task <TvEpisode> GetTvEpisodeAsync(int tvShowId, int seasonNumber, int episodeNumber, TvEpisodeMethods extraMethods = TvEpisodeMethods.Undefined, string language = null, string includeImageLanguage = null, CancellationToken cancellationToken = default) { if (extraMethods.HasFlag(TvEpisodeMethods.AccountStates)) { RequireSessionId(SessionType.UserSession); } RestRequest req = _client.Create("tv/{id}/season/{season_number}/episode/{episode_number}"); req.AddUrlSegment("id", tvShowId.ToString(CultureInfo.InvariantCulture)); req.AddUrlSegment("season_number", seasonNumber.ToString(CultureInfo.InvariantCulture)); req.AddUrlSegment("episode_number", episodeNumber.ToString(CultureInfo.InvariantCulture)); if (extraMethods.HasFlag(TvEpisodeMethods.AccountStates)) { AddSessionId(req, SessionType.UserSession); } language ??= DefaultLanguage; if (!string.IsNullOrWhiteSpace(language)) { req.AddParameter("language", language); } includeImageLanguage ??= DefaultImageLanguage; if (!string.IsNullOrWhiteSpace(includeImageLanguage)) { req.AddParameter("include_image_language", includeImageLanguage); } string appends = string.Join(",", Enum.GetValues(typeof(TvEpisodeMethods)) .OfType <TvEpisodeMethods>() .Except(new[] { TvEpisodeMethods.Undefined }) .Where(s => extraMethods.HasFlag(s)) .Select(s => s.GetDescription())); if (appends != string.Empty) { req.AddParameter("append_to_response", appends); } RestResponse <TvEpisode> response = await req.Get <TvEpisode>(cancellationToken).ConfigureAwait(false); if (!response.IsValid) { return(null); } TvEpisode item = await response.GetDataObject().ConfigureAwait(false); // No data to patch up so return if (item == null) { return(null); } // Patch up data, so that the end user won't notice that we share objects between request-types. if (item.Videos != null) { item.Videos.Id = item.Id ?? 0; } if (item.Credits != null) { item.Credits.Id = item.Id ?? 0; } if (item.Images != null) { item.Images.Id = item.Id ?? 0; } if (item.ExternalIds != null) { item.ExternalIds.Id = item.Id ?? 0; } return(item); }
private async Task <T> GetTvEpisodeMethodInternal <T>(int tvShowId, int seasonNumber, int episodeNumber, TvEpisodeMethods tvShowMethod, string dateFormat = null, string language = null, CancellationToken cancellationToken = default) where T : new() { RestRequest req = _client.Create("tv/{id}/season/{season_number}/episode/{episode_number}/{method}"); req.AddUrlSegment("id", tvShowId.ToString(CultureInfo.InvariantCulture)); req.AddUrlSegment("season_number", seasonNumber.ToString(CultureInfo.InvariantCulture)); req.AddUrlSegment("episode_number", episodeNumber.ToString(CultureInfo.InvariantCulture)); req.AddUrlSegment("method", tvShowMethod.GetDescription()); // TODO: Dateformat? //if (dateFormat != null) // req.DateFormat = dateFormat; language ??= DefaultLanguage; if (!string.IsNullOrWhiteSpace(language)) { req.AddParameter("language", language); } T resp = await req.GetOfT <T>(cancellationToken).ConfigureAwait(false); return(resp); }
private T GetTvEpisodeMethod <T>(int tvShowId, int seasonNumber, int episodeNumber, TvEpisodeMethods tvShowMethod, string dateFormat = null, string language = null) where T : new() { RestRequest req = new RestRequest("tv/{id}/season/{season_number}/episode/{episode_number}/{method}"); req.AddUrlSegment("id", tvShowId.ToString(CultureInfo.InvariantCulture)); req.AddUrlSegment("season_number", seasonNumber.ToString(CultureInfo.InvariantCulture)); req.AddUrlSegment("episode_number", episodeNumber.ToString(CultureInfo.InvariantCulture)); req.AddUrlSegment("method", tvShowMethod.GetDescription()); if (dateFormat != null) { req.DateFormat = dateFormat; } if (language != null) { req.AddParameter("language", language); } IRestResponse <T> resp = _client.Get <T>(req); return(resp.Data); }
/// <summary> /// Retrieve a specific episode using TMDb id of the associated tv show. /// </summary> /// <param name="tvShowId">TMDb id of the tv show the desired episode belongs to.</param> /// <param name="seasonNumber">The season number of the season the episode belongs to. Note use 0 for specials.</param> /// <param name="episodeNumber">The episode number of the episode you want to retrieve.</param> /// <param name="extraMethods">Enum flags indicating any additional data that should be fetched in the same request.</param> /// <param name="language">If specified the api will attempt to return a localized result. ex: en,it,es </param> public TvEpisode GetTvEpisode(int tvShowId, int seasonNumber, int episodeNumber, TvEpisodeMethods extraMethods = TvEpisodeMethods.Undefined, string language = null) { RestRequest req = new RestRequest("tv/{id}/season/{season_number}/episode/{episode_number}"); req.AddUrlSegment("id", tvShowId.ToString(CultureInfo.InvariantCulture)); req.AddUrlSegment("season_number", seasonNumber.ToString(CultureInfo.InvariantCulture)); req.AddUrlSegment("episode_number", episodeNumber.ToString(CultureInfo.InvariantCulture)); if (language != null) { req.AddParameter("language", language); } string appends = string.Join(",", Enum.GetValues(typeof(TvEpisodeMethods)) .OfType <TvEpisodeMethods>() .Except(new[] { TvEpisodeMethods.Undefined }) .Where(s => extraMethods.HasFlag(s)) .Select(s => s.GetDescription())); if (appends != string.Empty) { req.AddParameter("append_to_response", appends); } IRestResponse <TvEpisode> response = _client.Get <TvEpisode>(req); return(response.Data); }
/// <summary> /// Retrieve a specific episode using TMDb id of the associated tv show. /// </summary> /// <param name="tvShowId">TMDb id of the tv show the desired episode belongs to.</param> /// <param name="seasonNumber">The season number of the season the episode belongs to. Note use 0 for specials.</param> /// <param name="episodeNumber">The episode number of the episode you want to retrieve.</param> /// <param name="extraMethods">Enum flags indicating any additional data that should be fetched in the same request.</param> /// <param name="language">If specified the api will attempt to return a localized result. ex: en,it,es </param> public TvEpisode GetTvEpisode(int tvShowId, int seasonNumber, int episodeNumber, TvEpisodeMethods extraMethods = TvEpisodeMethods.Undefined, string language = null) { if (extraMethods.HasFlag(TvEpisodeMethods.AccountStates)) { RequireSessionId(SessionType.UserSession); } RestRequest request = new RestRequest("tv/{id}/season/{season_number}/episode/{episode_number}"); request.AddUrlSegment("id", tvShowId.ToString(CultureInfo.InvariantCulture)); request.AddUrlSegment("season_number", seasonNumber.ToString(CultureInfo.InvariantCulture)); request.AddUrlSegment("episode_number", episodeNumber.ToString(CultureInfo.InvariantCulture)); if (extraMethods.HasFlag(TvEpisodeMethods.AccountStates)) { request.AddParameter("session_id", SessionId); } language = language ?? DefaultLanguage; if (!String.IsNullOrWhiteSpace(language)) { request.AddParameter("language", language); } string appends = string.Join(",", Enum.GetValues(typeof(TvEpisodeMethods)) .OfType <TvEpisodeMethods>() .Except(new[] { TvEpisodeMethods.Undefined }) .Where(s => extraMethods.HasFlag(s)) .Select(s => s.GetDescription())); if (appends != string.Empty) { request.AddParameter("append_to_response", appends); } IRestResponse <TvEpisode> response = _client.Get <TvEpisode>(request); // No data to patch up so return if (response.Data == null) { return(null); } // Patch up data, so that the end user won't notice that we share objects between request-types. if (response.Data.Videos != null) { response.Data.Videos.Id = response.Data.Id ?? 0; } if (response.Data.Credits != null) { response.Data.Credits.Id = response.Data.Id ?? 0; } if (response.Data.Images != null) { response.Data.Images.Id = response.Data.Id ?? 0; } if (response.Data.ExternalIds != null) { response.Data.ExternalIds.Id = response.Data.Id ?? 0; } if (response.Data.AccountStates != null) { response.Data.AccountStates.Id = response.Data.Id ?? 0; // Do some custom deserialization, since TMDb uses a property that changes type we can't use automatic deserialization CustomDeserialization.DeserializeAccountStatesRating(response.Data.AccountStates, response.Content); } return(response.Data); }
/// <summary> /// Retrieve a specific episode using TMDb id of the associated tv show. /// </summary> /// <param name="tvShowId">TMDb id of the tv show the desired episode belongs to.</param> /// <param name="seasonNumber">The season number of the season the episode belongs to. Note use 0 for specials.</param> /// <param name="episodeNumber">The episode number of the episode you want to retrieve.</param> /// <param name="extraMethods">Enum flags indicating any additional data that should be fetched in the same request.</param> /// <param name="language">If specified the api will attempt to return a localized result. ex: en,it,es </param> public TvEpisode GetTvEpisode(int tvShowId, int seasonNumber, int episodeNumber, TvEpisodeMethods extraMethods = TvEpisodeMethods.Undefined, string language = null) { RestRequest req = new RestRequest("tv/{id}/season/{season_number}/episode/{episode_number}"); req.AddUrlSegment("id", tvShowId.ToString(CultureInfo.InvariantCulture)); req.AddUrlSegment("season_number", seasonNumber.ToString(CultureInfo.InvariantCulture)); req.AddUrlSegment("episode_number", episodeNumber.ToString(CultureInfo.InvariantCulture)); language = language ?? DefaultLanguage; if (!String.IsNullOrWhiteSpace(language)) { req.AddParameter("language", language); } string appends = string.Join(",", Enum.GetValues(typeof(TvEpisodeMethods)) .OfType <TvEpisodeMethods>() .Except(new[] { TvEpisodeMethods.Undefined }) .Where(s => extraMethods.HasFlag(s)) .Select(s => s.GetDescription())); if (appends != string.Empty) { req.AddParameter("append_to_response", appends); } IRestResponse <TvEpisode> response = _client.Get <TvEpisode>(req); // No data to patch up so return if (response.Data == null) { return(null); } // Patch up data, so that the end user won't notice that we share objects between request-types. if (response.Data.Videos != null) { response.Data.Videos.Id = response.Data.Id ?? 0; } if (response.Data.Credits != null) { response.Data.Credits.Id = response.Data.Id ?? 0; } if (response.Data.Images != null) { response.Data.Images.Id = response.Data.Id ?? 0; } if (response.Data.ExternalIds != null) { response.Data.ExternalIds.Id = response.Data.Id ?? 0; } return(response.Data); }
private async Task <T> GetTvEpisodeMethod <T>(int tvShowId, int seasonNumber, int episodeNumber, TvEpisodeMethods tvShowMethod, string dateFormat = null, string language = null) where T : new() { RestRequest req = new RestRequest("tv/{id}/season/{season_number}/episode/{episode_number}/{method}"); req.AddUrlSegment("id", tvShowId.ToString(CultureInfo.InvariantCulture)); req.AddUrlSegment("season_number", seasonNumber.ToString(CultureInfo.InvariantCulture)); req.AddUrlSegment("episode_number", episodeNumber.ToString(CultureInfo.InvariantCulture)); req.AddUrlSegment("method", tvShowMethod.GetDescription()); if (dateFormat != null) { req.DateFormat = dateFormat; } language = language ?? DefaultLanguage; if (!String.IsNullOrWhiteSpace(language)) { req.AddParameter("language", language); } IRestResponse <T> resp = await _client.ExecuteGetTaskAsync <T>(req).ConfigureAwait(false); return(resp.Data); }