Added a similar button to the movie searches. Makes movie discoverablility easier

pull/2020/head
tidusjar 7 years ago
parent 58e658262e
commit c47cc7f8f2

@ -17,5 +17,7 @@ namespace Ombi.Core
Task<IEnumerable<SearchMovieViewModel>> UpcomingMovies(); Task<IEnumerable<SearchMovieViewModel>> UpcomingMovies();
Task<SearchMovieViewModel> LookupImdbInformation(int theMovieDbId); Task<SearchMovieViewModel> LookupImdbInformation(int theMovieDbId);
Task<IEnumerable<SearchMovieViewModel>> SimilarMovies(int theMovieDbId);
} }
} }

@ -63,6 +63,22 @@ namespace Ombi.Core.Engine
return null; return null;
} }
/// <summary>
/// Get similar movies to the id passed in
/// </summary>
/// <param name="theMovieDbId"></param>
/// <returns></returns>
public async Task<IEnumerable<SearchMovieViewModel>> SimilarMovies(int theMovieDbId)
{
var result = await MovieApi.SimilarMovies(theMovieDbId);
if (result != null)
{
Logger.LogDebug("Search Result: {result}", result);
return await TransformMovieResultsToResponse(result.Take(10)); // Take 10 to stop us overloading the API
}
return null;
}
/// <summary> /// <summary>
/// Gets popular movies. /// Gets popular movies.
/// </summary> /// </summary>

@ -14,5 +14,6 @@ namespace Ombi.Api.TheMovieDb
Task<List<MovieSearchResult>> SearchMovie(string searchTerm); Task<List<MovieSearchResult>> SearchMovie(string searchTerm);
Task<List<MovieSearchResult>> TopRated(); Task<List<MovieSearchResult>> TopRated();
Task<List<MovieSearchResult>> Upcoming(); Task<List<MovieSearchResult>> Upcoming();
Task<List<MovieSearchResult>> SimilarMovies(int movieId);
} }
} }

@ -30,6 +30,15 @@ namespace Ombi.Api.TheMovieDb
return Mapper.Map<MovieResponseDto>(result); return Mapper.Map<MovieResponseDto>(result);
} }
public async Task<List<MovieSearchResult>> SimilarMovies(int movieId)
{
var request = new Request($"movie/{movieId}/similar", BaseUri, HttpMethod.Get);
request.FullUri = request.FullUri.AddQueryParameter("api_key", ApiToken);
var result = await Api.Request<TheMovieDbContainer<SearchResult>>(request);
return Mapper.Map<List<MovieSearchResult>>(result.results);
}
public async Task<MovieResponseDto> GetMovieInformationWithExtraInfo(int movieId) public async Task<MovieResponseDto> GetMovieInformationWithExtraInfo(int movieId)
{ {
var request = new Request($"movie/{movieId}", BaseUri, HttpMethod.Get); var request = new Request($"movie/{movieId}", BaseUri, HttpMethod.Get);

@ -41,9 +41,9 @@
<a href="https://www.themoviedb.org/movie/{{result.id}}/" target="_blank"> <a href="https://www.themoviedb.org/movie/{{result.id}}/" target="_blank">
<h4>{{result.title}} ({{result.releaseDate | date: 'yyyy'}})</h4> <h4>{{result.title}} ({{result.releaseDate | date: 'yyyy'}})</h4>
</a> </a>
<span class="tags"> <span class="tags">
<span *ngIf="result.releaseDate" class="label label-info" id="releaseDateLabel" target="_blank">{{ 'Search.TheatricalRelease' | translate: {date: result.releaseDate | date: 'mediumDate'} }}</span> <span *ngIf="result.releaseDate" class="label label-info" id="releaseDateLabel" target="_blank">{{ 'Search.TheatricalRelease' | translate: {date: result.releaseDate | date: 'mediumDate'} }}</span>
<span *ngIf="result.digitalReleaseDate" class="label label-info" id="releaseDateLabel" target="_blank">{{ 'Search.DigitalDate' | translate: {date: result.digitalReleaseDate | date: 'mediumDate'} }}</span> <span *ngIf="result.digitalReleaseDate" class="label label-info" id="releaseDateLabel" target="_blank">{{ 'Search.DigitalDate' | translate: {date: result.digitalReleaseDate | date: 'mediumDate'} }}</span>
<a *ngIf="result.homepage" href="{{result.homepage}}" id="homePageLabel" target="_blank"><span class="label label-info" [translate]="'Search.Movies.HomePage'"></span></a> <a *ngIf="result.homepage" href="{{result.homepage}}" id="homePageLabel" target="_blank"><span class="label label-info" [translate]="'Search.Movies.HomePage'"></span></a>
@ -80,7 +80,8 @@
<i *ngIf="result.processed && !result.requestProcessing" class="fa fa-check"></i>{{ 'Common.Request' | translate }}</button> <i *ngIf="result.processed && !result.requestProcessing" class="fa fa-check"></i>{{ 'Common.Request' | translate }}</button>
</ng-template> </ng-template>
</div> </div>
<button style="text-align: right" class="btn btn-sm btn-info-outline" (click)="similarMovies(result.id)"> <i class="fa fa-eye"></i> {{ 'Search.Similar' | translate }}</button>
<br/> <br/>
<div *ngIf="result.available"> <div *ngIf="result.available">
<a *ngIf="result.plexUrl" style="text-align: right" class="btn btn-sm btn-success-outline" href="{{result.plexUrl}}" target="_blank"><i class="fa fa-eye"></i> View On Plex</a> <a *ngIf="result.plexUrl" style="text-align: right" class="btn btn-sm btn-success-outline" href="{{result.plexUrl}}" target="_blank"><i class="fa fa-eye"></i> View On Plex</a>

@ -146,6 +146,15 @@ export class MovieSearchComponent implements OnInit {
this.issueProviderId = req.id.toString(); this.issueProviderId = req.id.toString();
} }
public similarMovies(theMovieDbId: number) {
this.clearResults();
this.searchService.similarMovies(theMovieDbId)
.subscribe(x => {
this.movieResults = x;
this.getExtraInfo();
});
}
private getExtraInfo() { private getExtraInfo() {
this.movieResults.forEach((val, index) => { this.movieResults.forEach((val, index) => {

@ -19,6 +19,9 @@ export class SearchService extends ServiceHelpers {
public searchMovie(searchTerm: string): Observable<ISearchMovieResult[]> { public searchMovie(searchTerm: string): Observable<ISearchMovieResult[]> {
return this.http.get<ISearchMovieResult[]>(`${this.url}/Movie/` + searchTerm); return this.http.get<ISearchMovieResult[]>(`${this.url}/Movie/` + searchTerm);
} }
public similarMovies(theMovieDbId: number): Observable<ISearchMovieResult[]> {
return this.http.get<ISearchMovieResult[]>(`${this.url}/Movie/${theMovieDbId}/similar`);
}
public popularMovies(): Observable<ISearchMovieResult[]> { public popularMovies(): Observable<ISearchMovieResult[]> {
return this.http.get<ISearchMovieResult[]>(`${this.url}/Movie/Popular`); return this.http.get<ISearchMovieResult[]>(`${this.url}/Movie/Popular`);

@ -61,6 +61,19 @@ namespace Ombi.Controllers
return await MovieEngine.LookupImdbInformation(theMovieDbId); return await MovieEngine.LookupImdbInformation(theMovieDbId);
} }
/// <summary>
/// Returns similar movies to the movie id passed in
/// </summary>
/// <param name="theMovieDbId">ID of the movie</param>
/// <remarks>
/// We use TheMovieDb as the Movie Provider
/// </remarks>
[HttpGet("movie/{theMovieDbId}/similar")]
public async Task<IEnumerable<SearchMovieViewModel>> SimilarMovies(int theMovieDbId)
{
return await MovieEngine.SimilarMovies(theMovieDbId);
}
/// <summary> /// <summary>
/// Returns Popular Movies /// Returns Popular Movies
/// </summary> /// </summary>

@ -81,6 +81,7 @@
"TheatricalRelease":"Theatrical Release: {{date}}", "TheatricalRelease":"Theatrical Release: {{date}}",
"ViewOnPlex": "View On Plex", "ViewOnPlex": "View On Plex",
"RequestAdded": "Request for {{title}} has been added successfully", "RequestAdded": "Request for {{title}} has been added successfully",
"Similar":"Similar",
"Movies": { "Movies": {
"PopularMovies": "Popular Movies", "PopularMovies": "Popular Movies",
"UpcomingMovies": "Upcoming Movies", "UpcomingMovies": "Upcoming Movies",

Loading…
Cancel
Save