diff --git a/Jellyfin.Plugin.MediaCleaner/Helpers/MovieHelper.cs b/Jellyfin.Plugin.MediaCleaner/Helpers/MovieHelper.cs
index ec0eb8a..429ed1c 100644
--- a/Jellyfin.Plugin.MediaCleaner/Helpers/MovieHelper.cs
+++ b/Jellyfin.Plugin.MediaCleaner/Helpers/MovieHelper.cs
@@ -17,7 +17,6 @@ public class MovieHelper(ILogger logger)
public bool IsMovieStale(BaseItem movie)
{
- _loggingHelper.LogDebugInformation("-------------------------------------------------");
_loggingHelper.LogDebugInformation("Start of scanning for movie: {Movie}", movie);
_loggingHelper.LogDebugInformation("-------------------------------------------------");
@@ -41,19 +40,22 @@ public class MovieHelper(ILogger logger)
if (mostRecentUserData.LastPlayedDate < DateTime.Now.AddDays(-Configuration.StaleMediaCutoff))
{
- _loggingHelper.LogDebugInformation("Most recent user data last played date is outside of cutoff. Adding {Movie} to stale movies.", movie);
+ _loggingHelper.LogDebugInformation("Most recent user data has last played date that is outside of cutoff.");
+ _loggingHelper.LogDebugInformation("Adding {Movie} to stale movies.", movie);
+ _loggingHelper.LogDebugInformation("With Last Played Date: {LastPlayedDate}", mostRecentUserData.LastPlayedDate);
+
movieIsStale = true;
}
}
else if (createdOutsideCutoff)
{
- _loggingHelper.LogDebugInformation("Movie has no user data and was created outside of cutoff: {DateCreated}. Adding {Movie} to stale movies.", [movie.DateCreated, movie]);
+ _loggingHelper.LogDebugInformation("Movie has no user data and was created outside of cutoff: {DateCreated}.", movie.DateCreated);
+ _loggingHelper.LogDebugInformation("Adding {Movie} to stale movies.", movie);
movieIsStale = true;
}
_loggingHelper.LogDebugInformation("-------------------------------------------------");
_loggingHelper.LogDebugInformation("End of scanning for movie: {Movie}", movie);
- _loggingHelper.LogDebugInformation("-------------------------------------------------");
return movieIsStale;
}
diff --git a/Jellyfin.Plugin.MediaCleaner/Helpers/SeriesHelper.cs b/Jellyfin.Plugin.MediaCleaner/Helpers/SeriesHelper.cs
index 0090af0..51d2950 100644
--- a/Jellyfin.Plugin.MediaCleaner/Helpers/SeriesHelper.cs
+++ b/Jellyfin.Plugin.MediaCleaner/Helpers/SeriesHelper.cs
@@ -28,8 +28,13 @@ public class SeriesHelper(ILogger logger)
var staleCreationDate = episode.DateCreated < DateTime.Now.AddDays(-Configuration.StaleMediaCutoff);
var hasUserDataWithLastPlayedDate = episode.UserData.Any(data => data.LastPlayedDate != null);
+ _loggingHelper.LogDebugInformation("-------------------------------------------------");
+ _loggingHelper.LogDebugInformation("Debug data for episode: {Episode}", episode);
+ _loggingHelper.LogDebugInformation("-------------------------------------------------");
+
if (staleCreationDate && !hasUserDataWithLastPlayedDate){
- _loggingHelper.LogInformation("Creation date is stale, and no user data for episode {Episode}.", episode);
+ _loggingHelper.LogDebugInformation("Creation date is stale, and no user data for episode {Episode}.", episode);
+ _loggingHelper.LogDebugInformation("Date created: {DateCreated}", episode.DateCreated);
episodeIsStale = true;
}
@@ -38,9 +43,6 @@ public class SeriesHelper(ILogger logger)
.OrderByDescending(data => data.LastPlayedDate)
.First();
- _loggingHelper.LogDebugInformation("User data for episode: {Episode}", episode);
- _loggingHelper.LogDebugInformation("-------------------------------------------------");
-
foreach (var property in typeof(UserData).GetProperties())
{
_loggingHelper.LogDebugInformation("{PropertyName}: {PropertyValue}", property.Name, property.GetValue(mostRecentUserData));
@@ -54,7 +56,7 @@ public class SeriesHelper(ILogger logger)
{
episodeIsStale = true;
_loggingHelper.LogDebugInformation("Most recent user data has a last played date of: {LastPlayedDate}.", [mostRecentUserData.LastPlayedDate]);
- _loggingHelper.LogDebugInformation("And episode created {DateCreated}.", episode.DateCreated);
+ _loggingHelper.LogDebugInformation("Episode created {DateCreated}.", episode.DateCreated);
_loggingHelper.LogDebugInformation("Episode is marked as stale.");
}
}
@@ -79,6 +81,8 @@ public class SeriesHelper(ILogger logger)
if(staleEpisodes.Count == episodes.Count)
{
seasonIsStale = true;
+
+ _loggingHelper.LogDebugInformation("-------------------------------------------------");
_loggingHelper.LogDebugInformation("Stale episodes count matches season episode count. Season is stale.");
_loggingHelper.LogDebugInformation("-------------------------------------------------");
}
diff --git a/Jellyfin.Plugin.MediaCleaner/Models/SeriesInfo.cs b/Jellyfin.Plugin.MediaCleaner/Models/SeriesInfo.cs
index 90ecf95..59ff805 100644
--- a/Jellyfin.Plugin.MediaCleaner/Models/SeriesInfo.cs
+++ b/Jellyfin.Plugin.MediaCleaner/Models/SeriesInfo.cs
@@ -22,9 +22,5 @@ public class SeriesInfo
///
/// Gets or sets seasons.
///
-#pragma warning disable CA2227 // Collection properties should be read only
-#pragma warning disable CA1002 // Do not expose generic lists
- public List Seasons { get; set; } = [];
-#pragma warning restore CA1002 // Do not expose generic lists
-#pragma warning restore CA2227 // Collection properties should be read only
+ public IEnumerable Seasons { get; set; } = [];
}
diff --git a/Jellyfin.Plugin.MediaCleaner/ScheduledTasks/StaleMediaTask.cs b/Jellyfin.Plugin.MediaCleaner/ScheduledTasks/StaleMediaTask.cs
index 2abb905..7c9f3d1 100644
--- a/Jellyfin.Plugin.MediaCleaner/ScheduledTasks/StaleMediaTask.cs
+++ b/Jellyfin.Plugin.MediaCleaner/ScheduledTasks/StaleMediaTask.cs
@@ -83,9 +83,8 @@ public sealed class StaleMediaTask : IScheduledTask
_loggingHelper.LogInformation("Starting scan of series items.");
_loggingHelper.LogInformation("-------------------------------------------------");
- List staleEpisodes = [.. series.SelectMany(GetStaleEpisodes)];
+ List staleSeasons = [.. series.SelectMany(GetStaleSeasons)];
- _loggingHelper.LogInformation("-------------------------------------------------");
_loggingHelper.LogInformation("Starting scan of movies items.");
_loggingHelper.LogInformation("-------------------------------------------------");
@@ -103,13 +102,13 @@ public sealed class StaleMediaTask : IScheduledTask
}
_loggingHelper.LogInformation("-------------------------------------------------");
- _loggingHelper.LogInformation("Stale Episodes found: {StaleEpisodes}", staleEpisodes.Count);
+ _loggingHelper.LogInformation("Stale seasons found: {StaleSeasons}", staleSeasons.Count);
- if (staleEpisodes.Count > 0 && Configuration.DebugMode)
+ if (staleSeasons.Count > 0 && Configuration.DebugMode)
{
- List seriesInfoList = FindSeriesInfoFromEpisodes(staleEpisodes);
+ IEnumerable staleSeriesInfo = FindSeriesInfo(staleSeasons);
- foreach (var seriesInfo in seriesInfoList)
+ foreach (var seriesInfo in staleSeriesInfo)
{
_loggingHelper.LogDebugInformation("Series Info: ID: {Id} | Series Name: {SeriesName} | Stale Seasons: {Seasons}", [seriesInfo.Id, seriesInfo.SeriesName, string.Join(", ", seriesInfo.Seasons)]);
}
@@ -132,9 +131,8 @@ public sealed class StaleMediaTask : IScheduledTask
}
- private List GetStaleEpisodes(BaseItem item)
+ private List GetStaleSeasons(BaseItem item)
{
- _loggingHelper.LogDebugInformation("-------------------------------------------------");
_loggingHelper.LogDebugInformation("Debug data for series: {SeriesName}", item.Name);
_loggingHelper.LogDebugInformation("-------------------------------------------------");
@@ -145,7 +143,7 @@ public sealed class StaleMediaTask : IScheduledTask
Recursive = false
});
- List staleEpisodes = [ ..seasons
+ List staleSeasons = [ ..seasons
.Where(season => {
var episodes = _libraryManager.GetItemList(new InternalItemsQuery
{
@@ -155,43 +153,38 @@ public sealed class StaleMediaTask : IScheduledTask
_loggingHelper.LogDebugInformation("Season debug information for {SeasonNumber}:", season);
- return _seriesHelper.IsSeasonDataStale(episodes);
+ bool isSeasonDataStale = _seriesHelper.IsSeasonDataStale(episodes);
+
+ _loggingHelper.LogDebugInformation("End of season debug information for {SeasonNumber}.", season);
+
+ return isSeasonDataStale;
})];
+
+ _loggingHelper.LogDebugInformation("-------------------------------------------------");
_loggingHelper.LogDebugInformation("End of scanning for series: {Series}", item);
_loggingHelper.LogDebugInformation("-------------------------------------------------");
- return staleEpisodes;
+ return staleSeasons;
}
- private List FindSeriesInfoFromEpisodes(IReadOnlyCollection episodes)
+ private IEnumerable FindSeriesInfo(IReadOnlyCollection seasons)
{
- Guid[] seasonIds = [.. episodes.Select(episode => episode.ParentId).Distinct()];
-
- var seasons = _libraryManager.GetItemList(new InternalItemsQuery
- {
- ItemIds = seasonIds
- });
-
Guid[] seriesIds = [.. seasons.Select(season => season.ParentId).Distinct()];
- var series = _libraryManager.GetItemList(new InternalItemsQuery
+ IReadOnlyCollection series = _libraryManager.GetItemList(new InternalItemsQuery
{
ItemIds = seriesIds
- }).ToList();
+ });
- List seriesNames = [.. series.Select(series => series.Name).Distinct()];
-
- List seriesInfoList = [];
-
- series.ForEach(series =>
+ IEnumerable seriesInfoList = series.Select(series =>
{
- seriesInfoList.Add(new SeriesInfo
+ return new SeriesInfo
{
Id = series.Id,
SeriesName = series.Name,
Seasons = [.. seasons.Where(season => season.ParentId == series.Id).Select(season => season.Name)]
- });
+ };
});
return seriesInfoList;