TMDbLib/Client/TMDbClientTvShows.cs
/// <summary>
/// Retrieve a tv Show by id.
/// </summary>
/// <param name="id">TMDb id of the tv show 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>
/// <returns>The requested Tv Show</returns>
Retrieve a tv Show by id.
Retrieve a tv Show by id .
public async Task<TvShow> GetTvShowAsync(int id, TvShowMethods extraMethods = TvShowMethods.Undefined, string language = null, string includeImageLanguage = null, CancellationToken cancellationToken = default)
        {
            if (extraMethods.HasFlag(TvShowMethods.AccountStates))
                RequireSessionId(SessionType.UserSession);
            RestRequest req = _client.Create("tv/{id}");
            req.AddUrlSegment("id", id.ToString(CultureInfo.InvariantCulture));
            if (extraMethods.HasFlag(TvShowMethods.AccountStates))
                AddSessionId(req, SessionType.UserSession);
            language ??= DefaultLanguage;
            if (!string.IsNullOrWhiteSpace(language))
                req.AddParameter("language", language);
            if (!string.IsNullOrWhiteSpace(includeImageLanguage))
                req.AddParameter("include_image_language", includeImageLanguage);
            string appends = string.Join(",",
                                         Enum.GetValues(typeof(TvShowMethods))
                                             .OfType<TvShowMethods>()
                                             .Except(new[] { TvShowMethods.Undefined })
                                             .Where(s => extraMethods.HasFlag(s))
                                             .Select(s => s.GetDescription()));
            if (appends != string.Empty)
                req.AddParameter("append_to_response", appends);
            RestResponse<TvShow> response = await req.Get<TvShow>(cancellationToken).ConfigureAwait(false);
            if (!response.IsValid)
                return null;
            TvShow item = await response.GetDataObject().ConfigureAwait(false);
            if (item == null)
                return null;
            if (item.Translations != null)
                item.Translations.Id = id;
            if (item.AccountStates != null)
                item.AccountStates.Id = id;
            if (item.Recommendations != null)
                item.Recommendations.Id = id;
            if (item.ExternalIds != null)
                item.ExternalIds.Id = id;
            return item;
        }
public async Task < TvShow > GetTvShowAsync ( int id , TvShowMethods extraMethods = TvShowMethods . Undefined , string language = null , string includeImageLanguage = null , CancellationToken cancellationToken = default ) { if ( extraMethods . HasFlag ( TvShowMethods . AccountStates ) ) RequireSessionId ( SessionType . UserSession ) ; RestRequest req = _client . Create ( " " ) ; req . AddUrlSegment ( " " , id . ToString ( CultureInfo . InvariantCulture ) ) ; if ( extraMethods . HasFlag ( TvShowMethods . AccountStates ) ) AddSessionId ( req , SessionType . UserSession ) ; language ??= DefaultLanguage ; if ( ! string . IsNullOrWhiteSpace ( language ) ) req . AddParameter ( " " , language ) ; if ( ! string . IsNullOrWhiteSpace ( includeImageLanguage ) ) req . AddParameter ( " " , includeImageLanguage ) ; string appends = string . Join ( " " , Enum . GetValues ( typeof ( TvShowMethods ) ) . OfType < TvShowMethods > ( ) . Except ( new [ ] { TvShowMethods . Undefined } ) . Where ( s => extraMethods . HasFlag ( s ) ) . Select ( s => s . GetDescription ( ) ) ) ; if ( appends != string . Empty ) req . AddParameter ( " " , appends ) ; RestResponse < TvShow > response = await req . Get < TvShow > ( cancellationToken ) . ConfigureAwait ( false ) ; if ( ! response . IsValid ) return null ; TvShow item = await response . GetDataObject ( ) . ConfigureAwait ( false ) ; if ( item == null ) return null ; if ( item . Translations != null ) item . Translations . Id = id ; if ( item . AccountStates != null ) item . AccountStates . Id = id ; if ( item . Recommendations != null ) item . Recommendations . Id = id ; if ( item . ExternalIds != null ) item . ExternalIds . Id = id ; return item ; }
Retrieve a tv Show by id.
Retrieve a tv Show by id .
// No data to patch up so return // Patch up data, so that the end user won't notice that we share objects between request-types.
The requested Tv Show
The requested Tv Show
id
int
TMDb id of the tv show to retrieve.
TMDb id of the tv show to retrieve .
extraMethods
TvShowMethods
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