using System.Net; using System.Threading; using System.Threading.Tasks; using TMDbLib.Objects.Find; using TMDbLib.Rest; using TMDbLib.Utilities; namespace TMDbLib.Client { public partial class TMDbClient { /// /// 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 /// /// The source the specified id belongs to /// The id of the object you wish to located /// A list of all objects in TMDb that matched your id /// A cancellation token public Task FindAsync(FindExternalSource source, string id, CancellationToken cancellationToken = default) { return FindAsync(source, id, null, cancellationToken); } /// /// 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 /// /// The source the specified id belongs to /// The id of the object you wish to located /// A list of all objects in TMDb that matched your id /// If specified the api will attempt to return a localized result. ex: en,it,es. /// A cancellation token public async Task FindAsync(FindExternalSource source, string id, string language, CancellationToken cancellationToken = default) { RestRequest req = _client.Create("find/{id}"); req.AddUrlSegment("id", WebUtility.UrlEncode(id)); req.AddParameter("external_source", source.GetDescription()); language ??= DefaultLanguage; if (!string.IsNullOrEmpty(language)) req.AddParameter("language", language); FindContainer resp = await req.GetOfT(cancellationToken).ConfigureAwait(false); return resp; } } }