TVDB: Fixing people images

This commit is contained in:
Zoe Roux 2021-08-05 23:35:10 +02:00
parent 6632ac5f1b
commit daa8d1f04a
10 changed files with 27 additions and 38 deletions

View File

@ -17,7 +17,7 @@ namespace Kyoo.TheMovieDb
/// <returns>The converted collection as a <see cref="Collection"/>.</returns> /// <returns>The converted collection as a <see cref="Collection"/>.</returns>
public static Collection ToCollection(this TMDbLib.Objects.Collections.Collection collection, Provider provider) public static Collection ToCollection(this TMDbLib.Objects.Collections.Collection collection, Provider provider)
{ {
return new() return new Collection
{ {
Slug = Utility.ToSlug(collection.Name), Slug = Utility.ToSlug(collection.Name),
Name = collection.Name, Name = collection.Name,
@ -51,7 +51,7 @@ namespace Kyoo.TheMovieDb
/// <returns>The converted collection as a <see cref="Collection"/>.</returns> /// <returns>The converted collection as a <see cref="Collection"/>.</returns>
public static Collection ToCollection(this SearchCollection collection, Provider provider) public static Collection ToCollection(this SearchCollection collection, Provider provider)
{ {
return new() return new Collection
{ {
Slug = Utility.ToSlug(collection.Name), Slug = Utility.ToSlug(collection.Name),
Name = collection.Name, Name = collection.Name,

View File

@ -18,7 +18,7 @@ namespace Kyoo.TheMovieDb
/// <returns>The converted episode as a <see cref="Episode"/>.</returns> /// <returns>The converted episode as a <see cref="Episode"/>.</returns>
public static Episode ToEpisode(this TvEpisode episode, int showID, Provider provider) public static Episode ToEpisode(this TvEpisode episode, int showID, Provider provider)
{ {
return new() return new Episode
{ {
SeasonNumber = episode.SeasonNumber, SeasonNumber = episode.SeasonNumber,
EpisodeNumber = episode.EpisodeNumber, EpisodeNumber = episode.EpisodeNumber,

View File

@ -19,7 +19,7 @@ namespace Kyoo.TheMovieDb
/// <returns>The converted movie as a <see cref="Show"/>.</returns> /// <returns>The converted movie as a <see cref="Show"/>.</returns>
public static Show ToShow(this Movie movie, Provider provider) public static Show ToShow(this Movie movie, Provider provider)
{ {
return new() return new Show
{ {
Slug = Utility.ToSlug(movie.Title), Slug = Utility.ToSlug(movie.Title),
Title = movie.Title, Title = movie.Title,
@ -69,7 +69,7 @@ namespace Kyoo.TheMovieDb
/// <returns>The converted movie as a <see cref="Show"/>.</returns> /// <returns>The converted movie as a <see cref="Show"/>.</returns>
public static Show ToShow(this SearchMovie movie, Provider provider) public static Show ToShow(this SearchMovie movie, Provider provider)
{ {
return new() return new Show
{ {
Slug = Utility.ToSlug(movie.Title), Slug = Utility.ToSlug(movie.Title),
Title = movie.Title, Title = movie.Title,

View File

@ -22,7 +22,7 @@ namespace Kyoo.TheMovieDb
/// <returns>A <see cref="PeopleRole"/> representing the movie cast.</returns> /// <returns>A <see cref="PeopleRole"/> representing the movie cast.</returns>
public static PeopleRole ToPeople(this MovieCast cast, Provider provider) public static PeopleRole ToPeople(this MovieCast cast, Provider provider)
{ {
return new() return new PeopleRole
{ {
People = new People People = new People
{ {
@ -57,7 +57,7 @@ namespace Kyoo.TheMovieDb
/// <returns>A <see cref="PeopleRole"/> representing the movie cast.</returns> /// <returns>A <see cref="PeopleRole"/> representing the movie cast.</returns>
public static PeopleRole ToPeople(this TvCast cast, Provider provider) public static PeopleRole ToPeople(this TvCast cast, Provider provider)
{ {
return new() return new PeopleRole
{ {
People = new People People = new People
{ {
@ -92,7 +92,7 @@ namespace Kyoo.TheMovieDb
/// <returns>A <see cref="PeopleRole"/> representing the movie crew.</returns> /// <returns>A <see cref="PeopleRole"/> representing the movie crew.</returns>
public static PeopleRole ToPeople(this Crew crew, Provider provider) public static PeopleRole ToPeople(this Crew crew, Provider provider)
{ {
return new() return new PeopleRole
{ {
People = new People People = new People
{ {
@ -127,7 +127,7 @@ namespace Kyoo.TheMovieDb
/// <returns>A <see cref="People"/> representing the person.</returns> /// <returns>A <see cref="People"/> representing the person.</returns>
public static People ToPeople(this Person person, Provider provider) public static People ToPeople(this Person person, Provider provider)
{ {
return new() return new People
{ {
Slug = Utility.ToSlug(person.Name), Slug = Utility.ToSlug(person.Name),
Name = person.Name, Name = person.Name,
@ -157,7 +157,7 @@ namespace Kyoo.TheMovieDb
/// <returns>A <see cref="People"/> representing the person.</returns> /// <returns>A <see cref="People"/> representing the person.</returns>
public static People ToPeople(this SearchPerson person, Provider provider) public static People ToPeople(this SearchPerson person, Provider provider)
{ {
return new() return new People
{ {
Slug = Utility.ToSlug(person.Name), Slug = Utility.ToSlug(person.Name),
Name = person.Name, Name = person.Name,

View File

@ -18,7 +18,7 @@ namespace Kyoo.TheMovieDb
/// <returns>The converted season as a <see cref="Season"/>.</returns> /// <returns>The converted season as a <see cref="Season"/>.</returns>
public static Season ToSeason(this TvSeason season, int showID, Provider provider) public static Season ToSeason(this TvSeason season, int showID, Provider provider)
{ {
return new() return new Season
{ {
SeasonNumber = season.SeasonNumber, SeasonNumber = season.SeasonNumber,
Title = season.Name, Title = season.Name,

View File

@ -19,7 +19,7 @@ namespace Kyoo.TheMovieDb
/// <returns>A converted <see cref="TvShow"/> as a <see cref="Show"/>.</returns> /// <returns>A converted <see cref="TvShow"/> as a <see cref="Show"/>.</returns>
public static Show ToShow(this TvShow tv, Provider provider) public static Show ToShow(this TvShow tv, Provider provider)
{ {
return new() return new Show
{ {
Slug = Utility.ToSlug(tv.Name), Slug = Utility.ToSlug(tv.Name),
Title = tv.Name, Title = tv.Name,
@ -68,7 +68,7 @@ namespace Kyoo.TheMovieDb
/// <returns>A converted <see cref="SearchTv"/> as a <see cref="Show"/>.</returns> /// <returns>A converted <see cref="SearchTv"/> as a <see cref="Show"/>.</returns>
public static Show ToShow(this SearchTv tv, Provider provider) public static Show ToShow(this SearchTv tv, Provider provider)
{ {
return new() return new Show
{ {
Slug = Utility.ToSlug(tv.Name), Slug = Utility.ToSlug(tv.Name),
Title = tv.Name, Title = tv.Name,

View File

@ -17,7 +17,7 @@ namespace Kyoo.TheMovieDb
/// <returns>The converted company as a <see cref="Studio"/>.</returns> /// <returns>The converted company as a <see cref="Studio"/>.</returns>
public static Studio ToStudio(this Company company, Provider provider) public static Studio ToStudio(this Company company, Provider provider)
{ {
return new() return new Studio
{ {
Slug = Utility.ToSlug(company.Name), Slug = Utility.ToSlug(company.Name),
Name = company.Name, Name = company.Name,
@ -41,7 +41,7 @@ namespace Kyoo.TheMovieDb
/// <returns>The converted company as a <see cref="Studio"/>.</returns> /// <returns>The converted company as a <see cref="Studio"/>.</returns>
public static Studio ToStudio(this SearchCompany company, Provider provider) public static Studio ToStudio(this SearchCompany company, Provider provider)
{ {
return new() return new Studio
{ {
Slug = Utility.ToSlug(company.Name), Slug = Utility.ToSlug(company.Name),
Name = company.Name, Name = company.Name,

View File

@ -48,7 +48,7 @@ namespace Kyoo.TheTvdb
/// <returns>A show representing the given search result.</returns> /// <returns>A show representing the given search result.</returns>
public static Show ToShow(this SeriesSearchResult result, Provider provider) public static Show ToShow(this SeriesSearchResult result, Provider provider)
{ {
return new() return new Show
{ {
Slug = result.Slug, Slug = result.Slug,
Title = result.SeriesName, Title = result.SeriesName,
@ -58,7 +58,7 @@ namespace Kyoo.TheTvdb
StartAir = _ParseDate(result.FirstAired), StartAir = _ParseDate(result.FirstAired),
Images = new Dictionary<int, string> Images = new Dictionary<int, string>
{ {
[Images.Poster] = result.Poster != null [Images.Poster] = string.IsNullOrEmpty(result.Poster)
? $"https://www.thetvdb.com{result.Poster}" ? $"https://www.thetvdb.com{result.Poster}"
: null, : null,
}, },
@ -82,7 +82,7 @@ namespace Kyoo.TheTvdb
/// <returns>A show representing the given series.</returns> /// <returns>A show representing the given series.</returns>
public static Show ToShow(this Series series, Provider provider) public static Show ToShow(this Series series, Provider provider)
{ {
return new() return new Show
{ {
Slug = series.Slug, Slug = series.Slug,
Title = series.SeriesName, Title = series.SeriesName,
@ -92,10 +92,10 @@ namespace Kyoo.TheTvdb
StartAir = _ParseDate(series.FirstAired), StartAir = _ParseDate(series.FirstAired),
Images = new Dictionary<int, string> Images = new Dictionary<int, string>
{ {
[Images.Poster] = series.Poster != null [Images.Poster] = string.IsNullOrEmpty(series.Poster)
? $"https://www.thetvdb.com/banners/{series.Poster}" ? $"https://www.thetvdb.com/banners/{series.Poster}"
: null, : null,
[Images.Thumbnail] = series.FanArt != null [Images.Thumbnail] = string.IsNullOrEmpty(series.FanArt)
? $"https://www.thetvdb.com/banners/{series.FanArt}" ? $"https://www.thetvdb.com/banners/{series.FanArt}"
: null : null
}, },
@ -116,11 +116,10 @@ namespace Kyoo.TheTvdb
/// Convert a tvdb actor to a kyoo <see cref="PeopleRole"/>. /// Convert a tvdb actor to a kyoo <see cref="PeopleRole"/>.
/// </summary> /// </summary>
/// <param name="actor">The actor to convert</param> /// <param name="actor">The actor to convert</param>
/// <param name="provider">The provider representing the tvdb inside kyoo</param>
/// <returns>A people role representing the given actor in the role they played.</returns> /// <returns>A people role representing the given actor in the role they played.</returns>
public static PeopleRole ToPeopleRole(this Actor actor, Provider provider) public static PeopleRole ToPeopleRole(this Actor actor)
{ {
return new() return new PeopleRole
{ {
People = new People People = new People
{ {
@ -128,18 +127,9 @@ namespace Kyoo.TheTvdb
Name = actor.Name, Name = actor.Name,
Images = new Dictionary<int, string> Images = new Dictionary<int, string>
{ {
[Images.Poster] = actor.Image != null [Images.Poster] = string.IsNullOrEmpty(actor.Image)
? $"https://www.thetvdb.com/banners/{actor.Image}" ? $"https://www.thetvdb.com/banners/{actor.Image}"
: null : null
},
ExternalIDs = new []
{
new MetadataID
{
DataID = actor.Id.ToString(),
Link = $"https://www.thetvdb.com/people/{actor.Id}",
Provider = provider
}
} }
}, },
Role = actor.Role, Role = actor.Role,
@ -155,7 +145,7 @@ namespace Kyoo.TheTvdb
/// <returns>A episode representing the given tvdb episode.</returns> /// <returns>A episode representing the given tvdb episode.</returns>
public static Episode ToEpisode(this EpisodeRecord episode, Provider provider) public static Episode ToEpisode(this EpisodeRecord episode, Provider provider)
{ {
return new() return new Episode
{ {
SeasonNumber = episode.AiredSeason, SeasonNumber = episode.AiredSeason,
EpisodeNumber = episode.AiredEpisodeNumber, EpisodeNumber = episode.AiredEpisodeNumber,
@ -164,7 +154,7 @@ namespace Kyoo.TheTvdb
Overview = episode.Overview, Overview = episode.Overview,
Images = new Dictionary<int, string> Images = new Dictionary<int, string>
{ {
[Images.Thumbnail] = episode.Filename != null [Images.Thumbnail] = string.IsNullOrEmpty(episode.Filename)
? $"https://www.thetvdb.com/banners/{episode.Filename}" ? $"https://www.thetvdb.com/banners/{episode.Filename}"
: null : null
}, },

View File

@ -95,7 +95,7 @@ namespace Kyoo.TheTvdb
Show ret = series.Data.ToShow(Provider); Show ret = series.Data.ToShow(Provider);
TvDbResponse<Actor[]> people = await _client.Series.GetActorsAsync(id); TvDbResponse<Actor[]> people = await _client.Series.GetActorsAsync(id);
ret.People = people.Data.Select(x => x.ToPeopleRole(Provider)).ToArray(); ret.People = people.Data.Select(x => x.ToPeopleRole()).ToArray();
return ret; return ret;
} }

View File

@ -124,8 +124,7 @@ namespace Kyoo.Tests.Identifier.Tvdb
Name = "Name", Name = "Name",
Role = "role" Role = "role"
}; };
Provider provider = TestSample.Get<Provider>(); PeopleRole people = actor.ToPeopleRole();
PeopleRole people = actor.ToPeopleRole(provider);
Assert.Equal("name", people.Slug); Assert.Equal("name", people.Slug);
Assert.Equal("Name", people.People.Name); Assert.Equal("Name", people.People.Name);