Add Exclude Seasonal Content option to configuration and update related logic

This commit is contained in:
CodeDevMLH
2026-03-08 19:32:15 +01:00
parent 25ee5b73b4
commit 07658f4fbc
3 changed files with 47 additions and 3 deletions

View File

@@ -40,6 +40,7 @@ namespace Jellyfin.Plugin.MediaBarEnhanced.Configuration
public bool EnableCustomMediaIds { get; set; } = true; public bool EnableCustomMediaIds { get; set; } = true;
public string PreferredVideoQuality { get; set; } = "Auto"; public string PreferredVideoQuality { get; set; } = "Auto";
public bool EnableSeasonalContent { get; set; } = false; public bool EnableSeasonalContent { get; set; } = false;
public bool ExcludeSeasonalContent { get; set; } = true;
public string SeasonalSections { get; set; } = "[]"; public string SeasonalSections { get; set; } = "[]";
public bool IsEnabled { get; set; } = true; public bool IsEnabled { get; set; } = true;
public bool EnableClientSideSettings { get; set; } = false; public bool EnableClientSideSettings { get; set; } = false;

View File

@@ -183,6 +183,14 @@
during their active date ranges. If no season matches the current date, the default during their active date ranges. If no season matches the current date, the default
Custom Media IDs above or random selection are used as fallback.</div> Custom Media IDs above or random selection are used as fallback.</div>
</div> </div>
<div class="checkboxContainer checkboxContainer-withDescription">
<label>
<input is="emby-checkbox" type="checkbox" id="ExcludeSeasonalContent"
name="ExcludeSeasonalContent" />
<span>Exclude Seasonal Content from Random Lists</span>
</label>
<div class="fieldDescription">When enabled, any items defined in your Seasonal Sections below will be explicitly excluded from being shown when the plugin pulls random items from your library.</div>
</div>
<div id="seasonalContentContainer" style="display: none;"> <div id="seasonalContentContainer" style="display: none;">
<div <div
@@ -516,7 +524,7 @@
'PreferLocalTrailers', 'ApplyLimitsToCustomIds', 'SeasonalSections', 'PreferLocalTrailers', 'ApplyLimitsToCustomIds', 'SeasonalSections',
'PreferLocalBackdrops', 'RandomizeThemeVideos', 'RandomizeLocalTrailers', 'PreferLocalBackdrops', 'RandomizeThemeVideos', 'RandomizeLocalTrailers',
'IncludeWatchedContent', 'ShowPaginationDots', 'MaxParentalRating', 'IncludeWatchedContent', 'ShowPaginationDots', 'MaxParentalRating',
'MaxDaysRecent' 'MaxDaysRecent', 'ExcludeSeasonalContent'
]; ];
// Manual mapping for MediaBarIsEnabled -> IsEnabled, to avoid conflicts with other plugins // Manual mapping for MediaBarIsEnabled -> IsEnabled, to avoid conflicts with other plugins
@@ -621,7 +629,7 @@
'PreferLocalTrailers', 'ApplyLimitsToCustomIds', 'SeasonalSections', 'PreferLocalTrailers', 'ApplyLimitsToCustomIds', 'SeasonalSections',
'PreferLocalBackdrops', 'RandomizeThemeVideos', 'RandomizeLocalTrailers', 'PreferLocalBackdrops', 'RandomizeThemeVideos', 'RandomizeLocalTrailers',
'IncludeWatchedContent', 'ShowPaginationDots', 'MaxParentalRating', 'IncludeWatchedContent', 'ShowPaginationDots', 'MaxParentalRating',
'MaxDaysRecent' 'MaxDaysRecent', 'ExcludeSeasonalContent'
]; ];
keys.forEach(function (key) { keys.forEach(function (key) {

View File

@@ -66,6 +66,7 @@ const CONFIG = {
sortOrder: "Ascending", sortOrder: "Ascending",
applyLimitsToCustomIds: false, applyLimitsToCustomIds: false,
seasonalSections: "[]", seasonalSections: "[]",
excludeSeasonalContent: true,
isEnabled: true, isEnabled: true,
}; };
@@ -1126,8 +1127,42 @@ const ApiUtils = {
dateFilter = `&minDateLastSaved=${pastDate.toISOString()}`; dateFilter = `&minDateLastSaved=${pastDate.toISOString()}`;
} }
// Exclude seasonal content from random lists
let excludeFilter = '';
if (CONFIG.excludeSeasonalContent && CONFIG.seasonalSections) {
try {
const sections = JSON.parse(CONFIG.seasonalSections || "[]");
let allExcludedIds = [];
for (const section of sections) {
if (section.MediaIds) {
const idsInThisSection = section.MediaIds.split(/[\n,]/)
.map((line) => {
const urlMatch = line.match(/\[(.*?)\]/);
let id = line;
if (urlMatch) {
id = line.replace(/\[.*?\]/, '').trim();
const guidMatch = id.match(/([0-9a-f]{32})/i);
if (guidMatch) { id = guidMatch[1]; } else { id = id.split('|')[0].trim(); }
}
return id.trim();
})
.filter((id) => id);
allExcludedIds.push(...idsInThisSection);
}
}
if (allExcludedIds.length > 0) {
excludeFilter = `&ExcludeItemIds=${allExcludedIds.join(',')}`;
}
} catch(e) {
console.error("🎬 Media Bar:", "Error extracting seasonal IDs for exclusion:", e);
}
}
const fetchItems = async (currentDateFilter) => { const fetchItems = async (currentDateFilter) => {
const url = `${STATE.jellyfinData.serverAddress}/Items?IncludeItemTypes=Movie,Series&Recursive=true&hasOverview=true&imageTypes=Logo,Backdrop&${sortParams}${playedFilter}${parentalFilter}${currentDateFilter}&enableUserData=true&Limit=${CONFIG.maxItems}&fields=Id,DateCreated`; const url = `${STATE.jellyfinData.serverAddress}/Items?IncludeItemTypes=Movie,Series&Recursive=true&hasOverview=true&imageTypes=Logo,Backdrop&${sortParams}${playedFilter}${parentalFilter}${currentDateFilter}${excludeFilter}&enableUserData=true&Limit=${CONFIG.maxItems}&fields=Id,DateCreated`;
const resp = await fetch(url, { headers: this.getAuthHeaders() }); const resp = await fetch(url, { headers: this.getAuthHeaders() });
return resp; return resp;
}; };