Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Knocking out LC requirements in issue #2124 #2125

Merged
merged 16 commits into from
Apr 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/Ombi.Core/Engine/TvRequestEngine.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using AutoMapper;
using Ombi.Api.TvMaze;
using Ombi.Api.TheMovieDb;
using Ombi.Core.Models.Requests;
using Ombi.Core.Models.Search;
using Ombi.Helpers;
Expand All @@ -26,11 +27,12 @@ namespace Ombi.Core.Engine
{
public class TvRequestEngine : BaseMediaEngine, ITvRequestEngine
{
public TvRequestEngine(ITvMazeApi tvApi, IRequestServiceMain requestService, IPrincipal user,
public TvRequestEngine(ITvMazeApi tvApi, IMovieDbApi movApi, IRequestServiceMain requestService, IPrincipal user,
INotificationHelper helper, IRuleEvaluator rule, OmbiUserManager manager,
ITvSender sender, IAuditRepository audit, IRepository<RequestLog> rl, ISettingsService<OmbiSettings> settings, ICacheService cache) : base(user, requestService, rule, manager, cache, settings)
{
TvApi = tvApi;
MovieDbApi = movApi;
NotificationHelper = helper;
TvSender = sender;
Audit = audit;
Expand All @@ -39,6 +41,7 @@ public TvRequestEngine(ITvMazeApi tvApi, IRequestServiceMain requestService, IPr

private INotificationHelper NotificationHelper { get; }
private ITvMazeApi TvApi { get; }
private IMovieDbApi MovieDbApi { get; }
private ITvSender TvSender { get; }
private IAuditRepository Audit { get; }
private readonly IRepository<RequestLog> _requestLog;
Expand All @@ -47,7 +50,7 @@ public async Task<RequestEngineResult> RequestTvShow(TvRequestViewModel tv)
{
var user = await GetUser();

var tvBuilder = new TvShowRequestBuilder(TvApi);
var tvBuilder = new TvShowRequestBuilder(TvApi, MovieDbApi);
(await tvBuilder
.GetShowInfo(tv.TvDbId))
.CreateTvList(tv)
Expand Down
16 changes: 15 additions & 1 deletion src/Ombi.Core/Helpers/TvShowRequestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
using System.Linq;
using System.Threading.Tasks;
using Ombi.Api.TvMaze;
using Ombi.Api.TheMovieDb;
using Ombi.Api.TvMaze.Models;
using Ombi.Api.TheMovieDb.Models;
using Ombi.Core.Models.Requests;
using Ombi.Core.Models.Search;
using Ombi.Helpers;
Expand All @@ -16,23 +18,35 @@ namespace Ombi.Core.Helpers
public class TvShowRequestBuilder
{

public TvShowRequestBuilder(ITvMazeApi tvApi)
public TvShowRequestBuilder(ITvMazeApi tvApi, IMovieDbApi movApi)
{
TvApi = tvApi;
MovieDbApi = movApi;
}

private ITvMazeApi TvApi { get; }
private IMovieDbApi MovieDbApi { get; }

public ChildRequests ChildRequest { get; set; }
public List<SeasonsViewModel> TvRequests { get; protected set; }
public string PosterPath { get; protected set; }
public DateTime FirstAir { get; protected set; }
public TvRequests NewRequest { get; protected set; }
protected TvMazeShow ShowInfo { get; set; }
protected List<TvSearchResult> Results { get; set; }

public async Task<TvShowRequestBuilder> GetShowInfo(int id)
{
ShowInfo = await TvApi.ShowLookupByTheTvDbId(id);
Results = await MovieDbApi.SearchTv(ShowInfo.name);
foreach (TvSearchResult result in Results) {
if (result.Name == ShowInfo.name)
{
var showIds = await MovieDbApi.GetTvExternals(result.Id);
ShowInfo.externals.imdb = showIds.imdb_id;
break;
}
}

DateTime.TryParse(ShowInfo.premiered, out var dt);

Expand Down
13 changes: 13 additions & 0 deletions src/Ombi.Mapping/Profiles/MovieProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ public MovieProfile()
.ForMember(dest => dest.VoteAverage, opts => opts.MapFrom(src => src.vote_average))
.ForMember(dest => dest.VoteCount, opts => opts.MapFrom(src => src.vote_count));

CreateMap<SearchResult, TvSearchResult>()
.ForMember(dest => dest.BackdropPath, opts => opts.MapFrom(src => src.backdrop_path))
.ForMember(dest => dest.Id, opts => opts.MapFrom(src => src.id))
.ForMember(dest => dest.OriginalLanguage, opts => opts.MapFrom(src => src.original_language))
.ForMember(dest => dest.OriginalName, opts => opts.MapFrom(src => src.original_name))
.ForMember(dest => dest.Overview, opts => opts.MapFrom(src => src.overview))
.ForMember(dest => dest.Popularity, opts => opts.MapFrom(src => src.popularity))
.ForMember(dest => dest.PosterPath, opts => opts.MapFrom(src => src.poster_path))
.ForMember(dest => dest.ReleaseDate, opts => opts.MapFrom(src => src.first_air_date))
.ForMember(dest => dest.Name, opts => opts.MapFrom(src => src.name))
.ForMember(dest => dest.VoteAverage, opts => opts.MapFrom(src => src.vote_average))
.ForMember(dest => dest.VoteCount, opts => opts.MapFrom(src => src.vote_count));

CreateMap<MovieResponse, MovieResponseDto>()
.ForMember(dest => dest.Adult, opts => opts.MapFrom(src => src.adult))
.ForMember(dest => dest.BackdropPath, opts => opts.MapFrom(src => src.backdrop_path))
Expand Down
1 change: 1 addition & 0 deletions src/Ombi.TheMovieDbApi/IMovieDbApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public interface IMovieDbApi
Task<List<MovieSearchResult>> NowPlaying();
Task<List<MovieSearchResult>> PopularMovies();
Task<List<MovieSearchResult>> SearchMovie(string searchTerm);
Task<List<TvSearchResult>> SearchTv(string searchTerm);
Task<List<MovieSearchResult>> TopRated();
Task<List<MovieSearchResult>> Upcoming();
Task<List<MovieSearchResult>> SimilarMovies(int movieId);
Expand Down
3 changes: 3 additions & 0 deletions src/Ombi.TheMovieDbApi/Models/SearchResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ public class SearchResult
public bool adult { get; set; }
public string overview { get; set; }
public string release_date { get; set; }
public string first_air_date { get; set; }
public int?[] genre_ids { get; set; }
public int id { get; set; }
public string original_title { get; set; }
public string original_name { get; set; }
public string name { get; set; }
public string original_language { get; set; }
public string title { get; set; }
public string backdrop_path { get; set; }
Expand Down
18 changes: 18 additions & 0 deletions src/Ombi.TheMovieDbApi/Models/TvSearchResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace Ombi.Api.TheMovieDb.Models
{
public class TvSearchResult
{
public string PosterPath { get; set; }
public string Overview { get; set; }
public string ReleaseDate { get; set; }
public int?[] GenreIds { get; set; }
public int Id { get; set; }
public string OriginalName { get; set; }
public string OriginalLanguage { get; set; }
public string Name { get; set; }
public string BackdropPath { get; set; }
public float Popularity { get; set; }
public int VoteCount { get; set; }
public float VoteAverage { get; set; }
}
}
13 changes: 12 additions & 1 deletion src/Ombi.TheMovieDbApi/TheMovieDbApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,18 @@ public async Task<FindResult> Find(string externalId, ExternalSource source)

return await Api.Request<FindResult>(request);
}


public async Task<List<TvSearchResult>> SearchTv(string searchTerm)
{
var request = new Request($"search/tv", BaseUri, HttpMethod.Get);
request.FullUri = request.FullUri.AddQueryParameter("api_key", ApiToken);
request.FullUri = request.FullUri.AddQueryParameter("query", searchTerm);
AddRetry(request);

var result = await Api.Request<TheMovieDbContainer<SearchResult>>(request);
return Mapper.Map<List<TvSearchResult>>(result.results);
}

public async Task<TvExternals> GetTvExternals(int theMovieDbId)
{
var request = new Request($"/tv/{theMovieDbId}/external_ids", BaseUri, HttpMethod.Get);
Expand Down
2 changes: 1 addition & 1 deletion src/Ombi/ClientApp/app/issues/issueDetails.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div *ngIf="issue">
<div class="row">
<div class="row issue-details">
<div class="myBg backdrop" [style.background-image]="backgroundPath"></div>
<div class="tint" style="background-image: linear-gradient(to bottom, rgba(0,0,0,0.6) 0%,rgba(0,0,0,0.6) 100%);"></div>
<h1>{{issue.title}} </h1>
Expand Down
12 changes: 10 additions & 2 deletions src/Ombi/ClientApp/app/issues/issueDetails.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ export class IssueDetailsComponent implements OnInit {
("url(" + x + ")");
});
this.imageService.getMoviePoster(issue.providerId).subscribe(x => {
this.posterPath = x.toString();
if (x.length === 0) {
this.posterPath = "../../../images/default_movie_poster.png";
} else {
this.posterPath = x.toString();
}
});

} else {
Expand All @@ -107,7 +111,11 @@ export class IssueDetailsComponent implements OnInit {
("url(" + x + ")");
});
this.imageService.getTvPoster(Number(issue.providerId)).subscribe(x => {
this.posterPath = x.toString();
if (x.length === 0) {
this.posterPath = "../../../images/default_tv_poster.png";
} else {
this.posterPath = x.toString();
}
});
}

Expand Down
8 changes: 4 additions & 4 deletions src/Ombi/ClientApp/app/issues/issuestable.component.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
<table class="table table-striped table-hover table-responsive table-condensed">
<thead>
<tr>
<th (click)="setOrder('title')">
<th (click)="setOrder('title', $event)">
<a [translate]="'Issues.ColumnTitle'"></a>
<span *ngIf="order === 'title'">
<span [hidden]="reverse"><i class="fa fa-arrow-down" aria-hidden="true"></i></span><span [hidden]="!reverse"><i class="fa fa-arrow-up" aria-hidden="true"></i></span>
</span>
</th>
<th (click)="setOrder('issueCategory.value')">
<th (click)="setOrder('issueCategory.value', $event)">
<a [translate]="'Issues.Category'"></a>
<span *ngIf="order === 'issueCategory.value'">
<span [hidden]="reverse"><i class="fa fa-arrow-down" aria-hidden="true"></i></span><span [hidden]="!reverse"><i class="fa fa-arrow-up" aria-hidden="true"></i></span>
</span>
</th>
<th (click)="setOrder('status')">
<th (click)="setOrder('status', $event)">
<a [translate]="'Issues.Status'"></a>
<span *ngIf="order === 'status'">
<span [hidden]="reverse"><i class="fa fa-arrow-down" aria-hidden="true"></i></span><span [hidden]="!reverse"><i class="fa fa-arrow-up" aria-hidden="true"></i></span>
</span>
</th>
<th (click)="setOrder('reportedUser')">
<th (click)="setOrder('reportedUser', $event)">
<a [translate]="'Issues.ReportedBy'"></a>
<span *ngIf="order === 'reportedUser'">
<span [hidden]="reverse"><i class="fa fa-arrow-down" aria-hidden="true"></i></span><span [hidden]="!reverse"><i class="fa fa-arrow-up" aria-hidden="true"></i></span>
Expand Down
20 changes: 17 additions & 3 deletions src/Ombi/ClientApp/app/issues/issuestable.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,25 @@ export class IssuesTableComponent {

public rowCount = 10;

public setOrder(value: string) {
public setOrder(value: string, el: any) {
el = el.toElement || el.relatedTarget || el.target || el.srcElement;

if (el.nodeName === "A") {
el = el.parentElement;
}

const parent = el.parentElement;
const previousFilter = parent.querySelector(".active");

if (this.order === value) {
this.reverse = !this.reverse;
this.reverse = !this.reverse;
} else {
if (previousFilter) {
previousFilter.className = "";
}
el.className = "active";
}

this.order = value;
}

Expand Down
61 changes: 31 additions & 30 deletions src/Ombi/ClientApp/app/requests/movierequests.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<div class="tint" style="background-image: linear-gradient(to bottom, rgba(0,0,0,0.6) 0%,rgba(0,0,0,0.6) 100%);"></div>
<div class="col-sm-2 small-padding">

<img class="img-responsive poster" src="https://image.tmdb.org/t/p/w300/{{request.posterPath}}" alt="poster">
<img class="img-responsive poster" src="{{request.posterPath}}" alt="poster">

</div>

Expand Down Expand Up @@ -222,42 +222,43 @@ <h4 class="request-title">{{request.title}} ({{request.releaseDate | date: 'yyyy
<p-sidebar [(visible)]="filterDisplay" styleClass="ui-sidebar-md side-back side-small">
<h3>{{ 'Requests.Filter' | translate }}</h3>
<hr>

<h4>{{ 'Filter.FilterHeaderAvailability' | translate }}</h4>
<div class="form-group">
<div class="radio">
<input type="radio" id="Available" name="Availability" (click)="filterAvailability(filterType.Available)">
<label for="Available">{{ 'Common.Available' | translate }}</label>
<div>
<h4>{{ 'Filter.FilterHeaderAvailability' | translate }}</h4>
<div class="form-group">
<div class="radio">
<input type="radio" id="Available" name="Availability" (click)="filterAvailability(filterType.Available, $event)">
<label for="Available">{{ 'Common.Available' | translate }}</label>
</div>
</div>
</div>
<div class="form-group">
<div class="radio">
<input type="radio" id="notAvailable" name="Availability" (click)="filterAvailability(filterType.NotAvailable)">
<label for="notAvailable">{{ 'Common.NotAvailable' | translate }}</label>
<div class="form-group">
<div class="radio">
<input type="radio" id="notAvailable" name="Availability" (click)="filterAvailability(filterType.NotAvailable, $event)">
<label for="notAvailable">{{ 'Common.NotAvailable' | translate }}</label>
</div>
</div>
</div>

<h4>{{ 'Filter.FilterHeaderRequestStatus' | translate }}</h4>
<div class="form-group">
<div class="radio">
<input type="radio" id="approved" name="Status" (click)="filterStatus(filterType.Approved)">
<label for="approved">{{ 'Filter.Approved' | translate }}</label>
<div>
<h4>{{ 'Filter.FilterHeaderRequestStatus' | translate }}</h4>
<div class="form-group">
<div class="radio">
<input type="radio" id="approved" name="Status" (click)="filterStatus(filterType.Approved, $event)">
<label for="approved">{{ 'Filter.Approved' | translate }}</label>
</div>
</div>
</div>
<div class="form-group">
<div class="radio">
<input type="radio" id="Processing" name="Status" (click)="filterStatus(filterType.Processing)">
<label for="Processing">{{ 'Common.ProcessingRequest' | translate }}</label>
<div class="form-group">
<div class="radio">
<input type="radio" id="Processing" name="Status" (click)="filterStatus(filterType.Processing, $event)">
<label for="Processing">{{ 'Common.ProcessingRequest' | translate }}</label>
</div>
</div>
</div>
<div class="form-group">
<div class="radio">
<input type="radio" id="pendingApproval" name="Status" (click)="filterStatus(filterType.PendingApproval, $event)">
<label for="pendingApproval">{{ 'Filter.PendingApproval' | translate }}</label>
<div class="form-group">
<div class="radio">
<input type="radio" id="pendingApproval" name="Status" (click)="filterStatus(filterType.PendingApproval, $event)">
<label for="pendingApproval">{{ 'Filter.PendingApproval' | translate }}</label>
</div>
</div>
</div>


<button class="btn btn-sm btn-primary-outline" (click)="clearFilter()">
<button class="btn btn-sm btn-primary-outline" (click)="clearFilter($event)">
<i class="fa fa-filter"></i> {{ 'Filter.ClearFilter' | translate }}</button>
</p-sidebar>
Loading