TMDbLib/Client/TMDbClientMovies.cs
/// <summary>
/// Retrieves a movie by its IMDb Id
/// </summary>
/// <param name="imdbId">The IMDb id of the movie OR the TMDb id as string</param>
/// <param name="language">Language to localize the results in.</param>
/// <param name="includeImageLanguage">If specified the api will attempt to return localized image results eg. en,it,es.</param>
/// <param name="extraMethods">A list of additional methods to execute for this req as enum flags</param>
/// <param name="cancellationToken">A cancellation token</param>
/// <returns>The reqed movie or null if it could not be found</returns>
/// <remarks>Requires a valid user session when specifying the extra method 'AccountStates' flag</remarks>
/// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned, see remarks.</exception>
Retrieves a movie by its IMDb Id
Retrieves a movie by its IMDb Id
public async Task<Movie> GetMovieAsync(string imdbId, string language, string includeImageLanguage = null, MovieMethods extraMethods = MovieMethods.Undefined, CancellationToken cancellationToken = default)
        {
            if (extraMethods.HasFlag(MovieMethods.AccountStates))
                RequireSessionId(SessionType.UserSession);
            RestRequest req = _client.Create("movie/{movieId}");
            req.AddUrlSegment("movieId", imdbId);
            if (extraMethods.HasFlag(MovieMethods.AccountStates))
                AddSessionId(req, SessionType.UserSession);
            if (language != null)
                req.AddParameter("language", language);
            includeImageLanguage ??= DefaultImageLanguage;
            if (includeImageLanguage != null)
                req.AddParameter("include_image_language", includeImageLanguage);
            string appends = string.Join(",",
                                         Enum.GetValues(typeof(MovieMethods))
                                             .OfType<MovieMethods>()
                                             .Except(new[] { MovieMethods.Undefined })
                                             .Where(s => extraMethods.HasFlag(s))
                                             .Select(s => s.GetDescription()));
            if (appends != string.Empty)
                req.AddParameter("append_to_response", appends);
            RestResponse<Movie> response = await req.Get<Movie>(cancellationToken).ConfigureAwait(false);
            if (!response.IsValid)
                return null;
            Movie item = await response.GetDataObject().ConfigureAwait(false);
            if (item.Videos != null)
                item.Videos.Id = item.Id;
            if (item.AlternativeTitles != null)
                item.AlternativeTitles.Id = item.Id;
            if (item.Credits != null)
                item.Credits.Id = item.Id;
            if (item.Releases != null)
                item.Releases.Id = item.Id;
            if (item.Keywords != null)
                item.Keywords.Id = item.Id;
            if (item.Translations != null)
                item.Translations.Id = item.Id;
            if (item.AccountStates != null)
                item.AccountStates.Id = item.Id;
            if (item.ExternalIds != null)
                item.ExternalIds.Id = item.Id;
            item.Overview = WebUtility.HtmlDecode(item.Overview);
            return item;
        }
public async Task < Movie > GetMovieAsync ( string imdbId , string language , string includeImageLanguage = null , MovieMethods extraMethods = MovieMethods . Undefined , CancellationToken cancellationToken = default ) { if ( extraMethods . HasFlag ( MovieMethods . AccountStates ) ) RequireSessionId ( SessionType . UserSession ) ; RestRequest req = _client . Create ( " " ) ; req . AddUrlSegment ( " " , imdbId ) ; if ( extraMethods . HasFlag ( MovieMethods . AccountStates ) ) AddSessionId ( req , SessionType . UserSession ) ; if ( language != null ) req . AddParameter ( " " , language ) ; includeImageLanguage ??= DefaultImageLanguage ; if ( includeImageLanguage != null ) req . AddParameter ( " " , includeImageLanguage ) ; string appends = string . Join ( " " , Enum . GetValues ( typeof ( MovieMethods ) ) . OfType < MovieMethods > ( ) . Except ( new [ ] { MovieMethods . Undefined } ) . Where ( s => extraMethods . HasFlag ( s ) ) . Select ( s => s . GetDescription ( ) ) ) ; if ( appends != string . Empty ) req . AddParameter ( " " , appends ) ; RestResponse < Movie > response = await req . Get < Movie > ( cancellationToken ) . ConfigureAwait ( false ) ; if ( ! response . IsValid ) return null ; Movie item = await response . GetDataObject ( ) . ConfigureAwait ( false ) ; if ( item . Videos != null ) item . Videos . Id = item . Id ; if ( item . AlternativeTitles != null ) item . AlternativeTitles . Id = item . Id ; if ( item . Credits != null ) item . Credits . Id = item . Id ; if ( item . Releases != null ) item . Releases . Id = item . Id ; if ( item . Keywords != null ) item . Keywords . Id = item . Id ; if ( item . Translations != null ) item . Translations . Id = item . Id ; if ( item . AccountStates != null ) item . AccountStates . Id = item . Id ; if ( item . ExternalIds != null ) item . ExternalIds . Id = item . Id ; item . Overview = WebUtility . HtmlDecode ( item . Overview ) ; return item ; }
Retrieves a movie by its IMDb Id
Retrieves a movie by its IMDb Id
// Patch up data, so that the end user won't notice that we share objects between req-types. // Overview is the only field that is HTML encoded from the source.
The reqed movie or null if it could not be found
The reqed movie or null if it could not be found
Thrown when the current client object doens't have a user session assigned, see remarks.
Thrown when the current client object doens ' t have a user session assigned see remarks .
imdbId
string
The IMDb id of the movie OR the TMDb id as string
The IMDb id of the movie OR the TMDb id as string
language
string
Language to localize the results in.
Language to localize the results in .
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 .
extraMethods
MovieMethods
A list of additional methods to execute for this req as enum flags
A list of additional methods to execute for this req as enum flags
cancellationToken
CancellationToken
A cancellation token
A cancellation token
remarks
Requires a valid user session when specifying the extra method 'AccountStates' flag
Requires a valid user session when specifying the extra method ' AccountStates ' flag