TMDbLib/Client/TMDbClientTvSeasons.cs
/// <summary>
/// Retrieve a season for a specifc tv Show by id.
/// </summary>
/// <param name="tvShowId">TMDb id of the tv show the desired season belongs to.</param>
/// <param name="seasonNumber">The season number of the season you want to retrieve. Note use 0 for specials.</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>
/// <returns>The requested season for the specified tv show</returns>
Retrieve a season for a specifc tv Show by id.
Retrieve a season for a specifc tv Show by id .
public async Task<TvSeason> GetTvSeasonAsync(int tvShowId, int seasonNumber, TvSeasonMethods extraMethods = TvSeasonMethods.Undefined, string language = null, string includeImageLanguage = null, CancellationToken cancellationToken = default)
        {
            if (extraMethods.HasFlag(TvSeasonMethods.AccountStates))
                RequireSessionId(SessionType.UserSession);
            RestRequest req = _client.Create("tv/{id}/season/{season_number}");
            req.AddUrlSegment("id", tvShowId.ToString(CultureInfo.InvariantCulture));
            req.AddUrlSegment("season_number", seasonNumber.ToString(CultureInfo.InvariantCulture));
            if (extraMethods.HasFlag(TvSeasonMethods.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(TvSeasonMethods))
                                             .OfType<TvSeasonMethods>()
                                             .Except(new[] { TvSeasonMethods.Undefined })
                                             .Where(s => extraMethods.HasFlag(s))
                                             .Select(s => s.GetDescription()));
            if (appends != string.Empty)
                req.AddParameter("append_to_response", appends);
            RestResponse<TvSeason> response = await req.Get<TvSeason>(cancellationToken).ConfigureAwait(false);
            if (!response.IsValid)
                return null;
            TvSeason item = await response.GetDataObject().ConfigureAwait(false);
            if (item == null)
                return null;
            if (item.Images != null)
                item.Images.Id = item.Id ?? 0;
            if (item.Credits != null)
                item.Credits.Id = item.Id ?? 0;
            if (item.ExternalIds != null)
                item.ExternalIds.Id = item.Id ?? 0;
            if (item.AccountStates != null)
                item.AccountStates.Id = item.Id ?? 0;
            if (item.Videos != null)
                item.Videos.Id = item.Id ?? 0;
            return item;
        }
public async Task < TvSeason > GetTvSeasonAsync ( int tvShowId , int seasonNumber , TvSeasonMethods extraMethods = TvSeasonMethods . Undefined , string language = null , string includeImageLanguage = null , CancellationToken cancellationToken = default ) { if ( extraMethods . HasFlag ( TvSeasonMethods . AccountStates ) ) RequireSessionId ( SessionType . UserSession ) ; RestRequest req = _client . Create ( " " ) ; req . AddUrlSegment ( " " , tvShowId . ToString ( CultureInfo . InvariantCulture ) ) ; req . AddUrlSegment ( " " , seasonNumber . ToString ( CultureInfo . InvariantCulture ) ) ; if ( extraMethods . HasFlag ( TvSeasonMethods . AccountStates ) ) AddSessionId ( req , SessionType . UserSession ) ; language ??= DefaultLanguage ; if ( ! string . IsNullOrWhiteSpace ( language ) ) req . AddParameter ( " " , language ) ; includeImageLanguage ??= DefaultImageLanguage ; if ( ! string . IsNullOrWhiteSpace ( includeImageLanguage ) ) req . AddParameter ( " " , includeImageLanguage ) ; string appends = string . Join ( " " , Enum . GetValues ( typeof ( TvSeasonMethods ) ) . OfType < TvSeasonMethods > ( ) . Except ( new [ ] { TvSeasonMethods . Undefined } ) . Where ( s => extraMethods . HasFlag ( s ) ) . Select ( s => s . GetDescription ( ) ) ) ; if ( appends != string . Empty ) req . AddParameter ( " " , appends ) ; RestResponse < TvSeason > response = await req . Get < TvSeason > ( cancellationToken ) . ConfigureAwait ( false ) ; if ( ! response . IsValid ) return null ; TvSeason item = await response . GetDataObject ( ) . ConfigureAwait ( false ) ; if ( item == null ) return null ; if ( item . Images != null ) item . Images . Id = item . Id ?? 0 ; if ( item . Credits != null ) item . Credits . Id = item . Id ?? 0 ; if ( item . ExternalIds != null ) item . ExternalIds . Id = item . Id ?? 0 ; if ( item . AccountStates != null ) item . AccountStates . Id = item . Id ?? 0 ; if ( item . Videos != null ) item . Videos . Id = item . Id ?? 0 ; return item ; }
Retrieve a season for a specifc tv Show by id.
Retrieve a season for a specifc tv Show by id .
// Nothing to patch up
The requested season for the specified tv show
The requested season for the specified tv show
tvShowId
int
TMDb id of the tv show the desired season belongs to.
TMDb id of the tv show the desired season belongs to .
seasonNumber
int
The season number of the season you want to retrieve. Note use 0 for specials.
The season number of the season you want to retrieve . Note use 0 for specials .
extraMethods
TvSeasonMethods
Enum flags indicating any additional data that should be fetched in the same request.
Enum flags indicating any additional data that should be fetched in the same request .
language
string
If specified the api will attempt to return a localized result. ex: en,it,es
If specified the api will attempt to return a localized result . ex : en it es
includeImageLanguage
string
If specified the api will attempt to return localized image results eg. en,it,es.
If specified the api will attempt to return localized image results eg . en it es .
cancellationToken
CancellationToken
A cancellation token
A cancellation token