Merge branch 'feature/recently-added' into feature_recentlyAdded

pull/2089/head
Jamie 7 years ago committed by GitHub
commit ffe74de278
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -41,8 +41,8 @@ namespace Ombi.Core.Engine
public IEnumerable<RecentlyAddedTvModel> GetRecentlyAddedTv(DateTime from, DateTime to, bool groupBySeason) public IEnumerable<RecentlyAddedTvModel> GetRecentlyAddedTv(DateTime from, DateTime to, bool groupBySeason)
{ {
var plexTv = _plex.GetAll().Where(x => x.Type == PlexMediaTypeEntity.Show && 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().Where(x => x.Type == EmbyMediaType.Series && 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); return GetRecentlyAddedTv(plexTv, embyTv, groupBySeason).Take(30);
} }
@ -50,8 +50,8 @@ namespace Ombi.Core.Engine
public IEnumerable<RecentlyAddedTvModel> GetRecentlyAddedTv(bool groupBySeason) public IEnumerable<RecentlyAddedTvModel> GetRecentlyAddedTv(bool groupBySeason)
{ {
var plexTv = _plex.GetAll().Where(x => x.Type == PlexMediaTypeEntity.Show); var plexTv = _plex.GetAll().Include(x => x.Seasons).Include(x => x.Episodes).Where(x => x.Type == PlexMediaTypeEntity.Show);
var embyTv = _emby.GetAll().Where(x => x.Type == EmbyMediaType.Series); var embyTv = _emby.GetAll().Include(x => x.Episodes).Where(x => x.Type == EmbyMediaType.Series);
return GetRecentlyAddedTv(plexTv, embyTv, groupBySeason); return GetRecentlyAddedTv(plexTv, embyTv, groupBySeason);
} }

@ -15,6 +15,7 @@ export interface IRecentlyAddedMovies {
export interface IRecentlyAddedTvShows extends IRecentlyAddedMovies { export interface IRecentlyAddedTvShows extends IRecentlyAddedMovies {
seasonNumber: number; seasonNumber: number;
episodeNumber: number; episodeNumber: number;
tvDbId: number;
} }
export interface IRecentlyAddedRangeModel { export interface IRecentlyAddedRangeModel {

@ -1,13 +1,31 @@
<h1>Recently Added</h1> <h1>Recently Added</h1>
<input type="checkbox" [(ngModel)]="groupTv" (click)="change()" />
<hr /> <hr />
<p-calendar [(ngModel)]="range" showButtonBar="true" selectionMode="range" (onClose)="close()"></p-calendar> <p-calendar [(ngModel)]="range" showButtonBar="true" selectionMode="range" (onClose)="close()"></p-calendar>
<hr /> <hr />
<style>
.img-conatiner {
position: relative;
text-align: center;
color: white;
}
/* Bottom left text */
.bottom-left {
position: absolute;
bottom: 8px;
left: 16px;
}
</style>
<ngu-carousel [inputs]="carouselTile"> <ngu-carousel [inputs]="carouselTile">
<ngu-tile NguCarouselItem *ngFor="let movie of movies"> <ngu-tile NguCarouselItem *ngFor="let movie of movies">
<img class="img-responsive poster" src="{{movie.posterPath}}" style="width: 300px" alt="poster"> <div class="img-container">
<b>{{movie.title}}</b> <img class="img-responsive poster" src="{{movie.posterPath}}" style="width: 300px" alt="poster">
<div class="bottom-left"> {{movie.title}}</div>
</div>
</ngu-tile> </ngu-tile>
<button NguCarouselPrev class='leftRs'><i class="fa fa-arrow-left"></i></button> <button NguCarouselPrev class='leftRs'><i class="fa fa-arrow-left"></i></button>
@ -22,6 +40,10 @@
<ngu-tile NguCarouselItem *ngFor="let t of tv"> <ngu-tile NguCarouselItem *ngFor="let t of tv">
<img class="img-responsive poster" src="{{t.posterPath}}" style="width: 300px" alt="poster"> <img class="img-responsive poster" src="{{t.posterPath}}" style="width: 300px" alt="poster">
<b>{{t.title}}</b> <b>{{t.title}}</b>
<br>
<b>Season: {{t.seasonNumber}}</b>
<br>
<b>Episode: {{t.episodeNumber}}</b>
</ngu-tile> </ngu-tile>
<button NguCarouselPrev class='leftRs'><i class="fa fa-arrow-left"></i></button> <button NguCarouselPrev class='leftRs'><i class="fa fa-arrow-left"></i></button>

@ -40,6 +40,8 @@ export class RecentlyAddedComponent implements OnInit {
public tv: IRecentlyAddedTvShows[]; public tv: IRecentlyAddedTvShows[];
public range: Date[]; public range: Date[];
public groupTv: boolean;
// https://github.com/sheikalthaf/ngu-carousel // https://github.com/sheikalthaf/ngu-carousel
public carouselTile: NguCarousel; public carouselTile: NguCarousel;
@ -75,24 +77,32 @@ export class RecentlyAddedComponent implements OnInit {
this.getMovies(); this.getMovies();
} }
public change() {
this.getShows();
}
private getShows() { private getShows() {
this.recentlyAddedService.getRecentlyAddedTv().subscribe(x => { if(this.groupTv) {
this.tv = x; this.recentlyAddedService.getRecentlyAddedTvGrouped().subscribe(x => {
this.tv = x;
//this.tv.forEach((t) => {
// if(t.theMovieDbId) { this.tv.forEach((t) => {
// this.imageService.getTvPoster(t.imdbId).subscribe(p => { this.imageService.getTvPoster(t.tvDbId).subscribe(p => {
// t.posterPath = p; t.posterPath = p;
// }); });
// } else if(t.imdbId) { });
// this.imageService.getMoviePoster(t.imdbId).subscribe(p => { });
// t.posterPath = p; } else {
// }); this.recentlyAddedService.getRecentlyAddedTv().subscribe(x => {
// } else { this.tv = x;
// t.posterPath = "";
// } this.tv.forEach((t) => {
//}); this.imageService.getTvPoster(t.tvDbId).subscribe(p => {
}); t.posterPath = p;
});
});
});
}
} }
private getMovies() { private getMovies() {

@ -44,11 +44,15 @@ namespace Ombi.Controllers
} }
if (images.tvbanner != null) 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; return string.Empty;
} }
@ -97,7 +101,12 @@ namespace Ombi.Controllers
if (images.tvposter?.Any() ?? false) 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) if (images.tvthumb?.Any() ?? false)

Loading…
Cancel
Save