Update README.md

This commit is contained in:
2026-03-23 00:18:34 -07:00
parent c698879cda
commit 1dbeb724fc
7 changed files with 146 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
using Jellyfin.Plugin.NewReleases.Models;
using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
namespace Jellyfin.Plugin.NewReleases.Services;
public sealed class NewReleasesService
{
private const int DefaultMaxItems = 20;
private const int DefaultReleaseWindowDays = 365;
private readonly ILibraryManager _libraryManager;
public NewReleasesService(ILibraryManager libraryManager)
{
_libraryManager = libraryManager;
}
public NewReleasesResponse GetNewlyReleasedMovies()
{
var configuration = Plugin.Instance?.Configuration ?? new PluginConfiguration();
var maxItems = configuration.MaxItems > 0 ? configuration.MaxItems : DefaultMaxItems;
var releaseWindowDays = configuration.ReleaseWindowDays > 0 ? configuration.ReleaseWindowDays : DefaultReleaseWindowDays;
var cutoffUtc = DateTime.UtcNow.AddDays(-releaseWindowDays);
var query = new InternalItemsQuery
{
IncludeItemTypes = [BaseItemKind.Movie],
Recursive = true
};
var items = _libraryManager.GetItemList(query)
.Where(x => x.PremiereDate.HasValue)
.Where(x => x.PremiereDate!.Value.ToUniversalTime() >= cutoffUtc)
.OrderByDescending(x => x.PremiereDate!.Value)
.Take(maxItems)
.Select(x => new NewReleaseMovieDto
{
Id = x.Id.ToString("N"),
Name = x.Name,
PremiereDate = x.PremiereDate!.Value.ToUniversalTime()
})
.ToList();
return new NewReleasesResponse
{
TotalRecordCount = items.Count,
Items = items
};
}
}