Compare commits
2 Commits
v0.0.1-alp
...
v0.0.2-alp
| Author | SHA1 | Date | |
|---|---|---|---|
| 08747baf51 | |||
| 41c28f095f |
@@ -1,7 +1,5 @@
|
|||||||
<Project>
|
<Project>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Version>0.0.0.1</Version>
|
<AssemblyVersion>0.0.0.2</AssemblyVersion>
|
||||||
<AssemblyVersion>0.0.0.1</AssemblyVersion>
|
</PropertyGroup>
|
||||||
<FileVersion>0.0.0.1</FileVersion>
|
|
||||||
</PropertyGroup>
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net9.0</TargetFramework>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
<RootNamespace>Jellyfin.Plugin.MediaCleaner</RootNamespace>
|
<RootNamespace>Jellyfin.Plugin.MediaCleaner</RootNamespace>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
|
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
|
||||||
@@ -19,15 +19,30 @@
|
|||||||
</PackageReference>
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="SerilogAnalyzer" Version="0.15.0" PrivateAssets="All" />
|
|
||||||
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556" PrivateAssets="All" />
|
|
||||||
<PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Remove="Configuration\configPage.html" />
|
<None Remove="Configuration\configPage.html" />
|
||||||
<EmbeddedResource Include="Configuration\configPage.html" />
|
<EmbeddedResource Include="Configuration\configPage.html" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<Timestamp>$([System.DateTime]::UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ"))</Timestamp>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<Target Name="GeneratePluginJson" BeforeTargets="Publish">
|
||||||
|
<WriteLinesToFile
|
||||||
|
File="$(PublishDir)\meta.json"
|
||||||
|
Lines='{
|
||||||
|
"guid": "fef007a8-3e8f-4aa8-a22e-486a387f4192",
|
||||||
|
"name": "Media Cleaner",
|
||||||
|
"category": "Library",
|
||||||
|
"overview": "A cleaner for your stale media.",
|
||||||
|
"description": "Clean out the stale media from your library using scheduled tasks",
|
||||||
|
"timestamp": "$(PluginTimestamp)",
|
||||||
|
"targetAbi": "10.11.0",
|
||||||
|
"owner": "T-Gander",
|
||||||
|
"version": "$(Version)"
|
||||||
|
}'
|
||||||
|
Overwrite="true"
|
||||||
|
Encoding="utf-8" />
|
||||||
|
</Target>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
30
Jellyfin.Plugin.MediaCleaner/Models/SeriesInfo.cs
Normal file
30
Jellyfin.Plugin.MediaCleaner/Models/SeriesInfo.cs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
|
||||||
|
namespace Jellyfin.Plugin.MediaCleaner.Models;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Contains series information.
|
||||||
|
/// </summary>
|
||||||
|
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>
|
||||||
|
#pragma warning disable CA2227 // Collection properties should be read only
|
||||||
|
#pragma warning disable CA1002 // Do not expose generic lists
|
||||||
|
public List<string> Seasons { get; set; } = [];
|
||||||
|
#pragma warning restore CA1002 // Do not expose generic lists
|
||||||
|
#pragma warning restore CA2227 // Collection properties should be read only
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Data.Common;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection.Metadata.Ecma335;
|
using System.Reflection.Metadata.Ecma335;
|
||||||
@@ -10,6 +11,7 @@ using Jellyfin.Data.Enums;
|
|||||||
using Jellyfin.Database.Implementations.Entities;
|
using Jellyfin.Database.Implementations.Entities;
|
||||||
using Jellyfin.Database.Implementations.Entities.Libraries;
|
using Jellyfin.Database.Implementations.Entities.Libraries;
|
||||||
using Jellyfin.Plugin.MediaCleaner.Configuration;
|
using Jellyfin.Plugin.MediaCleaner.Configuration;
|
||||||
|
using Jellyfin.Plugin.MediaCleaner.Models;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Model.Tasks;
|
using MediaBrowser.Model.Tasks;
|
||||||
@@ -77,8 +79,12 @@ public sealed class StaleMediaTask : IScheduledTask
|
|||||||
if (staleEpisodes.Count > 0)
|
if (staleEpisodes.Count > 0)
|
||||||
{
|
{
|
||||||
// Firstly figure out the seasons, and then the Series to find the name.
|
// Firstly figure out the seasons, and then the Series to find the name.
|
||||||
List<string> seriesNames = FindDistinctSeriesNamesFromEpisodes(staleEpisodes);
|
List<SeriesInfo> seriesInfoList = FindSeriesInfoFromEpisodes(staleEpisodes);
|
||||||
_logger.LogInformation("Series: {Names}", string.Join(", ", seriesNames));
|
|
||||||
|
foreach (var seriesInfo in seriesInfoList)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Series Info: ID: {Id} | Series Name: {SeriesName} | Stale Seasons: {Seasons}", [seriesInfo.Id, seriesInfo.SeriesName, string.Join(", ", seriesInfo.Seasons)]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
@@ -99,7 +105,7 @@ public sealed class StaleMediaTask : IScheduledTask
|
|||||||
return staleMovies;
|
return staleMovies;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<string> FindDistinctSeriesNamesFromEpisodes(List<BaseItem> episodes)
|
private List<SeriesInfo> FindSeriesInfoFromEpisodes(List<BaseItem> episodes)
|
||||||
{
|
{
|
||||||
Guid[] seasonIds = [.. episodes.Select(episode => episode.ParentId).Distinct()];
|
Guid[] seasonIds = [.. episodes.Select(episode => episode.ParentId).Distinct()];
|
||||||
|
|
||||||
@@ -113,11 +119,24 @@ public sealed class StaleMediaTask : IScheduledTask
|
|||||||
var series = _libraryManager.GetItemList(new InternalItemsQuery
|
var series = _libraryManager.GetItemList(new InternalItemsQuery
|
||||||
{
|
{
|
||||||
ItemIds = seriesIds
|
ItemIds = seriesIds
|
||||||
});
|
}).ToList();
|
||||||
|
|
||||||
|
// Series Id, Series Name and Stale Seasons
|
||||||
List<string> seriesNames = [.. series.Select(series => series.Name).Distinct()];
|
List<string> seriesNames = [.. series.Select(series => series.Name).Distinct()];
|
||||||
|
|
||||||
return seriesNames;
|
List<SeriesInfo> seriesInfoList = [];
|
||||||
|
|
||||||
|
series.ForEach(series =>
|
||||||
|
{
|
||||||
|
seriesInfoList.Add(new SeriesInfo
|
||||||
|
{
|
||||||
|
Id = series.Id,
|
||||||
|
SeriesName = series.Name,
|
||||||
|
Seasons = [.. seasons.Where(season => season.ParentId == series.Id).Select(season => season.Name)]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return seriesInfoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<BaseItem> GetStaleEpisodes(BaseItem item)
|
private List<BaseItem> GetStaleEpisodes(BaseItem item)
|
||||||
|
|||||||
Reference in New Issue
Block a user