diff --git a/Jellyfin.Plugin.MediaCleaner/Models/SeriesInfo.cs b/Jellyfin.Plugin.MediaCleaner/Models/SeriesInfo.cs
new file mode 100644
index 0000000..90ecf95
--- /dev/null
+++ b/Jellyfin.Plugin.MediaCleaner/Models/SeriesInfo.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+
+namespace Jellyfin.Plugin.MediaCleaner.Models;
+
+///
+/// Contains series information.
+///
+public class SeriesInfo
+{
+ ///
+ /// Gets or sets series identifier.
+ ///
+ public Guid Id { get; set; }
+
+ ///
+ /// Gets or sets series name.
+ ///
+ public string SeriesName { get; set; } = string.Empty;
+
+ ///
+ /// 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
+}
diff --git a/Jellyfin.Plugin.MediaCleaner/ScheduledTasks/StaleMediaTask.cs b/Jellyfin.Plugin.MediaCleaner/ScheduledTasks/StaleMediaTask.cs
index 79105ec..bb10290 100644
--- a/Jellyfin.Plugin.MediaCleaner/ScheduledTasks/StaleMediaTask.cs
+++ b/Jellyfin.Plugin.MediaCleaner/ScheduledTasks/StaleMediaTask.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.Data.Common;
using System.Diagnostics;
using System.Linq;
using System.Reflection.Metadata.Ecma335;
@@ -10,6 +11,7 @@ using Jellyfin.Data.Enums;
using Jellyfin.Database.Implementations.Entities;
using Jellyfin.Database.Implementations.Entities.Libraries;
using Jellyfin.Plugin.MediaCleaner.Configuration;
+using Jellyfin.Plugin.MediaCleaner.Models;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Tasks;
@@ -77,8 +79,12 @@ public sealed class StaleMediaTask : IScheduledTask
if (staleEpisodes.Count > 0)
{
// Firstly figure out the seasons, and then the Series to find the name.
- List seriesNames = FindDistinctSeriesNamesFromEpisodes(staleEpisodes);
- _logger.LogInformation("Series: {Names}", string.Join(", ", seriesNames));
+ List seriesInfoList = FindSeriesInfoFromEpisodes(staleEpisodes);
+
+ foreach (var seriesInfo in seriesInfoList)
+ {
+ _logger.LogInformation("Series Info: ID: {Id} | Series Name: {SeriesName} | Stale Seasons: {Seasons}", [seriesInfo.Id, seriesInfo.SeriesName, string.Join(", ", seriesInfo.Seasons)]);
+ }
}
return Task.CompletedTask;
@@ -99,7 +105,7 @@ public sealed class StaleMediaTask : IScheduledTask
return staleMovies;
}
- private List FindDistinctSeriesNamesFromEpisodes(List episodes)
+ private List FindSeriesInfoFromEpisodes(List episodes)
{
Guid[] seasonIds = [.. episodes.Select(episode => episode.ParentId).Distinct()];
@@ -113,11 +119,24 @@ public sealed class StaleMediaTask : IScheduledTask
var series = _libraryManager.GetItemList(new InternalItemsQuery
{
ItemIds = seriesIds
- });
+ }).ToList();
+ // Series Id, Series Name and Stale Seasons
List seriesNames = [.. series.Select(series => series.Name).Distinct()];
- return seriesNames;
+ List seriesInfoList = [];
+
+ series.ForEach(series =>
+ {
+ seriesInfoList.Add(new SeriesInfo
+ {
+ Id = series.Id,
+ SeriesName = series.Name,
+ Seasons = [.. seasons.Where(season => season.ParentId == series.Id).Select(season => season.Name)]
+ });
+ });
+
+ return seriesInfoList;
}
private List GetStaleEpisodes(BaseItem item)