Compare commits
11 Commits
66716a9bc9
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 629d5d1f2e | |||
| 1bd4935232 | |||
| 984db9e089 | |||
| e77f7dcd5f | |||
| 669f59db15 | |||
| a69f9df4e1 | |||
| e99ce96563 | |||
| 56403b5722 | |||
| ebe24e2630 | |||
| 04ef815a9b | |||
| 5ba270c9a0 |
@@ -1,5 +1,5 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<AssemblyVersion>0.0.0.10</AssemblyVersion>
|
||||
<AssemblyVersion>0.0.0.11</AssemblyVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
||||
@@ -1,22 +1,32 @@
|
||||
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 : Controller
|
||||
public class StateController(MediaCleanerState state) : Controller
|
||||
{
|
||||
private readonly PluginState _state;
|
||||
public StateController(PluginState state) => _state = state;
|
||||
private readonly MediaCleanerState _state = state;
|
||||
private static PluginConfiguration Configuration =>
|
||||
Plugin.Instance!.Configuration;
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Get() => Ok(_state.GetSeriesInfo());
|
||||
[HttpGet("getSeriesInfo")]
|
||||
public IActionResult GetSeriesInfo() => Ok(_state.GetSeriesInfo());
|
||||
|
||||
[HttpPost("add")]
|
||||
public IActionResult AddSeriesInfo([FromBody] SeriesInfo seriesInfo)
|
||||
{
|
||||
_state.AddSeriesInfo(seriesInfo);
|
||||
return Ok();
|
||||
}
|
||||
[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.)");
|
||||
}
|
||||
|
||||
42
Jellyfin.Plugin.MediaCleaner/Data/MediaCleanerState.cs
Normal file
42
Jellyfin.Plugin.MediaCleaner/Data/MediaCleanerState.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
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>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
9
Jellyfin.Plugin.MediaCleaner/Models/MediaInfo.cs
Normal file
9
Jellyfin.Plugin.MediaCleaner/Models/MediaInfo.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace Jellyfin.Plugin.MediaCleaner.Models;
|
||||
|
||||
public abstract class MediaInfo
|
||||
{
|
||||
public required Guid Id { get; set; }
|
||||
public required string Name { get; set; }
|
||||
}
|
||||
14
Jellyfin.Plugin.MediaCleaner/Models/MovieInfo.cs
Normal file
14
Jellyfin.Plugin.MediaCleaner/Models/MovieInfo.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
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,26 +1,14 @@
|
||||
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
|
||||
public class SeriesInfo : MediaInfo
|
||||
{
|
||||
/// <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; } = [];
|
||||
}
|
||||
|
||||
27
Jellyfin.Plugin.MediaCleaner/Pages/home.css
Normal file
27
Jellyfin.Plugin.MediaCleaner/Pages/home.css
Normal file
@@ -0,0 +1,27 @@
|
||||
table {
|
||||
border: 1px solid;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
td, th {
|
||||
border: 1px solid;
|
||||
padding: 0.5rem 0.75rem;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.links {
|
||||
background-color: #0f0f0f;
|
||||
border: 1px solid;
|
||||
padding: 0.8rem 1.8rem;
|
||||
font-size: 1.2rem;
|
||||
color: #ffffff;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
line-height: inherit;
|
||||
vertical-align: baseline;
|
||||
transition: background-color 0.3s ease;
|
||||
}
|
||||
|
||||
.links:hover {
|
||||
background-color: #2a2a2a;
|
||||
}
|
||||
@@ -1,17 +1,31 @@
|
||||
<div data-role="page" class="page type-interior pluginConfigurationPage withTabs"
|
||||
data-controller="__plugin/media_cleaner_table.js">
|
||||
<div data-role="page" class="page type-interior pluginConfigurationPage"
|
||||
data-controller="__plugin/home.js">
|
||||
<div data-role="content">
|
||||
<div class="content-primary">
|
||||
<div>
|
||||
<a href="#configurationpage?name=Home">Home</a>
|
||||
<a href="#configurationpage?name=Settings">Settings</a>
|
||||
</div>
|
||||
<div id="loading">Loading...</div>
|
||||
<div id="homepage" style="visibility: hidden;">
|
||||
<button class="links" data-target="configurationpage?name=Settings">Settings</button>
|
||||
<h2>Media Cleaner</h2>
|
||||
|
||||
<h3 id="moviesTitle"></h3>
|
||||
<table id="moviesTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th class="actions-cell">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
<br>
|
||||
|
||||
<h3 id="seriesTitle"></h3>
|
||||
<table id="seriesTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Series Name</th>
|
||||
<th>Name</th>
|
||||
<th>Seasons</th>
|
||||
<th class="actions-cell">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
@@ -19,3 +33,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
151
Jellyfin.Plugin.MediaCleaner/Pages/home.js
Normal file
151
Jellyfin.Plugin.MediaCleaner/Pages/home.js
Normal file
@@ -0,0 +1,151 @@
|
||||
document.addEventListener('pageshow', async () => {
|
||||
await fetchHomepageCSS();
|
||||
await updateMediaCleanerState();
|
||||
|
||||
var moviesTitle = document.getElementById("moviesTitle");
|
||||
var seriesTitle = document.getElementById("seriesTitle");
|
||||
|
||||
moviesTitle.innerHTML = await getMediaCleanerMoviesTitle();
|
||||
seriesTitle.innerHTML = await getMediaCleanerSeriesTitle();
|
||||
|
||||
await populateTables();
|
||||
addClickHandlersToLinks();
|
||||
finishLoading();
|
||||
});
|
||||
|
||||
const getMediaCleanerSeriesInfo = async () => {
|
||||
const response = await fetch("/mediacleaner/state/getSeriesInfo");
|
||||
|
||||
if(!response.ok){
|
||||
throw new Error(`Response status: ${response.status}`)
|
||||
}
|
||||
|
||||
return response.json();
|
||||
};
|
||||
|
||||
const getMediaCleanerMovieInfo = async () => {
|
||||
const response = await fetch("/mediacleaner/state/getMovieInfo");
|
||||
|
||||
if(!response.ok){
|
||||
throw new Error(`Response status: ${response.status}`)
|
||||
}
|
||||
|
||||
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 populateTables = async () => {
|
||||
var moviesInfo = await getMediaCleanerMovieInfo();
|
||||
var seriesInfo = await getMediaCleanerSeriesInfo();
|
||||
|
||||
var seriesTableBody = seriesTable.getElementsByTagName('tbody')[0];
|
||||
seriesTableBody.replaceChildren();
|
||||
|
||||
var moviesTableBody = moviesTable.getElementsByTagName('tbody')[0];
|
||||
moviesTableBody.replaceChildren();
|
||||
|
||||
if (moviesInfo.length > 0){
|
||||
for(let i = 0; i < moviesInfo.length; i++){
|
||||
var row = moviesTableBody.insertRow(-1);
|
||||
var cell1 = row.insertCell(0);
|
||||
var cell2 = row.insertCell(1);
|
||||
cell1.innerHTML = moviesInfo[i].Name;
|
||||
// Will need to be enabled once radarr and sonarr integration is enabled.
|
||||
// Maybe change this to an element to remove hard coding.
|
||||
cell2.innerHTML = "<button type=\"button\" disabled>Delete</button>";
|
||||
}
|
||||
}
|
||||
else{
|
||||
var columnCount = moviesTable.tHead.rows[0].cells.length;
|
||||
var row = moviesTableBody.insertRow(-1);
|
||||
var cell1 = row.insertCell(0);
|
||||
cell1.colSpan = columnCount;
|
||||
cell1.innerHTML = "No stale movies found.";
|
||||
}
|
||||
|
||||
if(seriesInfo.length > 0){
|
||||
for(let i = 0; i < seriesInfo.length; i++){
|
||||
var row = seriesTableBody.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(", ");
|
||||
// Will need to be enabled once radarr and sonarr integration is enabled.
|
||||
// Maybe change this to an element to remove hard coding.
|
||||
cell3.innerHTML = "<button type=\"button\" disabled>Delete</button>";
|
||||
cell3.className = "actions-cell";
|
||||
}
|
||||
}
|
||||
else{
|
||||
var columnCount = seriesTable.tHead.rows[0].cells.length;
|
||||
var row = seriesTableBody.insertRow(-1);
|
||||
var cell1 = row.insertCell(0);
|
||||
cell1.colSpan = columnCount;
|
||||
cell1.innerHTML = "No stale series found.";
|
||||
}
|
||||
};
|
||||
|
||||
const addClickHandlersToLinks = () => {
|
||||
const linkbtns = document.querySelectorAll("button.links")
|
||||
linkbtns.forEach(btn => {
|
||||
btn.addEventListener("click", () => {
|
||||
const target = btn.dataset.target;
|
||||
if (!target) return;
|
||||
window.location.hash = target;
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const finishLoading = () => {
|
||||
const loadingElement = document.getElementById("loading");
|
||||
|
||||
const homepage = document.getElementById("homepage");
|
||||
loadingElement.style.visibility = "hidden";
|
||||
homepage.style.visibility = "visible";
|
||||
|
||||
console.log("Loading element: ", loadingElement);
|
||||
console.log("Homepage element: ", homepage);
|
||||
}
|
||||
|
||||
const fetchHomepageCSS = async () => {
|
||||
const response = await fetch('/web/configurationpage?name=home.css')
|
||||
|
||||
if(!response.ok){
|
||||
throw new Error(`Response status: ${response.status}`);
|
||||
}
|
||||
|
||||
const css = await response.text();
|
||||
const styles = document.createElement('style');
|
||||
styles.textContent = css;
|
||||
document.head.appendChild(styles);
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
var table = document.getElementById("seriesTable");
|
||||
|
||||
|
||||
|
||||
const getMediaCleanerState = async () => {
|
||||
const response = await fetch('/mediacleaner/state');
|
||||
|
||||
if(!response.ok){
|
||||
throw new Error(`Response status: ${response.status}`)
|
||||
}
|
||||
|
||||
return response.json();
|
||||
}
|
||||
|
||||
var state = await getMediaCleanerState();
|
||||
|
||||
console.log("State: ", state);
|
||||
|
||||
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 = state[i].Id;
|
||||
cell2.innerHTML = state[i].SeriesName;
|
||||
cell3.innerHTML = state[i].Seasons.length;
|
||||
}
|
||||
@@ -57,8 +57,13 @@ public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
|
||||
},
|
||||
new PluginPageInfo
|
||||
{
|
||||
Name = "media_cleaner_table.js",
|
||||
EmbeddedResourcePath = string.Format(CultureInfo.InvariantCulture, "{0}.Pages.media_cleaner_table.js", GetType().Namespace),
|
||||
Name = "home.js",
|
||||
EmbeddedResourcePath = string.Format(CultureInfo.InvariantCulture, "{0}.Pages.home.js", GetType().Namespace),
|
||||
},
|
||||
new PluginPageInfo
|
||||
{
|
||||
Name = "home.css",
|
||||
EmbeddedResourcePath = string.Format(CultureInfo.InvariantCulture, "{0}.Pages.home.css", GetType().Namespace),
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
@@ -8,6 +8,6 @@ public class PluginServiceRegistrator : IPluginServiceRegistrator
|
||||
{
|
||||
public void RegisterServices(IServiceCollection serviceCollection, IServerApplicationHost applicationHost)
|
||||
{
|
||||
serviceCollection.AddSingleton<PluginState>();
|
||||
serviceCollection.AddSingleton<MediaCleanerState>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,18 +14,20 @@ 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.ScheduledTasks;
|
||||
namespace Jellyfin.Plugin.MediaCleaner;
|
||||
|
||||
/// <summary>
|
||||
/// A task to scan media for stale files.
|
||||
/// </summary>
|
||||
public sealed class StaleMediaTask : IScheduledTask
|
||||
public sealed class StaleMediaScanner
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
@@ -38,7 +40,7 @@ public sealed class StaleMediaTask : IScheduledTask
|
||||
/// </summary>
|
||||
/// <param name="logger">Logger for StaleMediaTask.</param>
|
||||
/// <param name="libraryManager">Accesses jellyfin's library manager for media.</param>
|
||||
public StaleMediaTask(ILogger<StaleMediaTask> logger, ILibraryManager libraryManager)
|
||||
public StaleMediaScanner(ILogger<StaleMediaScanner> logger, ILibraryManager libraryManager)
|
||||
{
|
||||
_logger = logger;
|
||||
_libraryManager = libraryManager;
|
||||
@@ -47,18 +49,7 @@ public sealed class StaleMediaTask : IScheduledTask
|
||||
_seriesHelper = new SeriesHelper(_logger);
|
||||
}
|
||||
|
||||
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)
|
||||
public async Task<IEnumerable<MediaInfo>> ScanStaleMedia()
|
||||
{
|
||||
_loggingHelper.LogDebugInformation("--DEBUG MODE ACTIVE--");
|
||||
_loggingHelper.LogInformation("-------------------------------------------------");
|
||||
@@ -98,13 +89,15 @@ public sealed class StaleMediaTask : IScheduledTask
|
||||
_loggingHelper.LogInformation("-------------------------------------------------");
|
||||
_loggingHelper.LogInformation("Stale seasons found: {StaleSeasons}", staleSeasons.Count);
|
||||
|
||||
IEnumerable<MediaInfo> staleSeriesInfo = [];
|
||||
|
||||
if (staleSeasons.Count > 0)
|
||||
{
|
||||
IEnumerable<SeriesInfo> staleSeriesInfo = FindSeriesInfo(staleSeasons);
|
||||
staleSeriesInfo = FindSeriesInfo(staleSeasons);
|
||||
|
||||
foreach (var seriesInfo in staleSeriesInfo)
|
||||
foreach (SeriesInfo seriesInfo in staleSeriesInfo.Cast<SeriesInfo>())
|
||||
{
|
||||
_loggingHelper.LogInformation("Series Info: ID: {Id} | Series Name: {SeriesName} | Stale Seasons: {Seasons}", [seriesInfo.Id, seriesInfo.SeriesName, string.Join(", ", seriesInfo.Seasons)]);
|
||||
_loggingHelper.LogInformation("Series Info: ID: {Id} | Series Name: {SeriesName} | Stale Seasons: {Seasons}", [seriesInfo.Id, seriesInfo.Name, string.Join(", ", seriesInfo.Seasons)]);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -115,9 +108,17 @@ public sealed class StaleMediaTask : IScheduledTask
|
||||
_loggingHelper.LogInformation("-------------------------------------------------");
|
||||
_loggingHelper.LogInformation("Stale Movies found: {StaleMovies}", staleMovies.Count);
|
||||
|
||||
IEnumerable<MediaInfo> staleMoviesInfo = [];
|
||||
|
||||
if (staleMovies.Count > 0)
|
||||
{
|
||||
foreach (var movieInfo in staleMovies)
|
||||
staleMoviesInfo = staleMovies.Select(movie => new MovieInfo
|
||||
{
|
||||
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]);
|
||||
}
|
||||
@@ -131,7 +132,9 @@ public sealed class StaleMediaTask : IScheduledTask
|
||||
_loggingHelper.LogInformation("Ending stale media scan...");
|
||||
_loggingHelper.LogInformation("-------------------------------------------------");
|
||||
|
||||
return Task.CompletedTask;
|
||||
IEnumerable<MediaInfo> mediaInfo = staleSeriesInfo.Concat(staleMoviesInfo);
|
||||
|
||||
return mediaInfo;
|
||||
}
|
||||
|
||||
private List<BaseItem> GetStaleMovies(List<BaseItem> movies)
|
||||
@@ -198,7 +201,7 @@ public sealed class StaleMediaTask : IScheduledTask
|
||||
return staleSeasons;
|
||||
}
|
||||
|
||||
private IEnumerable<SeriesInfo> FindSeriesInfo(IReadOnlyCollection<BaseItem> seasons)
|
||||
private IEnumerable<MediaInfo> FindSeriesInfo(IReadOnlyCollection<BaseItem> seasons)
|
||||
{
|
||||
Guid[] seriesIds = [.. seasons.Select(season => season.ParentId).Distinct()];
|
||||
|
||||
@@ -212,22 +215,11 @@ public sealed class StaleMediaTask : IScheduledTask
|
||||
return new SeriesInfo
|
||||
{
|
||||
Id = series.Id,
|
||||
SeriesName = series.Name,
|
||||
Name = 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
|
||||
// Unnecessary, and will be removed once front end page is ready.
|
||||
yield return new TaskTriggerInfo
|
||||
{
|
||||
Type = TaskTriggerInfoType.IntervalTrigger,
|
||||
IntervalTicks = TimeSpan.FromHours(24).Ticks
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user