diff --git a/src/Ombi.Core/Engine/RecentlyAddedEngine.cs b/src/Ombi.Core/Engine/RecentlyAddedEngine.cs index b8cc0ee6b..aab5ea607 100644 --- a/src/Ombi.Core/Engine/RecentlyAddedEngine.cs +++ b/src/Ombi.Core/Engine/RecentlyAddedEngine.cs @@ -40,8 +40,8 @@ namespace Ombi.Core.Engine public IEnumerable GetRecentlyAddedTv(DateTime from, DateTime to, bool groupBySeason) { - var plexTv = _plex.GetAll().Where(x => x.Type == PlexMediaTypeEntity.Show && x.AddedAt > from && x.AddedAt < to); - var embyTv = _emby.GetAll().Where(x => x.Type == EmbyMediaType.Series && x.AddedAt > from && x.AddedAt < to); + var plexTv = _plex.GetAll().Include(x => x.Seasons).Include(x => x.Episodes).Where(x => x.Type == PlexMediaTypeEntity.Show && x.AddedAt > from && x.AddedAt < to); + var embyTv = _emby.GetAll().Include(x => x.Episodes).Where(x => x.Type == EmbyMediaType.Series && x.AddedAt > from && x.AddedAt < to); return GetRecentlyAddedTv(plexTv, embyTv, groupBySeason).Take(30); } @@ -49,8 +49,8 @@ namespace Ombi.Core.Engine public IEnumerable GetRecentlyAddedTv(bool groupBySeason) { - var plexTv = _plex.GetAll().Where(x => x.Type == PlexMediaTypeEntity.Show); - var embyTv = _emby.GetAll().Where(x => x.Type == EmbyMediaType.Series); + var plexTv = _plex.GetAll().Include(x => x.Seasons).Include(x => x.Episodes).Where(x => x.Type == PlexMediaTypeEntity.Show); + var embyTv = _emby.GetAll().Include(x => x.Episodes).Where(x => x.Type == EmbyMediaType.Series); return GetRecentlyAddedTv(plexTv, embyTv, groupBySeason); } diff --git a/src/Ombi/ClientApp/app/interfaces/IRecentlyAdded.ts b/src/Ombi/ClientApp/app/interfaces/IRecentlyAdded.ts index 357a70d8b..e3b62b333 100644 --- a/src/Ombi/ClientApp/app/interfaces/IRecentlyAdded.ts +++ b/src/Ombi/ClientApp/app/interfaces/IRecentlyAdded.ts @@ -15,6 +15,7 @@ export interface IRecentlyAddedMovies { export interface IRecentlyAddedTvShows extends IRecentlyAddedMovies { seasonNumber: number; episodeNumber: number; + tvDbId: number; } export interface IRecentlyAddedRangeModel { diff --git a/src/Ombi/ClientApp/app/recentlyAdded/recentlyAdded.component.html b/src/Ombi/ClientApp/app/recentlyAdded/recentlyAdded.component.html index f9234f4a4..ee60b7c87 100644 --- a/src/Ombi/ClientApp/app/recentlyAdded/recentlyAdded.component.html +++ b/src/Ombi/ClientApp/app/recentlyAdded/recentlyAdded.component.html @@ -1,13 +1,31 @@

Recently Added

- +

- + - poster - {{movie.title}} +
+ poster +
{{movie.title}}
+
+ +
@@ -22,6 +40,10 @@ poster {{t.title}} +
+ Season: {{t.seasonNumber}} +
+ Episode: {{t.episodeNumber}}
diff --git a/src/Ombi/ClientApp/app/recentlyAdded/recentlyAdded.component.ts b/src/Ombi/ClientApp/app/recentlyAdded/recentlyAdded.component.ts index d540a6b2d..c5c09f814 100644 --- a/src/Ombi/ClientApp/app/recentlyAdded/recentlyAdded.component.ts +++ b/src/Ombi/ClientApp/app/recentlyAdded/recentlyAdded.component.ts @@ -39,6 +39,8 @@ export class RecentlyAddedComponent implements OnInit { public movies: IRecentlyAddedMovies[]; public tv: IRecentlyAddedTvShows[]; public range: Date[]; + + public groupTv: boolean; // https://github.com/sheikalthaf/ngu-carousel public carouselTile: NguCarousel; @@ -74,25 +76,33 @@ export class RecentlyAddedComponent implements OnInit { } this.getMovies(); } + + public change() { + this.getShows(); + } private getShows() { - this.recentlyAddedService.getRecentlyAddedTv().subscribe(x => { - this.tv = x; - - this.tv.forEach((t) => { - if(t.theMovieDbId) { - this.imageService.getTvPoster(t.imdbId).subscribe(p => { - t.posterPath = p; + if(this.groupTv) { + this.recentlyAddedService.getRecentlyAddedTvGrouped().subscribe(x => { + this.tv = x; + + this.tv.forEach((t) => { + this.imageService.getTvPoster(t.tvDbId).subscribe(p => { + t.posterPath = p; + }); }); - } else if(t.imdbId) { - this.imageService.getMoviePoster(t.imdbId).subscribe(p => { + }); + } else { + this.recentlyAddedService.getRecentlyAddedTv().subscribe(x => { + this.tv = x; + + this.tv.forEach((t) => { + this.imageService.getTvPoster(t.tvDbId).subscribe(p => { t.posterPath = p; }); - } else { - t.posterPath = ""; - } + }); }); - }); + } } private getMovies() { diff --git a/src/Ombi/Controllers/ImagesController.cs b/src/Ombi/Controllers/ImagesController.cs index 2cee60476..9e85f0d56 100644 --- a/src/Ombi/Controllers/ImagesController.cs +++ b/src/Ombi/Controllers/ImagesController.cs @@ -44,11 +44,15 @@ namespace Ombi.Controllers } if (images.tvbanner != null) { - return images.tvbanner.FirstOrDefault()?.url ?? string.Empty; + var enImage = images.tvbanner.Where(x => x.lang == "en").OrderByDescending(x => x.likes).Select(x => x.url).FirstOrDefault(); + if (enImage == null) + { + return images.tvbanner.OrderByDescending(x => x.likes).Select(x => x.url).FirstOrDefault(); + } } - if (images.showbackground != null) + if (images.seasonposter != null) { - return images.showbackground.FirstOrDefault()?.url ?? string.Empty; + return images.seasonposter.FirstOrDefault()?.url ?? string.Empty; } return string.Empty; } @@ -97,7 +101,12 @@ namespace Ombi.Controllers if (images.tvposter?.Any() ?? false) { - return images.tvposter.OrderBy(x => x.likes).Select(x => x.url).FirstOrDefault(); + var enImage = images.tvposter.Where(x => x.lang == "en").OrderByDescending(x => x.likes).Select(x => x.url).FirstOrDefault(); + if (enImage == null) + { + return images.tvposter.OrderByDescending(x => x.likes).Select(x => x.url).FirstOrDefault(); + } + return enImage; } if (images.tvthumb?.Any() ?? false)