|
|
|
|
@@ -73,59 +73,46 @@ public sealed class StaleMediaTask : IScheduledTask
|
|
|
|
|
|
|
|
|
|
List<BaseItem> allItems = [.. _libraryManager.GetItemsResult(query).Items];
|
|
|
|
|
|
|
|
|
|
_loggingHelper.LogInformation("Total items to scan: {ItemCount}", allItems.Count);
|
|
|
|
|
_loggingHelper.LogDebugInformation("Items found: {AllItems}", allItems);
|
|
|
|
|
_loggingHelper.LogInformation("Total items: {ItemCount}", allItems.Count);
|
|
|
|
|
_loggingHelper.LogInformation("Stale items found: {AllItems}", allItems);
|
|
|
|
|
|
|
|
|
|
List<BaseItem> series = [.. allItems.Where(item => item.GetBaseItemKind() == BaseItemKind.Series)];
|
|
|
|
|
List<BaseItem> movies = [.. allItems.Where(item => item.GetBaseItemKind() == BaseItemKind.Movie)];
|
|
|
|
|
|
|
|
|
|
_loggingHelper.LogDebugInformation("-------------------------------------------------");
|
|
|
|
|
_loggingHelper.LogDebugInformation("Starting scan of series items.");
|
|
|
|
|
_loggingHelper.LogInformation("-------------------------------------------------");
|
|
|
|
|
_loggingHelper.LogInformation("Starting scan of series items.");
|
|
|
|
|
_loggingHelper.LogInformation("-------------------------------------------------");
|
|
|
|
|
|
|
|
|
|
List<BaseItem> staleSeasons = [.. series.SelectMany(GetStaleSeasons)];
|
|
|
|
|
|
|
|
|
|
_loggingHelper.LogDebugInformation("-------------------------------------------------");
|
|
|
|
|
_loggingHelper.LogDebugInformation("End of scan for series items.");
|
|
|
|
|
|
|
|
|
|
_loggingHelper.LogDebugInformation("-------------------------------------------------");
|
|
|
|
|
_loggingHelper.LogDebugInformation("Starting scan of movie items.");
|
|
|
|
|
_loggingHelper.LogInformation("Starting scan of movies items.");
|
|
|
|
|
_loggingHelper.LogInformation("-------------------------------------------------");
|
|
|
|
|
|
|
|
|
|
List<BaseItem> staleMovies = [.. GetStaleMovies(movies)];
|
|
|
|
|
|
|
|
|
|
_loggingHelper.LogDebugInformation("-------------------------------------------------");
|
|
|
|
|
_loggingHelper.LogDebugInformation("End of scan for movie items.");
|
|
|
|
|
_loggingHelper.LogInformation("-------------------------------------------------");
|
|
|
|
|
_loggingHelper.LogInformation("Stale Movies found: {StaleMovies}", staleMovies.Count);
|
|
|
|
|
|
|
|
|
|
if (staleMovies.Count > 0 && Configuration.DebugMode)
|
|
|
|
|
{
|
|
|
|
|
foreach (var movieInfo in staleMovies)
|
|
|
|
|
{
|
|
|
|
|
_loggingHelper.LogDebugInformation("Movie Info: ID: {Id} | Movie Name: {MovieName}", [movieInfo.Id, movieInfo.Name]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_loggingHelper.LogInformation("-------------------------------------------------");
|
|
|
|
|
_loggingHelper.LogInformation("Stale seasons found: {StaleSeasons}", staleSeasons.Count);
|
|
|
|
|
|
|
|
|
|
if (staleSeasons.Count > 0)
|
|
|
|
|
if (staleSeasons.Count > 0 && Configuration.DebugMode)
|
|
|
|
|
{
|
|
|
|
|
IEnumerable<SeriesInfo> staleSeriesInfo = FindSeriesInfo(staleSeasons);
|
|
|
|
|
|
|
|
|
|
foreach (var seriesInfo in staleSeriesInfo)
|
|
|
|
|
{
|
|
|
|
|
_loggingHelper.LogInformation("Series Info: ID: {Id} | Series Name: {SeriesName} | Stale Seasons: {Seasons}", [seriesInfo.Id, seriesInfo.SeriesName, string.Join(", ", seriesInfo.Seasons)]);
|
|
|
|
|
_loggingHelper.LogDebugInformation("Series Info: ID: {Id} | Series Name: {SeriesName} | Stale Seasons: {Seasons}", [seriesInfo.Id, seriesInfo.SeriesName, string.Join(", ", seriesInfo.Seasons)]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_loggingHelper.LogInformation("No stale seasons found!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_loggingHelper.LogInformation("-------------------------------------------------");
|
|
|
|
|
_loggingHelper.LogInformation("Stale Movies found: {StaleMovies}", staleMovies.Count);
|
|
|
|
|
|
|
|
|
|
if (staleMovies.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var movieInfo in staleMovies)
|
|
|
|
|
{
|
|
|
|
|
_loggingHelper.LogInformation("Movie Info: ID: {Id} | Movie Name: {MovieName}", [movieInfo.Id, movieInfo.Name]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_loggingHelper.LogInformation("No stale movies found!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_loggingHelper.LogInformation("-------------------------------------------------");
|
|
|
|
|
_loggingHelper.LogInformation("Ending stale media scan...");
|
|
|
|
|
@@ -138,15 +125,7 @@ public sealed class StaleMediaTask : IScheduledTask
|
|
|
|
|
{
|
|
|
|
|
List<BaseItem> staleMovies = [];
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
staleMovies.AddRange(movies.Where(_movieHelper.IsMovieStale));
|
|
|
|
|
}
|
|
|
|
|
catch (ArgumentNullException ex)
|
|
|
|
|
{
|
|
|
|
|
_loggingHelper.LogInformation("Arguement Null Exception in GetStaleMovies!");
|
|
|
|
|
_loggingHelper.LogInformation(ex.Message);
|
|
|
|
|
}
|
|
|
|
|
staleMovies.AddRange(movies.Where(_movieHelper.IsMovieStale));
|
|
|
|
|
|
|
|
|
|
return staleMovies;
|
|
|
|
|
}
|
|
|
|
|
@@ -154,10 +133,10 @@ public sealed class StaleMediaTask : IScheduledTask
|
|
|
|
|
|
|
|
|
|
private List<BaseItem> GetStaleSeasons(BaseItem item)
|
|
|
|
|
{
|
|
|
|
|
_loggingHelper.LogDebugInformation("-------------------------------------------------");
|
|
|
|
|
_loggingHelper.LogDebugInformation("Debug data for series: {SeriesName}", item.Name);
|
|
|
|
|
_loggingHelper.LogDebugInformation("-------------------------------------------------");
|
|
|
|
|
|
|
|
|
|
// Gets each season in a show
|
|
|
|
|
var seasons = _libraryManager.GetItemList(new InternalItemsQuery
|
|
|
|
|
{
|
|
|
|
|
ParentId = item.Id,
|
|
|
|
|
@@ -174,17 +153,7 @@ public sealed class StaleMediaTask : IScheduledTask
|
|
|
|
|
|
|
|
|
|
_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);
|
|
|
|
|
}
|
|
|
|
|
bool isSeasonDataStale = _seriesHelper.IsSeasonDataStale(episodes);
|
|
|
|
|
|
|
|
|
|
_loggingHelper.LogDebugInformation("End of season debug information for {SeasonNumber}.", season);
|
|
|
|
|
|
|
|
|
|
@@ -194,6 +163,7 @@ public sealed class StaleMediaTask : IScheduledTask
|
|
|
|
|
|
|
|
|
|
_loggingHelper.LogDebugInformation("-------------------------------------------------");
|
|
|
|
|
_loggingHelper.LogDebugInformation("End of scanning for series: {Series}", item);
|
|
|
|
|
_loggingHelper.LogDebugInformation("-------------------------------------------------");
|
|
|
|
|
|
|
|
|
|
return staleSeasons;
|
|
|
|
|
}
|
|
|
|
|
@@ -223,7 +193,6 @@ public sealed class StaleMediaTask : IScheduledTask
|
|
|
|
|
IEnumerable<TaskTriggerInfo> IScheduledTask.GetDefaultTriggers()
|
|
|
|
|
{
|
|
|
|
|
// Run this task every 24 hours
|
|
|
|
|
// Unnecessary, and will be removed once front end page is ready.
|
|
|
|
|
yield return new TaskTriggerInfo
|
|
|
|
|
{
|
|
|
|
|
Type = TaskTriggerInfoType.IntervalTrigger,
|
|
|
|
|
|