Media-Cleaner-Homepage-and-Api #9

Merged
T-Gander merged 4 commits from Media-Cleaner-Homepage-and-Api into main 2026-02-12 19:30:36 -07:00
5 changed files with 57 additions and 33 deletions

View File

@@ -1,5 +1,5 @@
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<AssemblyVersion>0.0.0.11</AssemblyVersion> <AssemblyVersion>0.0.0.12</AssemblyVersion>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View File

@@ -25,3 +25,7 @@ td, th {
.links:hover { .links:hover {
background-color: #2a2a2a; background-color: #2a2a2a;
} }
.actions-cell {
text-align: center;
}

View File

@@ -2,6 +2,7 @@
data-controller="__plugin/home.js"> data-controller="__plugin/home.js">
<div data-role="content"> <div data-role="content">
<div class="content-primary"> <div class="content-primary">
<link rel="stylesheet" href="/web/configurationpage?name=home.css" />
<div id="loading">Loading...</div> <div id="loading">Loading...</div>
<div id="homepage" style="visibility: hidden;"> <div id="homepage" style="visibility: hidden;">
<button class="links" data-target="configurationpage?name=Settings">Settings</button> <button class="links" data-target="configurationpage?name=Settings">Settings</button>

View File

@@ -1,5 +1,4 @@
document.addEventListener('pageshow', async () => { document.addEventListener('pageshow', async () => {
await fetchHomepageCSS();
await updateMediaCleanerState(); await updateMediaCleanerState();
var moviesTitle = document.getElementById("moviesTitle"); var moviesTitle = document.getElementById("moviesTitle");
@@ -81,7 +80,8 @@ const populateTables = async () => {
cell1.innerHTML = moviesInfo[i].Name; cell1.innerHTML = moviesInfo[i].Name;
// Will need to be enabled once radarr and sonarr integration is enabled. // Will need to be enabled once radarr and sonarr integration is enabled.
// Maybe change this to an element to remove hard coding. // Maybe change this to an element to remove hard coding.
cell2.innerHTML = "<button type=\"button\" disabled>Delete</button>"; cell2.innerHTML = "<input type=\"checkbox\" disabled />";
cell2.className = "actions-cell";
} }
} }
else{ else{
@@ -102,7 +102,7 @@ const populateTables = async () => {
cell2.innerHTML = seriesInfo[i].Seasons.map(season => season.replace("Season ", "")).join(", "); cell2.innerHTML = seriesInfo[i].Seasons.map(season => season.replace("Season ", "")).join(", ");
// Will need to be enabled once radarr and sonarr integration is enabled. // Will need to be enabled once radarr and sonarr integration is enabled.
// Maybe change this to an element to remove hard coding. // Maybe change this to an element to remove hard coding.
cell3.innerHTML = "<button type=\"button\" disabled>Delete</button>"; cell3.innerHTML = "<input type=\"checkbox\" disabled />";
cell3.className = "actions-cell"; cell3.className = "actions-cell";
} }
} }
@@ -136,16 +136,3 @@ const finishLoading = () => {
console.log("Loading element: ", loadingElement); console.log("Loading element: ", loadingElement);
console.log("Homepage element: ", homepage); console.log("Homepage element: ", homepage);
} }
const fetchHomepageCSS = async () => {
const response = await fetch('/web/configurationpage?name=home.css')
if(!response.ok){
throw new Error(`Response status: ${response.status}`);
}
const css = await response.text();
const styles = document.createElement('style');
styles.textContent = css;
document.head.appendChild(styles);
}

View File

@@ -154,21 +154,10 @@ public sealed class StaleMediaScanner
return staleMovies; return staleMovies;
} }
private IEnumerable<BaseItem> GetStaleSeasonsWithShortCircuitOnNonStaleSeason(IEnumerable<BaseItem> seasons)
private List<BaseItem> GetStaleSeasons(BaseItem item)
{ {
_loggingHelper.LogDebugInformation("-------------------------------------------------"); foreach (BaseItem season in seasons)
_loggingHelper.LogDebugInformation("Debug data for series: {SeriesName}", item.Name);
_loggingHelper.LogDebugInformation("-------------------------------------------------");
var seasons = _libraryManager.GetItemList(new InternalItemsQuery
{ {
ParentId = item.Id,
Recursive = false
});
List<BaseItem> staleSeasons = [ ..seasons
.Where(season => {
var episodes = _libraryManager.GetItemList(new InternalItemsQuery var episodes = _libraryManager.GetItemList(new InternalItemsQuery
{ {
ParentId = season.Id, ParentId = season.Id,
@@ -185,14 +174,57 @@ public sealed class StaleMediaScanner
} }
catch (ArgumentNullException ex) catch (ArgumentNullException ex)
{ {
_loggingHelper.LogInformation("Arguement Null Exception in GetStaleSeasons!"); _loggingHelper.LogInformation("Argument Null Exception in GetStaleSeasons!");
_loggingHelper.LogInformation(ex.Message); _loggingHelper.LogInformation(ex.Message);
} }
_loggingHelper.LogDebugInformation("End of season debug information for {SeasonNumber}.", season); _loggingHelper.LogDebugInformation("End of season debug information for {SeasonNumber}.", season);
return isSeasonDataStale; if (!isSeasonDataStale) yield break;
})]; yield return season;
}
}
private List<BaseItem> GetStaleSeasons(BaseItem item)
{
_loggingHelper.LogDebugInformation("-------------------------------------------------");
_loggingHelper.LogDebugInformation("Debug data for series: {SeriesName}", item.Name);
_loggingHelper.LogDebugInformation("-------------------------------------------------");
var seasons = _libraryManager.GetItemList(new InternalItemsQuery
{
ParentId = item.Id,
Recursive = false
});
List<BaseItem> staleSeasons = [.. GetStaleSeasonsWithShortCircuitOnNonStaleSeason(seasons)];
// [ ..seasons
// .Where(season => {
// var episodes = _libraryManager.GetItemList(new InternalItemsQuery
// {
// ParentId = season.Id,
// Recursive = false
// });
// _loggingHelper.LogDebugInformation("Season debug information for {SeasonNumber}:", season);
// bool isSeasonDataStale = false;
// try
// {
// isSeasonDataStale = _seriesHelper.IsSeasonDataStale(episodes);
// }
// catch (ArgumentNullException ex)
// {
// _loggingHelper.LogInformation("Arguement Null Exception in GetStaleSeasons!");
// _loggingHelper.LogInformation(ex.Message);
// }
// _loggingHelper.LogDebugInformation("End of season debug information for {SeasonNumber}.", season);
// return isSeasonDataStale;
// })];
_loggingHelper.LogDebugInformation("-------------------------------------------------"); _loggingHelper.LogDebugInformation("-------------------------------------------------");