mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 02:26:55 -07:00
Added recently added stuff
This commit is contained in:
parent
109f5317bb
commit
ee50eb79b7
5 changed files with 60 additions and 4 deletions
12
src/Ombi.Core/Engine/IRecentlyAddedEngine.cs
Normal file
12
src/Ombi.Core/Engine/IRecentlyAddedEngine.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Ombi.Core.Models;
|
||||
|
||||
namespace Ombi.Core.Engine
|
||||
{
|
||||
public interface IRecentlyAddedEngine
|
||||
{
|
||||
IEnumerable<RecentlyAddedMovieModel> GetRecentlyAddedMovies();
|
||||
IEnumerable<RecentlyAddedMovieModel> GetRecentlyAddedMovies(DateTime from, DateTime to);
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@ using Ombi.Store.Repository;
|
|||
|
||||
namespace Ombi.Core.Engine
|
||||
{
|
||||
public class RecentlyAddedEngine
|
||||
public class RecentlyAddedEngine : IRecentlyAddedEngine
|
||||
{
|
||||
public RecentlyAddedEngine(IPlexContentRepository plex, IEmbyContentRepository emby)
|
||||
{
|
||||
|
@ -22,11 +22,11 @@ namespace Ombi.Core.Engine
|
|||
private readonly IPlexContentRepository _plex;
|
||||
private readonly IEmbyContentRepository _emby;
|
||||
|
||||
public IEnumerable<RecentlyAddedMovieModel> GetRecentlyAddedMovies(TimeSpan from)
|
||||
public IEnumerable<RecentlyAddedMovieModel> GetRecentlyAddedMovies(DateTime from, DateTime to)
|
||||
{
|
||||
var model = new HashSet<RecentlyAddedMovieModel>();
|
||||
var plexMovies = _plex.GetAll().Where(x => x.Type == PlexMediaTypeEntity.Movie && x.AddedAt.Subtract(from) <= x.AddedAt);
|
||||
var embyMovies = _emby.GetAll().Where(x => x.Type == EmbyMediaType.Movie && x.AddedAt.Subtract(from) <= x.AddedAt);
|
||||
var plexMovies = _plex.GetAll().Where(x => x.Type == PlexMediaTypeEntity.Movie && x.AddedAt > from && x.AddedAt < to);
|
||||
var embyMovies = _emby.GetAll().Where(x => x.Type == EmbyMediaType.Movie && x.AddedAt > from && x.AddedAt < to);
|
||||
|
||||
TransformPlexMovies(plexMovies, model);
|
||||
TransformEmbyMovies(embyMovies, model);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue