TMDbLib/Client/TMDbClientTvEpisodes.cs
/// <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>
Retrieve a specific episode using TMDb id of the associated tv show.
Retrieve a specific episode using TMDb id of the associated tv show .
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);
            if (item == null)
                return null;
            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;
        }
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 ( " " ) ; req . AddUrlSegment ( " " , tvShowId . ToString ( CultureInfo . InvariantCulture ) ) ; req . AddUrlSegment ( " " , seasonNumber . ToString ( CultureInfo . InvariantCulture ) ) ; req . AddUrlSegment ( " " , episodeNumber . ToString ( CultureInfo . InvariantCulture ) ) ; if ( extraMethods . HasFlag ( TvEpisodeMethods . 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 ( TvEpisodeMethods ) ) . OfType < TvEpisodeMethods > ( ) . Except ( new [ ] { TvEpisodeMethods . Undefined } ) . Where ( s => extraMethods . HasFlag ( s ) ) . Select ( s => s . GetDescription ( ) ) ) ; if ( appends != string . Empty ) req . AddParameter ( " " , appends ) ; RestResponse < TvEpisode > response = await req . Get < TvEpisode > ( cancellationToken ) . ConfigureAwait ( false ) ; if ( ! response . IsValid ) return null ; TvEpisode item = await response . GetDataObject ( ) . ConfigureAwait ( false ) ; if ( item == null ) return null ; 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 ; }
Retrieve a specific episode using TMDb id of the associated tv show.
Retrieve a specific episode using TMDb id of the associated tv show .
// 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.
tvShowId
int
TMDb id of the tv show the desired episode belongs to.
TMDb id of the tv show the desired episode belongs to .
seasonNumber
int
The season number of the season the episode belongs to. Note use 0 for specials.
The season number of the season the episode belongs to . Note use 0 for specials .
episodeNumber
int
The episode number of the episode you want to retrieve.
The episode number of the episode you want to retrieve .
extraMethods
TvEpisodeMethods
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