Compare commits
9 Commits
b6242de064
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| dbc7325e85 | |||
| 1de8e31468 | |||
| a10769779a | |||
| c860141f5e | |||
| ddb3433bef | |||
| 3f5b59b0bd | |||
| d5b97e0bf3 | |||
| de94fbd7ec | |||
| 98dfd51d3e |
@@ -1,5 +1,5 @@
|
|||||||
<Project>
|
<Project>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<AssemblyVersion>0.0.0.12</AssemblyVersion>
|
<AssemblyVersion>0.1.1.1</AssemblyVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -32,7 +32,11 @@ public class StateController(MediaCleanerState state) : Controller
|
|||||||
public IActionResult GetMovieInfo() => Ok(_state.GetMovieInfo());
|
public IActionResult GetMovieInfo() => Ok(_state.GetMovieInfo());
|
||||||
|
|
||||||
[HttpGet("updateState")]
|
[HttpGet("updateState")]
|
||||||
public IActionResult GetUpdateState() => Ok(_state.UpdateState());
|
public async Task<IActionResult> GetUpdateState()
|
||||||
|
{
|
||||||
|
await _state.UpdateState().ConfigureAwait(false);
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
|
||||||
[HttpGet("getMoviesTitle")]
|
[HttpGet("getMoviesTitle")]
|
||||||
public IActionResult GetMoviesTitle() =>
|
public IActionResult GetMoviesTitle() =>
|
||||||
|
|||||||
@@ -11,28 +11,50 @@ using System.Net.Http;
|
|||||||
using System;
|
using System;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using MediaBrowser.Model.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace Jellyfin.Plugin.MediaCleaner.Data;
|
namespace Jellyfin.Plugin.MediaCleaner.Data;
|
||||||
|
|
||||||
public class MediaCleanerState(ILogger<StaleMediaScanner> logger, ILibraryManager libraryManager)
|
public class MediaCleanerState(ILogger<StaleMediaScanner> logger, ILibraryManager libraryManager, ITaskManager taskManager)
|
||||||
{
|
{
|
||||||
private readonly Lock _lock = new();
|
private readonly Lock _lock = new();
|
||||||
private IEnumerable<MediaInfo> _mediaInfo = [];
|
private IEnumerable<MediaInfo> _mediaInfo = [];
|
||||||
private readonly StaleMediaScanner _staleMediaScanner = new(logger, libraryManager);
|
private readonly StaleMediaScanner _staleMediaScanner = new(logger, libraryManager);
|
||||||
|
// private readonly ILibraryManager _libraryManager = libraryManager;
|
||||||
|
private readonly ITaskManager _taskManager = taskManager;
|
||||||
|
|
||||||
public async Task UpdateState()
|
public async Task UpdateState()
|
||||||
{
|
{
|
||||||
|
// First re-scan library and then scan for stale media.
|
||||||
|
IScheduledTaskWorker? refreshLibraryWorker = _taskManager.ScheduledTasks.FirstOrDefault(task => task.ScheduledTask.Key == "RefreshLibrary");
|
||||||
|
|
||||||
|
if(refreshLibraryWorker != null)
|
||||||
|
{
|
||||||
|
await _taskManager.Execute(refreshLibraryWorker, new TaskOptions()).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
_mediaInfo = await _staleMediaScanner.ScanStaleMedia().ConfigureAwait(false);
|
_mediaInfo = await _staleMediaScanner.ScanStaleMedia().ConfigureAwait(false);
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<SeriesInfo>> GetTvSeriesInfo()
|
public async Task<IEnumerable<SeriesInfo>> GetTvSeriesInfo()
|
||||||
{
|
{
|
||||||
// Filter only TV
|
// Filter only TV
|
||||||
// Get all series on tv sonarr server
|
// Get all series on tv sonarr server
|
||||||
HttpHelper tvHttpHelper = new HttpHelper(ServerType.Sonarr);
|
HttpHelper httpHelper = new HttpHelper(ServerType.Sonarr);
|
||||||
var tvSeriesResponse = await tvHttpHelper.SendHttpRequestAsync(HttpMethod.Get,"/api/v3/series").ConfigureAwait(false);
|
JsonElement tvSeriesResponse = new JsonElement();
|
||||||
var tvSeries = JsonSerializer.Deserialize<IEnumerable<SonarrSeries>>(tvSeriesResponse.GetRawText());
|
try
|
||||||
|
{
|
||||||
|
tvSeriesResponse = await httpHelper.SendHttpRequestAsync(HttpMethod.Get,"/api/v3/series").ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
var tvSeries = JsonSerializer.Deserialize<IEnumerable<SonarrSeries>>(tvSeriesResponse.GetRawText());
|
||||||
if(tvSeries == null)
|
if(tvSeries == null)
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
@@ -53,7 +75,16 @@ public class MediaCleanerState(ILogger<StaleMediaScanner> logger, ILibraryManage
|
|||||||
{
|
{
|
||||||
// Get all series on anime sonarr server
|
// Get all series on anime sonarr server
|
||||||
HttpHelper animeHttpHelper = new HttpHelper(ServerType.SonarrAnime);
|
HttpHelper animeHttpHelper = new HttpHelper(ServerType.SonarrAnime);
|
||||||
var animeSeriesResponse = await animeHttpHelper.SendHttpRequestAsync(HttpMethod.Get,"/api/v3/series").ConfigureAwait(false);
|
JsonElement animeSeriesResponse = new JsonElement();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
animeSeriesResponse = await animeHttpHelper.SendHttpRequestAsync(HttpMethod.Get,"/api/v3/series").ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
var animeSeries = JsonSerializer.Deserialize<List<SonarrSeries>>(animeSeriesResponse.GetRawText());
|
var animeSeries = JsonSerializer.Deserialize<List<SonarrSeries>>(animeSeriesResponse.GetRawText());
|
||||||
|
|
||||||
if(animeSeries == null)
|
if(animeSeries == null)
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Diagnostics.CodeAnalysis;
|
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Jellyfin.Plugin.MediaCleaner.Enums;
|
using Jellyfin.Plugin.MediaCleaner.Enums;
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace Jellyfin.Plugin.MediaCleaner.Helpers;
|
namespace Jellyfin.Plugin.MediaCleaner.Helpers;
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<div data-role="content">
|
<div data-role="content">
|
||||||
<div class="content-primary">
|
<div class="content-primary">
|
||||||
<link rel="stylesheet" href="/web/configurationpage?name=global.css" />
|
<link rel="stylesheet" href="/web/configurationpage?name=global.css" />
|
||||||
<div id="loading">Loading...</div>
|
<div id="loading">Loading... This may take some time whilst we scan your library and retrieve data from Radarr and Sonarr to accurately fill tables.</div>
|
||||||
<div id="homepage" style="visibility: hidden;">
|
<div id="homepage" style="visibility: hidden;">
|
||||||
<button class="links" data-target="configurationpage?name=Configuration">Configuration</button>
|
<button class="links" data-target="configurationpage?name=Configuration">Configuration</button>
|
||||||
<h2>Media Cleaner</h2>
|
<h2>Media Cleaner</h2>
|
||||||
|
|||||||
@@ -56,8 +56,6 @@ const updateMediaCleanerState = async () => {
|
|||||||
if(!response.ok){
|
if(!response.ok){
|
||||||
throw new Error(`Response status: ${response.status}`)
|
throw new Error(`Response status: ${response.status}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
return response.json();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getMediaCleanerAnimeSeriesTitle = async () => {
|
const getMediaCleanerAnimeSeriesTitle = async () => {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ Planned features:
|
|||||||
- Better logging to show more than just the count. ✅
|
- Better logging to show more than just the count. ✅
|
||||||
- A page that shows what media is currently flagged for removal. ✅
|
- A page that shows what media is currently flagged for removal. ✅
|
||||||
- Checkboxes to select media for removal within Jellyfin. ✅
|
- Checkboxes to select media for removal within Jellyfin. ✅
|
||||||
- Integration with sonarr and radarr apis to delete your media.
|
- Integration with sonarr and radarr apis to delete your media. ✅
|
||||||
- Whitelist for shows to ignore. (Seasonal shows)
|
- Whitelist for shows to ignore. (Seasonal shows)
|
||||||
|
|
||||||
Future features if I feel like it:
|
Future features if I feel like it:
|
||||||
|
|||||||
Reference in New Issue
Block a user