mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-05-16 05:36:52 +01:00
Make Cache duration user configurable
This commit is contained in:
@@ -53,6 +53,11 @@ public class PluginConfiguration : BasePluginConfiguration
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the cache duration in days for similar item results. A value of 0 disables caching.
|
||||
/// </summary>
|
||||
public int SimilarItemsCacheDays { get; set; } = 14;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the algorithm string for the API call.
|
||||
/// </summary>
|
||||
|
||||
@@ -30,6 +30,10 @@
|
||||
<input is="emby-input" type="number" id="rateLimit" required pattern="[0-9]*" min="0" max="10" step=".01" label="Rate Limit (seconds)" />
|
||||
<div class="fieldDescription">Span of time between requests in seconds. The official server is rate limited to one request per second.</div>
|
||||
</div>
|
||||
<div class="inputContainer">
|
||||
<input is="emby-input" type="number" id="similarItemsCacheDays" required pattern="[0-9]*" min="0" max="365" label="Cache duration (days)" />
|
||||
<div class="fieldDescription">Number of days to cache similar artist results from ListenBrainz. Set to 0 to disable caching.</div>
|
||||
</div>
|
||||
<br />
|
||||
<div>
|
||||
<button is="emby-button" type="submit" class="raised button-submit block"><span>Save</span></button>
|
||||
@@ -62,6 +66,13 @@
|
||||
cancelable: false
|
||||
}));
|
||||
|
||||
var similarItemsCacheDays = document.querySelector('#similarItemsCacheDays');
|
||||
similarItemsCacheDays.value = config.SimilarItemsCacheDays;
|
||||
similarItemsCacheDays.dispatchEvent(new Event('change', {
|
||||
bubbles: true,
|
||||
cancelable: false
|
||||
}));
|
||||
|
||||
Dashboard.hideLoadingMsg();
|
||||
});
|
||||
});
|
||||
@@ -74,6 +85,7 @@
|
||||
config.LabsServer = document.querySelector('#labsServer').value;
|
||||
config.Algorithm = parseInt(document.querySelector('#algorithm').value, 10);
|
||||
config.RateLimit = document.querySelector('#rateLimit').value;
|
||||
config.SimilarItemsCacheDays = parseInt(document.querySelector('#similarItemsCacheDays').value, 10);
|
||||
|
||||
ApiClient.updatePluginConfiguration(ListenBrainzPluginConfig.uniquePluginId, config).then(Dashboard.processPluginConfigurationUpdateResult);
|
||||
});
|
||||
|
||||
@@ -40,7 +40,14 @@ public class ListenBrainzSimilarArtistProvider : IRemoteSimilarItemsProvider<Mus
|
||||
public MetadataPluginType Type => MetadataPluginType.SimilarityProvider;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public TimeSpan? CacheDuration => TimeSpan.FromDays(14);
|
||||
public TimeSpan? CacheDuration
|
||||
{
|
||||
get
|
||||
{
|
||||
var days = ListenBrainzPlugin.Instance?.Configuration.SimilarItemsCacheDays ?? 0;
|
||||
return days > 0 ? TimeSpan.FromDays(days) : null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async IAsyncEnumerable<SimilarItemReference> GetSimilarItemsAsync(
|
||||
|
||||
@@ -77,5 +77,10 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
||||
/// Gets or sets a value indicating the still image size to fetch.
|
||||
/// </summary>
|
||||
public string? StillSize { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the cache duration in days for similar item results. A value of 0 disables caching.
|
||||
/// </summary>
|
||||
public int SimilarItemsCacheDays { get; set; } = 7;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,13 @@
|
||||
<span>Hide crew members without profile images.</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="verticalSection">
|
||||
<h2>Similar Items</h2>
|
||||
<div class="inputContainer">
|
||||
<input is="emby-input" type="number" id="similarItemsCacheDays" pattern="[0-9]*" required min="0" max="365" label="Cache duration (days)" />
|
||||
<div class="fieldDescription">Number of days to cache similar item results from TMDb. Set to 0 to disable caching.</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="verticalSection verticalSection-extrabottompadding">
|
||||
<h2>Image Scaling</h2>
|
||||
<div class="selectContainer">
|
||||
@@ -161,6 +168,13 @@
|
||||
cancelable: false
|
||||
}));
|
||||
|
||||
var similarItemsCacheDays = document.querySelector('#similarItemsCacheDays');
|
||||
similarItemsCacheDays.value = config.SimilarItemsCacheDays;
|
||||
similarItemsCacheDays.dispatchEvent(new Event('change', {
|
||||
bubbles: true,
|
||||
cancelable: false
|
||||
}));
|
||||
|
||||
pluginConfig = config;
|
||||
configureImageScaling();
|
||||
});
|
||||
@@ -179,6 +193,7 @@
|
||||
config.MaxCrewMembers = document.querySelector('#maxCrewMembers').value;
|
||||
config.HideMissingCastMembers = document.querySelector('#hideMissingCastMembers').checked;
|
||||
config.HideMissingCrewMembers = document.querySelector('#hideMissingCrewMembers').checked;
|
||||
config.SimilarItemsCacheDays = parseInt(document.querySelector('#similarItemsCacheDays').value, 10);
|
||||
config.PosterSize = document.querySelector('#selectPosterSize').value;
|
||||
config.BackdropSize = document.querySelector('#selectBackdropSize').value;
|
||||
config.LogoSize = document.querySelector('#selectLogoSize').value;
|
||||
|
||||
@@ -37,7 +37,14 @@ public class TmdbMovieSimilarProvider : IRemoteSimilarItemsProvider<Movie>
|
||||
public MetadataPluginType Type => MetadataPluginType.SimilarityProvider;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public TimeSpan? CacheDuration => TimeSpan.FromDays(7);
|
||||
public TimeSpan? CacheDuration
|
||||
{
|
||||
get
|
||||
{
|
||||
var days = Plugin.Instance?.Configuration.SimilarItemsCacheDays ?? 0;
|
||||
return days > 0 ? TimeSpan.FromDays(days) : null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async IAsyncEnumerable<SimilarItemReference> GetSimilarItemsAsync(
|
||||
|
||||
@@ -37,7 +37,14 @@ public class TmdbSeriesSimilarProvider : IRemoteSimilarItemsProvider<Series>
|
||||
public MetadataPluginType Type => MetadataPluginType.SimilarityProvider;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public TimeSpan? CacheDuration => TimeSpan.FromDays(7);
|
||||
public TimeSpan? CacheDuration
|
||||
{
|
||||
get
|
||||
{
|
||||
var days = Plugin.Instance?.Configuration.SimilarItemsCacheDays ?? 0;
|
||||
return days > 0 ? TimeSpan.FromDays(days) : null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async IAsyncEnumerable<SimilarItemReference> GetSimilarItemsAsync(
|
||||
|
||||
Reference in New Issue
Block a user