Compare commits
1 Commits
ebe24e2630
...
v0.0.11-al
| Author | SHA1 | Date | |
|---|---|---|---|
| 5ba270c9a0 |
@@ -1,5 +1,5 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<AssemblyVersion>0.0.0.10</AssemblyVersion>
|
||||
<AssemblyVersion>0.0.0.9</AssemblyVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
||||
@@ -1,32 +1,22 @@
|
||||
using Jellyfin.Plugin.MediaCleaner.Data;
|
||||
using Jellyfin.Plugin.MediaCleaner;
|
||||
using Jellyfin.Plugin.MediaCleaner.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Jellyfin.Plugin.MediaCleaner.Configuration;
|
||||
|
||||
namespace Jellyfin.Plugin.MediaCleaner.Controllers;
|
||||
|
||||
[Route("mediacleaner/state")]
|
||||
public class StateController(MediaCleanerState state) : Controller
|
||||
public class StateController : Controller
|
||||
{
|
||||
private readonly MediaCleanerState _state = state;
|
||||
private static PluginConfiguration Configuration =>
|
||||
Plugin.Instance!.Configuration;
|
||||
private readonly PluginState _state;
|
||||
public StateController(PluginState state) => _state = state;
|
||||
|
||||
[HttpGet("getSeriesInfo")]
|
||||
public IActionResult GetSeriesInfo() => Ok(_state.GetSeriesInfo());
|
||||
[HttpGet]
|
||||
public IActionResult Get() => Ok(_state.GetSeriesInfo());
|
||||
|
||||
[HttpGet("getMovieInfo")]
|
||||
public IActionResult GetMovieInfo() => Ok(_state.GetMovieInfo());
|
||||
|
||||
[HttpGet("updateState")]
|
||||
public IActionResult GetUpdateState() => Ok(_state.UpdateState());
|
||||
|
||||
[HttpGet("getMoviesTitle")]
|
||||
public IActionResult GetMoviesTitle() =>
|
||||
Ok($"Stale Movies (Unwatched for and created over {Configuration.StaleMediaCutoff} Days ago.)");
|
||||
|
||||
[HttpGet("getSeriesTitle")]
|
||||
public IActionResult GetSeriesTitle() =>
|
||||
Ok($"Stale Series (Unwatched for and created over {Configuration.StaleMediaCutoff} Days ago.)");
|
||||
[HttpPost("add")]
|
||||
public IActionResult AddSeriesInfo([FromBody] SeriesInfo seriesInfo)
|
||||
{
|
||||
_state.AddSeriesInfo(seriesInfo);
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Database.Implementations.ModelConfiguration;
|
||||
using Jellyfin.Plugin.MediaCleaner;
|
||||
using Jellyfin.Plugin.MediaCleaner.Models;
|
||||
using Jellyfin.Plugin.MediaCleaner.ScheduledTasks;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Jellyfin.Plugin.MediaCleaner.Data;
|
||||
|
||||
public class MediaCleanerState(ILogger<StaleMediaScanner> logger, ILibraryManager libraryManager)
|
||||
{
|
||||
private readonly Lock _lock = new();
|
||||
private IEnumerable<MediaInfo> _mediaInfo = [];
|
||||
private readonly StaleMediaScanner _staleMediaScanner = new(logger, libraryManager);
|
||||
|
||||
public async Task UpdateState()
|
||||
{
|
||||
_mediaInfo = await _staleMediaScanner.ScanStaleMedia().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public IEnumerable<SeriesInfo> GetSeriesInfo()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
return _mediaInfo.OfType<SeriesInfo>();
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<MovieInfo> GetMovieInfo()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
return _mediaInfo.OfType<MovieInfo>();
|
||||
}
|
||||
}
|
||||
}
|
||||
29
Jellyfin.Plugin.MediaCleaner/Data/PluginState.cs
Normal file
29
Jellyfin.Plugin.MediaCleaner/Data/PluginState.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Collections.Generic;
|
||||
using Jellyfin.Plugin.MediaCleaner.Models;
|
||||
|
||||
namespace Jellyfin.Plugin.MediaCleaner.Data;
|
||||
|
||||
public class PluginState
|
||||
{
|
||||
private readonly object _lock = new();
|
||||
private List<SeriesInfo> _seriesInfo = new List<SeriesInfo>
|
||||
{
|
||||
new SeriesInfo { SeriesName = "TestName", Id = System.Guid.NewGuid() }
|
||||
};
|
||||
|
||||
public void AddSeriesInfo(SeriesInfo seriesInfo)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
_seriesInfo.Add(seriesInfo);
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<SeriesInfo> GetSeriesInfo()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
return _seriesInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,10 +17,7 @@ public class MovieHelper(ILogger logger)
|
||||
|
||||
public bool IsMovieStale(BaseItem movie)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(movie, "IsMovieStale process recieved a null movie. Logic failure. Exception thrown.");
|
||||
|
||||
_loggingHelper.LogDebugInformation("-------------------------------------------------");
|
||||
_loggingHelper.LogDebugInformation("Scanning movie: {Movie}", movie);
|
||||
_loggingHelper.LogDebugInformation("Start of scanning for movie: {Movie}", movie);
|
||||
_loggingHelper.LogDebugInformation("-------------------------------------------------");
|
||||
|
||||
bool movieIsStale = false;
|
||||
@@ -50,20 +47,13 @@ public class MovieHelper(ILogger logger)
|
||||
movieIsStale = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (createdOutsideCutoff && !hasUserData)
|
||||
else if (createdOutsideCutoff)
|
||||
{
|
||||
_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;
|
||||
}
|
||||
|
||||
if (!createdOutsideCutoff && !hasUserData)
|
||||
{
|
||||
_loggingHelper.LogDebugInformation("Movie has no user data and was not created outside of cutoff: {DateCreated}.", movie.DateCreated);
|
||||
_loggingHelper.LogDebugInformation("Movie is not stale.");
|
||||
}
|
||||
|
||||
_loggingHelper.LogDebugInformation("-------------------------------------------------");
|
||||
_loggingHelper.LogDebugInformation("End of scanning for movie: {Movie}", movie);
|
||||
|
||||
|
||||
@@ -69,7 +69,10 @@ public class SeriesHelper(ILogger logger)
|
||||
|
||||
public bool IsSeasonDataStale(IReadOnlyList<BaseItem> episodes)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(episodes, "IsSeasonDataStale process recieved null episodes. Logic failure. Exception thrown.");
|
||||
if(episodes == null)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(episodes);
|
||||
}
|
||||
|
||||
bool seasonIsStale = false;
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Jellyfin.Plugin.MediaCleaner.Models;
|
||||
|
||||
public abstract class MediaInfo
|
||||
{
|
||||
public required Guid Id { get; set; }
|
||||
public required string Name { get; set; }
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using Jellyfin.Plugin.MediaCleaner;
|
||||
|
||||
namespace Jellyfin.Plugin.MediaCleaner.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Contains Movie information.
|
||||
/// </summary>
|
||||
public class MovieInfo : MediaInfo
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,14 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using Jellyfin.Plugin.MediaCleaner;
|
||||
|
||||
namespace Jellyfin.Plugin.MediaCleaner.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Contains series information.
|
||||
/// </summary>
|
||||
public class SeriesInfo : MediaInfo
|
||||
public class SeriesInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets series identifier.
|
||||
/// </summary>
|
||||
public Guid Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets series name.
|
||||
/// </summary>
|
||||
public string SeriesName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets seasons.
|
||||
/// </summary>
|
||||
public IEnumerable<string> Seasons { get; set; } = [];
|
||||
}
|
||||
|
||||
@@ -3,29 +3,18 @@
|
||||
<div data-role="content">
|
||||
<div class="content-primary">
|
||||
<div>
|
||||
<a href="#configurationpage?name=Home">Home</a>
|
||||
<a href="#configurationpage?name=Settings">Settings</a>
|
||||
</div>
|
||||
<h2>Media Cleaner</h2>
|
||||
|
||||
<h3 id="moviesTitle"></h3>
|
||||
<table id="moviesTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<h3 id="seriesTitle"></h3>
|
||||
<table id="seriesTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Seasons</th>
|
||||
<th>ID</th>
|
||||
<th>Series Name</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,91 +1,27 @@
|
||||
document.addEventListener('pageshow', async () => {
|
||||
var moviesTitle = document.getElementById("moviesTitle");
|
||||
var seriesTitle = document.getElementById("seriesTitle");
|
||||
var moviesTable = document.getElementById("moviesTable");
|
||||
var seriesTable = document.getElementById("seriesTable");
|
||||
var table = document.getElementById("seriesTable");
|
||||
|
||||
const getMediaCleanerSeriesInfo = async () => {
|
||||
const response = await fetch("/mediacleaner/state/getSeriesInfo");
|
||||
|
||||
|
||||
const getMediaCleanerState = async () => {
|
||||
const response = await fetch('/mediacleaner/state');
|
||||
|
||||
if(!response.ok){
|
||||
throw new Error(`Response status: ${response.status}`)
|
||||
}
|
||||
|
||||
return response.json();
|
||||
}
|
||||
}
|
||||
|
||||
const getMediaCleanerMovieInfo = async () => {
|
||||
const response = await fetch("/mediacleaner/state/getMovieInfo");
|
||||
var state = await getMediaCleanerState();
|
||||
|
||||
if(!response.ok){
|
||||
throw new Error(`Response status: ${response.status}`)
|
||||
}
|
||||
console.log("State: ", state);
|
||||
|
||||
return response.json();
|
||||
}
|
||||
|
||||
const updateMediaCleanerState = async () => {
|
||||
const response = await fetch("/mediacleaner/state/updateState");
|
||||
|
||||
if(!response.ok){
|
||||
throw new Error(`Response status: ${response.status}`)
|
||||
}
|
||||
|
||||
return response.json();
|
||||
}
|
||||
|
||||
const getMediaCleanerSeriesTitle = async () => {
|
||||
const response = await fetch("/mediacleaner/state/getSeriesTitle");
|
||||
|
||||
if(!response.ok){
|
||||
throw new Error(`Response status: ${response.status}`);
|
||||
}
|
||||
|
||||
return response.json();
|
||||
}
|
||||
|
||||
const getMediaCleanerMoviesTitle = async () => {
|
||||
const response = await fetch("/mediacleaner/state/getMoviesTitle");
|
||||
|
||||
if(!response.ok){
|
||||
throw new Error(`Response status: ${response.status}`);
|
||||
}
|
||||
|
||||
return response.json();
|
||||
}
|
||||
|
||||
const populateMoviesTable = () => {
|
||||
moviesTable.innerHTML = '';
|
||||
|
||||
for(let i = 0; i < moviesInfo.length; i++){
|
||||
var row = moviesTable.insertRow(-1);
|
||||
var cell1 = row.insertCell(0);
|
||||
var cell2 = row.insertCell(1);
|
||||
cell1.innerHTML = moviesInfo[i].Name;
|
||||
cell2.innerHTML = "<button>Delete</button>";
|
||||
}
|
||||
}
|
||||
|
||||
const populateSeriesTable = () => {
|
||||
seriesTable.innerHTML = '';
|
||||
|
||||
for(let i = 0; i < seriesInfo.length; i++){
|
||||
var row = seriesTable.insertRow(-1);
|
||||
for(let i = 0; i < state.length; i++){
|
||||
var row = table.insertRow(-1);
|
||||
var cell1 = row.insertCell(0);
|
||||
var cell2 = row.insertCell(1);
|
||||
var cell3 = row.insertCell(2);
|
||||
cell1.innerHTML = seriesInfo[i].Name;
|
||||
cell2.innerHTML = seriesInfo[i].Seasons.map(season => season.replace("Season ", "")).join(", ");
|
||||
cell3.innerHTML = "<button>Delete</button>";
|
||||
}
|
||||
}
|
||||
|
||||
moviesTitle.innerHTML = await getMediaCleanerMoviesTitle();
|
||||
seriesTitle.innerHTML = await getMediaCleanerSeriesTitle();
|
||||
|
||||
await updateMediaCleanerState();
|
||||
var moviesInfo = await getMediaCleanerMovieInfo();
|
||||
var seriesInfo = await getMediaCleanerSeriesInfo();
|
||||
populateMoviesTable();
|
||||
populateSeriesTable();
|
||||
});
|
||||
cell1.innerHTML = state[i].Id;
|
||||
cell2.innerHTML = state[i].SeriesName;
|
||||
cell3.innerHTML = state[i].Seasons.length;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,6 @@ public class PluginServiceRegistrator : IPluginServiceRegistrator
|
||||
{
|
||||
public void RegisterServices(IServiceCollection serviceCollection, IServerApplicationHost applicationHost)
|
||||
{
|
||||
serviceCollection.AddSingleton<MediaCleanerState>();
|
||||
serviceCollection.AddSingleton<PluginState>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,20 +14,18 @@ using Jellyfin.Database.Implementations.Entities;
|
||||
using Jellyfin.Database.Implementations.Entities.Libraries;
|
||||
using Jellyfin.Plugin.MediaCleaner.Configuration;
|
||||
using Jellyfin.Plugin.MediaCleaner.Helpers;
|
||||
using Jellyfin.Plugin.MediaCleaner;
|
||||
using Jellyfin.Plugin.MediaCleaner.Models;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Model.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Jellyfin.Plugin.MediaCleaner;
|
||||
namespace Jellyfin.Plugin.MediaCleaner.ScheduledTasks;
|
||||
|
||||
/// <summary>
|
||||
/// A task to scan media for stale files.
|
||||
/// </summary>
|
||||
public sealed class StaleMediaScanner
|
||||
public sealed class StaleMediaTask : IScheduledTask
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
@@ -40,7 +38,7 @@ public sealed class StaleMediaScanner
|
||||
/// </summary>
|
||||
/// <param name="logger">Logger for StaleMediaTask.</param>
|
||||
/// <param name="libraryManager">Accesses jellyfin's library manager for media.</param>
|
||||
public StaleMediaScanner(ILogger<StaleMediaScanner> logger, ILibraryManager libraryManager)
|
||||
public StaleMediaTask(ILogger<StaleMediaTask> logger, ILibraryManager libraryManager)
|
||||
{
|
||||
_logger = logger;
|
||||
_libraryManager = libraryManager;
|
||||
@@ -49,7 +47,18 @@ public sealed class StaleMediaScanner
|
||||
_seriesHelper = new SeriesHelper(_logger);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<MediaInfo>> ScanStaleMedia()
|
||||
private static PluginConfiguration Configuration =>
|
||||
Plugin.Instance!.Configuration;
|
||||
|
||||
string IScheduledTask.Name => "Scan Stale Media";
|
||||
|
||||
string IScheduledTask.Key => "Stale Media";
|
||||
|
||||
string IScheduledTask.Description => "Scan Stale Media";
|
||||
|
||||
string IScheduledTask.Category => "Media";
|
||||
|
||||
Task IScheduledTask.ExecuteAsync(IProgress<double> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
_loggingHelper.LogDebugInformation("--DEBUG MODE ACTIVE--");
|
||||
_loggingHelper.LogInformation("-------------------------------------------------");
|
||||
@@ -64,92 +73,59 @@ public sealed class StaleMediaScanner
|
||||
|
||||
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 seasons found: {StaleSeasons}", staleSeasons.Count);
|
||||
|
||||
IEnumerable<MediaInfo> staleSeriesInfo = [];
|
||||
|
||||
if (staleSeasons.Count > 0)
|
||||
{
|
||||
staleSeriesInfo = FindSeriesInfo(staleSeasons);
|
||||
|
||||
foreach (SeriesInfo seriesInfo in staleSeriesInfo.Cast<SeriesInfo>())
|
||||
{
|
||||
_loggingHelper.LogInformation("Series Info: ID: {Id} | Series Name: {SeriesName} | Stale Seasons: {Seasons}", [seriesInfo.Id, seriesInfo.Name, string.Join(", ", seriesInfo.Seasons)]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loggingHelper.LogInformation("No stale seasons found!");
|
||||
}
|
||||
|
||||
_loggingHelper.LogInformation("-------------------------------------------------");
|
||||
_loggingHelper.LogInformation("Stale Movies found: {StaleMovies}", staleMovies.Count);
|
||||
|
||||
IEnumerable<MediaInfo> staleMoviesInfo = [];
|
||||
|
||||
if (staleMovies.Count > 0)
|
||||
if (staleMovies.Count > 0 && Configuration.DebugMode)
|
||||
{
|
||||
staleMoviesInfo = staleMovies.Select(movie => new MovieInfo
|
||||
foreach (var movieInfo in staleMovies)
|
||||
{
|
||||
Id = movie.Id,
|
||||
Name = movie.Name
|
||||
});
|
||||
|
||||
foreach (MovieInfo movieInfo in staleMoviesInfo.Cast<MovieInfo>())
|
||||
{
|
||||
_loggingHelper.LogInformation("Movie Info: ID: {Id} | Movie Name: {MovieName}", [movieInfo.Id, movieInfo.Name]);
|
||||
_loggingHelper.LogDebugInformation("Movie Info: ID: {Id} | Movie Name: {MovieName}", [movieInfo.Id, movieInfo.Name]);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
_loggingHelper.LogInformation("-------------------------------------------------");
|
||||
_loggingHelper.LogInformation("Stale seasons found: {StaleSeasons}", staleSeasons.Count);
|
||||
|
||||
if (staleSeasons.Count > 0 && Configuration.DebugMode)
|
||||
{
|
||||
_loggingHelper.LogInformation("No stale movies found!");
|
||||
IEnumerable<SeriesInfo> staleSeriesInfo = FindSeriesInfo(staleSeasons);
|
||||
|
||||
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)]);
|
||||
}
|
||||
}
|
||||
|
||||
_loggingHelper.LogInformation("-------------------------------------------------");
|
||||
_loggingHelper.LogInformation("Ending stale media scan...");
|
||||
_loggingHelper.LogInformation("-------------------------------------------------");
|
||||
|
||||
IEnumerable<MediaInfo> mediaInfo = staleSeriesInfo.Concat(staleMoviesInfo);
|
||||
|
||||
return mediaInfo;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private List<BaseItem> GetStaleMovies(List<BaseItem> movies)
|
||||
{
|
||||
List<BaseItem> staleMovies = [];
|
||||
|
||||
try
|
||||
{
|
||||
staleMovies.AddRange(movies.Where(_movieHelper.IsMovieStale));
|
||||
}
|
||||
catch (ArgumentNullException ex)
|
||||
{
|
||||
_loggingHelper.LogInformation("Arguement Null Exception in GetStaleMovies!");
|
||||
_loggingHelper.LogInformation(ex.Message);
|
||||
}
|
||||
|
||||
return staleMovies;
|
||||
}
|
||||
@@ -157,10 +133,10 @@ public sealed class StaleMediaScanner
|
||||
|
||||
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,
|
||||
@@ -177,17 +153,7 @@ public sealed class StaleMediaScanner
|
||||
|
||||
_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);
|
||||
|
||||
@@ -197,11 +163,12 @@ public sealed class StaleMediaScanner
|
||||
|
||||
_loggingHelper.LogDebugInformation("-------------------------------------------------");
|
||||
_loggingHelper.LogDebugInformation("End of scanning for series: {Series}", item);
|
||||
_loggingHelper.LogDebugInformation("-------------------------------------------------");
|
||||
|
||||
return staleSeasons;
|
||||
}
|
||||
|
||||
private IEnumerable<MediaInfo> FindSeriesInfo(IReadOnlyCollection<BaseItem> seasons)
|
||||
private IEnumerable<SeriesInfo> FindSeriesInfo(IReadOnlyCollection<BaseItem> seasons)
|
||||
{
|
||||
Guid[] seriesIds = [.. seasons.Select(season => season.ParentId).Distinct()];
|
||||
|
||||
@@ -215,11 +182,21 @@ public sealed class StaleMediaScanner
|
||||
return new SeriesInfo
|
||||
{
|
||||
Id = series.Id,
|
||||
Name = series.Name,
|
||||
SeriesName = series.Name,
|
||||
Seasons = [.. seasons.Where(season => season.ParentId == series.Id).Select(season => season.Name)]
|
||||
};
|
||||
});
|
||||
|
||||
return seriesInfoList;
|
||||
}
|
||||
|
||||
IEnumerable<TaskTriggerInfo> IScheduledTask.GetDefaultTriggers()
|
||||
{
|
||||
// Run this task every 24 hours
|
||||
yield return new TaskTriggerInfo
|
||||
{
|
||||
Type = TaskTriggerInfoType.IntervalTrigger,
|
||||
IntervalTicks = TimeSpan.FromHours(24).Ticks
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user