Merge pull request #6781 from 1337joe/tmdb-settings

Add MaxCastMembers to TMDb Plugin Settings
This commit is contained in:
Cody Robibero 2021-11-05 05:56:51 -06:00 committed by GitHub
commit 0cd817bba3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 31 additions and 11 deletions

View File

@ -21,5 +21,10 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
/// Gets or sets a value indicating whether tags should be imported for movies from TMDb.
/// </summary>
public bool ExcludeTagsMovies { get; set; }
/// <summary>
/// Gets or sets a value indicating the maximum number of cast members to fetch for an item.
/// </summary>
public int MaxCastMembers { get; set; } = 15;
}
}

View File

@ -12,6 +12,18 @@
<input is="emby-checkbox" type="checkbox" id="includeAdult" />
<span>Include adult content in search results.</span>
</label>
<label class="checkboxContainer">
<input is="emby-checkbox" type="checkbox" id="excludeTagsSeries" />
<span>Exclude tags/keywords from metadata fetched for series.</span>
</label>
<label class="checkboxContainer">
<input is="emby-checkbox" type="checkbox" id="excludeTagsMovies" />
<span>Exclude tags/keywords from metadata fetched for movies.</span>
</label>
<div class="inputContainer">
<input is="emby-input" type="number" id="maxCastMembers" pattern="[0-9]*" required min="0" max="1000" label="Max Cast Members" />
<div class="fieldDescription">The maximum number of cast members to fetch for an item.</div>
</div>
<br />
<div>
<button is="emby-button" type="submit" class="raised button-submit block"><span>Save</span></button>
@ -31,6 +43,14 @@
document.querySelector('#includeAdult').checked = config.IncludeAdult;
document.querySelector('#excludeTagsSeries').checked = config.ExcludeTagsSeries;
document.querySelector('#excludeTagsMovies').checked = config.ExcludeTagsMovies;
var maxCastMembers = document.querySelector('#maxCastMembers');
maxCastMembers.value = config.MaxCastMembers;
maxCastMembers.dispatchEvent(new Event('change', {
bubbles: true,
cancelable: false
}));
Dashboard.hideLoadingMsg();
});
});
@ -44,6 +64,7 @@
config.IncludeAdult = document.querySelector('#includeAdult').checked;
config.ExcludeTagsSeries = document.querySelector('#excludeTagsSeries').checked;
config.ExcludeTagsMovies = document.querySelector('#excludeTagsMovies').checked;
config.MaxCastMembers = document.querySelector('#maxCastMembers').value;
ApiClient.updatePluginConfiguration(PluginConfig.pluginId, config).then(Dashboard.processPluginConfigurationUpdateResult);
});

View File

@ -241,8 +241,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
if (movieResult.Credits?.Cast != null)
{
// TODO configurable
foreach (var actor in movieResult.Credits.Cast.OrderBy(a => a.Order).Take(TmdbUtils.MaxCastMembers))
foreach (var actor in movieResult.Credits.Cast.OrderBy(a => a.Order).Take(Plugin.Instance.Configuration.MaxCastMembers))
{
var personInfo = new PersonInfo
{

View File

@ -154,7 +154,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
if (credits?.Cast != null)
{
foreach (var actor in credits.Cast.OrderBy(a => a.Order).Take(TmdbUtils.MaxCastMembers))
foreach (var actor in credits.Cast.OrderBy(a => a.Order).Take(Plugin.Instance.Configuration.MaxCastMembers))
{
metadataResult.AddPerson(new PersonInfo
{
@ -168,7 +168,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
if (credits?.GuestStars != null)
{
foreach (var guest in credits.GuestStars.OrderBy(a => a.Order).Take(TmdbUtils.MaxCastMembers))
foreach (var guest in credits.GuestStars.OrderBy(a => a.Order).Take(Plugin.Instance.Configuration.MaxCastMembers))
{
metadataResult.AddPerson(new PersonInfo
{

View File

@ -67,7 +67,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
var credits = seasonResult.Credits;
if (credits?.Cast != null)
{
var cast = credits.Cast.OrderBy(c => c.Order).Take(TmdbUtils.MaxCastMembers).ToList();
var cast = credits.Cast.OrderBy(c => c.Order).Take(Plugin.Instance.Configuration.MaxCastMembers).ToList();
for (var i = 0; i < cast.Count; i++)
{
result.AddPerson(new PersonInfo

View File

@ -331,7 +331,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
{
if (seriesResult.Credits?.Cast != null)
{
foreach (var actor in seriesResult.Credits.Cast.OrderBy(a => a.Order).Take(TmdbUtils.MaxCastMembers))
foreach (var actor in seriesResult.Credits.Cast.OrderBy(a => a.Order).Take(Plugin.Instance.Configuration.MaxCastMembers))
{
var personInfo = new PersonInfo
{

View File

@ -28,11 +28,6 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
/// </summary>
public const string ApiKey = "4219e299c89411838049ab0dab19ebd5";
/// <summary>
/// Maximum number of cast members to pull.
/// </summary>
public const int MaxCastMembers = 15;
/// <summary>
/// The crew types to keep.
/// </summary>