mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-05-27 10:58:44 +01:00
Convert Person.Type to use PersonKind enum (#9487)
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Data.Enums;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Library;
|
||||
@@ -163,7 +164,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||
PeopleHelper.AddPerson(people, new PersonInfo
|
||||
{
|
||||
Name = albumArtist,
|
||||
Type = "AlbumArtist"
|
||||
Type = PersonKind.AlbumArtist
|
||||
});
|
||||
}
|
||||
|
||||
@@ -173,7 +174,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||
PeopleHelper.AddPerson(people, new PersonInfo
|
||||
{
|
||||
Name = performer,
|
||||
Type = "Artist"
|
||||
Type = PersonKind.Artist
|
||||
});
|
||||
}
|
||||
|
||||
@@ -182,7 +183,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||
PeopleHelper.AddPerson(people, new PersonInfo
|
||||
{
|
||||
Name = composer,
|
||||
Type = "Composer"
|
||||
Type = PersonKind.Composer
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Jellyfin.Data.Enums;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
@@ -187,7 +188,7 @@ namespace MediaBrowser.Providers.Music
|
||||
PeopleHelper.AddPerson(people, new PersonInfo
|
||||
{
|
||||
Name = albumArtist,
|
||||
Type = "AlbumArtist"
|
||||
Type = PersonKind.AlbumArtist
|
||||
});
|
||||
}
|
||||
|
||||
@@ -196,7 +197,7 @@ namespace MediaBrowser.Providers.Music
|
||||
PeopleHelper.AddPerson(people, new PersonInfo
|
||||
{
|
||||
Name = artist,
|
||||
Type = "Artist"
|
||||
Type = PersonKind.Artist
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ using System.Net.Http.Json;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Data.Enums;
|
||||
using Jellyfin.Extensions.Json;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
@@ -424,7 +425,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
|
||||
var person = new PersonInfo
|
||||
{
|
||||
Name = result.Director,
|
||||
Type = PersonType.Director
|
||||
Type = PersonKind.Director
|
||||
};
|
||||
|
||||
itemResult.AddPerson(person);
|
||||
@@ -435,7 +436,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
|
||||
var person = new PersonInfo
|
||||
{
|
||||
Name = result.Writer,
|
||||
Type = PersonType.Writer
|
||||
Type = PersonKind.Writer
|
||||
};
|
||||
|
||||
itemResult.AddPerson(person);
|
||||
@@ -454,7 +455,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
|
||||
var person = new PersonInfo
|
||||
{
|
||||
Name = actor,
|
||||
Type = PersonType.Actor
|
||||
Type = PersonKind.Actor
|
||||
};
|
||||
|
||||
itemResult.AddPerson(person);
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Data.Enums;
|
||||
using Jellyfin.Extensions;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
@@ -258,7 +259,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
|
||||
{
|
||||
Name = actor.Name.Trim(),
|
||||
Role = actor.Character,
|
||||
Type = PersonType.Actor,
|
||||
Type = PersonKind.Actor,
|
||||
SortOrder = actor.Order
|
||||
};
|
||||
|
||||
@@ -278,20 +279,13 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
|
||||
|
||||
if (movieResult.Credits?.Crew is not null)
|
||||
{
|
||||
var keepTypes = new[]
|
||||
{
|
||||
PersonType.Director,
|
||||
PersonType.Writer,
|
||||
PersonType.Producer
|
||||
};
|
||||
|
||||
foreach (var person in movieResult.Credits.Crew)
|
||||
{
|
||||
// Normalize this
|
||||
var type = TmdbUtils.MapCrewToPersonType(person);
|
||||
|
||||
if (!keepTypes.Contains(type, StringComparison.OrdinalIgnoreCase) &&
|
||||
!keepTypes.Contains(person.Job ?? string.Empty, StringComparison.OrdinalIgnoreCase))
|
||||
if (!TmdbUtils.WantedCrewKinds.Contains(type)
|
||||
&& !TmdbUtils.WantedCrewTypes.Contains(person.Job ?? string.Empty, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Data.Enums;
|
||||
using Jellyfin.Extensions;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
@@ -168,7 +169,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
||||
{
|
||||
Name = actor.Name.Trim(),
|
||||
Role = actor.Character,
|
||||
Type = PersonType.Actor,
|
||||
Type = PersonKind.Actor,
|
||||
SortOrder = actor.Order
|
||||
});
|
||||
}
|
||||
@@ -182,7 +183,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
||||
{
|
||||
Name = guest.Name.Trim(),
|
||||
Role = guest.Character,
|
||||
Type = PersonType.GuestStar,
|
||||
Type = PersonKind.GuestStar,
|
||||
SortOrder = guest.Order
|
||||
});
|
||||
}
|
||||
@@ -196,7 +197,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
||||
// Normalize this
|
||||
var type = TmdbUtils.MapCrewToPersonType(person);
|
||||
|
||||
if (!TmdbUtils.WantedCrewTypes.Contains(type, StringComparison.OrdinalIgnoreCase)
|
||||
if (!TmdbUtils.WantedCrewKinds.Contains(type)
|
||||
&& !TmdbUtils.WantedCrewTypes.Contains(person.Job ?? string.Empty, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
continue;
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Data.Enums;
|
||||
using Jellyfin.Extensions;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
@@ -88,7 +89,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
||||
{
|
||||
Name = cast[i].Name.Trim(),
|
||||
Role = cast[i].Character,
|
||||
Type = PersonType.Actor,
|
||||
Type = PersonKind.Actor,
|
||||
SortOrder = cast[i].Order
|
||||
});
|
||||
}
|
||||
@@ -101,7 +102,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
||||
// Normalize this
|
||||
var type = TmdbUtils.MapCrewToPersonType(person);
|
||||
|
||||
if (!TmdbUtils.WantedCrewTypes.Contains(type, StringComparison.OrdinalIgnoreCase)
|
||||
if (!TmdbUtils.WantedCrewKinds.Contains(type)
|
||||
&& !TmdbUtils.WantedCrewTypes.Contains(person.Job ?? string.Empty, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
continue;
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Data.Enums;
|
||||
using Jellyfin.Extensions;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
@@ -352,7 +353,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
||||
{
|
||||
Name = actor.Name.Trim(),
|
||||
Role = actor.Character,
|
||||
Type = PersonType.Actor,
|
||||
Type = PersonKind.Actor,
|
||||
SortOrder = actor.Order,
|
||||
ImageUrl = _tmdbClientManager.GetPosterUrl(actor.ProfilePath)
|
||||
};
|
||||
@@ -380,8 +381,8 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
||||
// Normalize this
|
||||
var type = TmdbUtils.MapCrewToPersonType(person);
|
||||
|
||||
if (!keepTypes.Contains(type, StringComparison.OrdinalIgnoreCase)
|
||||
&& !keepTypes.Contains(person.Job ?? string.Empty, StringComparison.OrdinalIgnoreCase))
|
||||
if (!TmdbUtils.WantedCrewKinds.Contains(type)
|
||||
&& !TmdbUtils.WantedCrewTypes.Contains(person.Job ?? string.Empty, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.RegularExpressions;
|
||||
using Jellyfin.Data.Enums;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using TMDbLib.Objects.General;
|
||||
|
||||
@@ -39,6 +40,16 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
||||
PersonType.Producer
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// The crew kinds to keep.
|
||||
/// </summary>
|
||||
public static readonly PersonKind[] WantedCrewKinds =
|
||||
{
|
||||
PersonKind.Director,
|
||||
PersonKind.Writer,
|
||||
PersonKind.Producer
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Cleans the name according to TMDb requirements.
|
||||
/// </summary>
|
||||
@@ -55,26 +66,26 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
||||
/// </summary>
|
||||
/// <param name="crew">Crew member to map against the Jellyfin person types.</param>
|
||||
/// <returns>The Jellyfin person type.</returns>
|
||||
public static string MapCrewToPersonType(Crew crew)
|
||||
public static PersonKind MapCrewToPersonType(Crew crew)
|
||||
{
|
||||
if (crew.Department.Equals("production", StringComparison.OrdinalIgnoreCase)
|
||||
&& crew.Job.Contains("director", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return PersonType.Director;
|
||||
return PersonKind.Director;
|
||||
}
|
||||
|
||||
if (crew.Department.Equals("production", StringComparison.OrdinalIgnoreCase)
|
||||
&& crew.Job.Contains("producer", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return PersonType.Producer;
|
||||
return PersonKind.Producer;
|
||||
}
|
||||
|
||||
if (crew.Department.Equals("writing", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return PersonType.Writer;
|
||||
return PersonKind.Writer;
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
return PersonKind.Unknown;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user