diff --git a/Kyoo.TheMovieDb/Convertors/PeopleConvertors.cs b/Kyoo.TheMovieDb/Convertors/PeopleConvertors.cs
index 8e1a326d..01a119fb 100644
--- a/Kyoo.TheMovieDb/Convertors/PeopleConvertors.cs
+++ b/Kyoo.TheMovieDb/Convertors/PeopleConvertors.cs
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using Kyoo.Models;
using TMDbLib.Objects.General;
+using TMDbLib.Objects.Search;
using TvCast = TMDbLib.Objects.TvShows.Cast;
using MovieCast = TMDbLib.Objects.Movies.Cast;
@@ -115,5 +116,35 @@ namespace Kyoo.TheMovieDb
Role = crew.Job
};
}
+
+ ///
+ /// Convert a to a .
+ ///
+ /// An internal TheMovieDB person.
+ /// The provider that represent TheMovieDB inside Kyoo.
+ /// A representing the person.
+ public static People ToPeople(this SearchPerson person, Provider provider)
+ {
+ return new()
+ {
+ Slug = Utility.ToSlug(person.Name),
+ Name = person.Name,
+ Images = new Dictionary
+ {
+ [Thumbnails.Poster] = person.ProfilePath != null
+ ? $"https://image.tmdb.org/t/p/original{person.ProfilePath}"
+ : null
+ },
+ ExternalIDs = new[]
+ {
+ new MetadataID
+ {
+ Provider = provider,
+ DataID = person.Id.ToString(),
+ Link = $"https://www.themoviedb.org/person/{person.Id}"
+ }
+ }
+ };
+ }
}
}
\ No newline at end of file
diff --git a/Kyoo.TheMovieDb/ProviderTmdb.cs b/Kyoo.TheMovieDb/ProviderTmdb.cs
index deab03ab..3be0793b 100644
--- a/Kyoo.TheMovieDb/ProviderTmdb.cs
+++ b/Kyoo.TheMovieDb/ProviderTmdb.cs
@@ -161,8 +161,8 @@ namespace Kyoo.TheMovieDb
return (await _SearchCollections(query) as ICollection)!;
if (typeof(T) == typeof(Show))
return (await _SearchShows(query) as ICollection)!;
- // if (typeof(T) == typeof(People))
- // return (await _SearchPeople(query) as ICollection)!;
+ if (typeof(T) == typeof(People))
+ return (await _SearchPeople(query) as ICollection)!;
// if (typeof(T) == typeof(Studio))
// return (await _SearchStudios(query) as ICollection)!;
return ArraySegment.Empty;
@@ -204,5 +204,19 @@ namespace Kyoo.TheMovieDb
.Where(x => x != null)
.ToArray();
}
+
+ ///
+ /// Search for people using there name as a query.
+ ///
+ /// The query to search for
+ /// A list of people containing metadata from TheMovieDb
+ private async Task> _SearchPeople(string query)
+ {
+ TMDbClient client = new(_apiKey.Value.ApiKey);
+ return (await client.SearchPersonAsync(query))
+ .Results
+ .Select(x => x.ToPeople(Provider))
+ .ToArray();
+ }
}
}
\ No newline at end of file