Add language option to Find

This commit is contained in:
cvium 2020-09-24 09:47:31 +02:00
parent fbcc812f98
commit 30af76cadb

View File

@ -11,7 +11,7 @@ namespace TMDbLib.Client
{
/// <summary>
/// FindAsync movies, people and tv shows by an external id.
/// The following trypes can be found based on the specified external id's
/// The following types can be found based on the specified external id's
/// - Movies: Imdb
/// - People: Imdb, FreeBaseMid, FreeBaseId, TvRage
/// - TV Series: Imdb, FreeBaseMid, FreeBaseId, TvRage, TvDb
@ -20,7 +20,24 @@ namespace TMDbLib.Client
/// <param name="id">The id of the object you wish to located</param>
/// <returns>A list of all objects in TMDb that matched your id</returns>
/// <param name="cancellationToken">A cancellation token</param>
public async Task<FindContainer> FindAsync(FindExternalSource source, string id, CancellationToken cancellationToken = default(CancellationToken))
public Task<FindContainer> FindAsync(FindExternalSource source, string id, CancellationToken cancellationToken = default(CancellationToken))
{
return FindAsync(source, id, null, cancellationToken);
}
/// <summary>
/// FindAsync movies, people and tv shows by an external id.
/// The following types can be found based on the specified external id's
/// - Movies: Imdb
/// - People: Imdb, FreeBaseMid, FreeBaseId, TvRage
/// - TV Series: Imdb, FreeBaseMid, FreeBaseId, TvRage, TvDb
/// </summary>
/// <param name="source">The source the specified id belongs to</param>
/// <param name="id">The id of the object you wish to located</param>
/// <returns>A list of all objects in TMDb that matched your id</returns>
/// <param name="language">If specified the api will attempt to return a localized result. ex: en,it,es.</param>
/// <param name="cancellationToken">A cancellation token</param>
public async Task<FindContainer> FindAsync(FindExternalSource source, string id, string language, CancellationToken cancellationToken = default(CancellationToken))
{
RestRequest req = _client.Create("find/{id}");
@ -28,6 +45,10 @@ namespace TMDbLib.Client
req.AddParameter("external_source", source.GetDescription());
language = language ?? DefaultLanguage;
if (!string.IsNullOrEmpty(language))
req.AddParameter("language", language);
RestResponse<FindContainer> resp = await req.ExecuteGet<FindContainer>(cancellationToken).ConfigureAwait(false);
return resp;