Continued to improve logging and fixed a few bugs introduced by refactor
This commit is contained in:
@@ -83,9 +83,8 @@ public sealed class StaleMediaTask : IScheduledTask
|
||||
_loggingHelper.LogInformation("Starting scan of series items.");
|
||||
_loggingHelper.LogInformation("-------------------------------------------------");
|
||||
|
||||
List<BaseItem> staleEpisodes = [.. series.SelectMany(GetStaleEpisodes)];
|
||||
List<BaseItem> 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<SeriesInfo> seriesInfoList = FindSeriesInfoFromEpisodes(staleEpisodes);
|
||||
IEnumerable<SeriesInfo> 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<BaseItem> GetStaleEpisodes(BaseItem item)
|
||||
private List<BaseItem> 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<BaseItem> staleEpisodes = [ ..seasons
|
||||
List<BaseItem> 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<SeriesInfo> FindSeriesInfoFromEpisodes(IReadOnlyCollection<BaseItem> episodes)
|
||||
private IEnumerable<SeriesInfo> FindSeriesInfo(IReadOnlyCollection<BaseItem> 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<BaseItem> series = _libraryManager.GetItemList(new InternalItemsQuery
|
||||
{
|
||||
ItemIds = seriesIds
|
||||
}).ToList();
|
||||
});
|
||||
|
||||
List<string> seriesNames = [.. series.Select(series => series.Name).Distinct()];
|
||||
|
||||
List<SeriesInfo> seriesInfoList = [];
|
||||
|
||||
series.ForEach(series =>
|
||||
IEnumerable<SeriesInfo> 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;
|
||||
|
||||
Reference in New Issue
Block a user