mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-12 08:16:05 -07:00
Added Actor Searching for Movies!
This commit is contained in:
parent
a6b733e954
commit
76bfec1667
9 changed files with 96 additions and 50 deletions
|
@ -41,7 +41,7 @@ namespace Ombi.Api
|
|||
{
|
||||
if (!request.IgnoreErrors)
|
||||
{
|
||||
LogError(request, httpResponseMessage);
|
||||
await LogError(request, httpResponseMessage);
|
||||
}
|
||||
|
||||
if (request.Retry)
|
||||
|
@ -105,7 +105,7 @@ namespace Ombi.Api
|
|||
{
|
||||
if (!request.IgnoreErrors)
|
||||
{
|
||||
LogError(request, httpResponseMessage);
|
||||
await LogError(request, httpResponseMessage);
|
||||
}
|
||||
}
|
||||
// do something with the response
|
||||
|
@ -126,7 +126,7 @@ namespace Ombi.Api
|
|||
{
|
||||
if (!request.IgnoreErrors)
|
||||
{
|
||||
LogError(request, httpResponseMessage);
|
||||
await LogError(request, httpResponseMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -149,10 +149,15 @@ namespace Ombi.Api
|
|||
}
|
||||
}
|
||||
|
||||
private void LogError(Request request, HttpResponseMessage httpResponseMessage)
|
||||
private async Task LogError(Request request, HttpResponseMessage httpResponseMessage)
|
||||
{
|
||||
Logger.LogError(LoggingEvents.Api,
|
||||
$"StatusCode: {httpResponseMessage.StatusCode}, Reason: {httpResponseMessage.ReasonPhrase}, RequestUri: {request.FullUri}");
|
||||
if (Logger.IsEnabled(LogLevel.Debug))
|
||||
{
|
||||
var content = await httpResponseMessage.Content.ReadAsStringAsync();
|
||||
Logger.LogDebug(content);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -197,15 +197,16 @@ namespace Ombi.Core.Engine
|
|||
|
||||
private async Task<SearchMovieViewModel> ProcessSingleMovie(SearchMovieViewModel viewMovie, bool lookupExtraInfo = false)
|
||||
{
|
||||
if (lookupExtraInfo)
|
||||
if (lookupExtraInfo && viewMovie.ImdbId.IsNullOrEmpty())
|
||||
{
|
||||
var showInfo = await MovieApi.GetMovieInformation(viewMovie.Id);
|
||||
viewMovie.Id = showInfo.Id; // TheMovieDbId
|
||||
viewMovie.ImdbId = showInfo.ImdbId;
|
||||
var usDates = viewMovie.ReleaseDates?.Results?.FirstOrDefault(x => x.IsoCode == "US");
|
||||
viewMovie.DigitalReleaseDate = usDates?.ReleaseDate?.FirstOrDefault(x => x.Type == ReleaseDateType.Digital)?.ReleaseDate;
|
||||
}
|
||||
|
||||
var usDates = viewMovie.ReleaseDates?.Results?.FirstOrDefault(x => x.IsoCode == "US");
|
||||
viewMovie.DigitalReleaseDate = usDates?.ReleaseDate?.FirstOrDefault(x => x.Type == ReleaseDateType.Digital)?.ReleaseDate;
|
||||
|
||||
viewMovie.TheMovieDbId = viewMovie.Id.ToString();
|
||||
|
||||
await RunSearchRules(viewMovie);
|
||||
|
|
|
@ -66,5 +66,10 @@ namespace Ombi.Store.Context
|
|||
|
||||
SaveChanges();
|
||||
}
|
||||
|
||||
~SettingsContext()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -56,9 +56,8 @@ namespace Ombi.Api.TheMovieDb
|
|||
|
||||
public async Task<ActorCredits> GetActorMovieCredits(int actorId, string langCode)
|
||||
{
|
||||
var request = new Request($"search/person", BaseUri, HttpMethod.Get);
|
||||
var request = new Request($"person/{actorId}/movie_credits", BaseUri, HttpMethod.Get);
|
||||
request.FullUri = request.FullUri.AddQueryParameter("api_key", ApiToken);
|
||||
request.FullUri = request.FullUri.AddQueryParameter("person_id", actorId.ToString());
|
||||
request.FullUri = request.FullUri.AddQueryParameter("language", langCode);
|
||||
|
||||
var result = await Api.Request<ActorCredits>(request);
|
||||
|
|
|
@ -23,17 +23,11 @@ export class RemainingRequestsComponent implements OnInit {
|
|||
}
|
||||
|
||||
public ngOnInit() {
|
||||
const self = this;
|
||||
|
||||
this.update();
|
||||
|
||||
this.quotaRefreshEvents.subscribe(() => {
|
||||
this.quotaRefreshEvents.subscribe(() => {
|
||||
this.update();
|
||||
});
|
||||
|
||||
setInterval(() => {
|
||||
self.update();
|
||||
}, 60000);
|
||||
}
|
||||
|
||||
public update(): void {
|
||||
|
@ -43,7 +37,6 @@ export class RemainingRequestsComponent implements OnInit {
|
|||
this.calculateTime();
|
||||
}
|
||||
});
|
||||
|
||||
if (this.movie) {
|
||||
this.requestService.getRemainingMovieRequests().subscribe(callback);
|
||||
}
|
||||
|
|
|
@ -27,28 +27,35 @@
|
|||
</div>
|
||||
<!-- Refine search options -->
|
||||
<div class="row top-spacing form-group vcenter" *ngIf="refineSearchEnabled">
|
||||
<div class="col-md-1">
|
||||
<div class="form-group">
|
||||
<label class="control-label">Year</label>
|
||||
|
||||
<input [(ngModel)]="searchYear" class="form-control form-control-custom refine-option">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-1">
|
||||
<div class="form-group">
|
||||
<label class="control-label">Year</label>
|
||||
|
||||
<!-- <label for="name" class="col-xs-2 col-md-1">Language:</label> -->
|
||||
<div class="col-md-2">
|
||||
<div class="form-group">
|
||||
<label for="select" class="control-label">Language</label>
|
||||
<div id="profiles">
|
||||
<select [(ngModel)]="selectedLanguage" class="form-control form-control-custom refine-option"
|
||||
id="select">
|
||||
<option *ngFor="let lang of langauges" value="{{lang.code}}">{{lang.nativeName}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input [(ngModel)]="searchYear" class="form-control form-control-custom refine-option">
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
</div>
|
||||
|
||||
<!-- <label for="name" class="col-xs-2 col-md-1">Language:</label> -->
|
||||
<div class="col-md-2">
|
||||
<div class="form-group">
|
||||
<label for="select" class="control-label">Language</label>
|
||||
<div id="profiles">
|
||||
<select [(ngModel)]="selectedLanguage" class="form-control form-control-custom refine-option" id="select">
|
||||
<option *ngFor="let lang of langauges" value="{{lang.code}}">{{lang.nativeName}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-2">
|
||||
<div class="form-group">
|
||||
<div class="checkbox">
|
||||
<input type="checkbox" id="actorSearch" name="actorSearch" [(ngModel)]="actorSearch">
|
||||
<label for="actorSearch" tooltipPosition="top" pTooltip="Search for movies by actor">Actor Search</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-7">
|
||||
<button class="btn pull-right btn-success-outline" (click)="applyRefinedSearch()">Apply</button>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -70,7 +77,8 @@
|
|||
<div class="myBg backdrop" [style.background-image]="result.background"></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>
|
||||
<div class="col-sm-2 small-padding">
|
||||
<img *ngIf="result.posterPath" class="img-responsive poster movie-poster" src="{{result.posterPath}}" alt="poster">
|
||||
<img *ngIf="result.posterPath" class="img-responsive poster movie-poster" src="{{result.posterPath}}"
|
||||
alt="poster">
|
||||
|
||||
</div>
|
||||
<div class="col-sm-8 small-padding">
|
||||
|
|
|
@ -27,6 +27,7 @@ export class MovieSearchComponent implements OnInit {
|
|||
public searchApplied = false;
|
||||
public refineSearchEnabled = false;
|
||||
public searchYear?: number;
|
||||
public actorSearch: boolean;
|
||||
public selectedLanguage: string;
|
||||
public langauges: ILanguageRefine[];
|
||||
|
||||
|
@ -204,7 +205,7 @@ export class MovieSearchComponent implements OnInit {
|
|||
}
|
||||
val.background = this.sanitizer.bypassSecurityTrustStyle
|
||||
("url(" + "https://image.tmdb.org/t/p/w1280" + val.backdropPath + ")");
|
||||
|
||||
|
||||
if (this.applyRefinedSearch) {
|
||||
this.searchService.getMovieInformationWithRefined(val.id, this.selectedLanguage)
|
||||
.subscribe(m => {
|
||||
|
@ -212,9 +213,9 @@ export class MovieSearchComponent implements OnInit {
|
|||
});
|
||||
} else {
|
||||
this.searchService.getMovieInformation(val.id)
|
||||
.subscribe(m => {
|
||||
this.updateItem(val, m);
|
||||
});
|
||||
.subscribe(m => {
|
||||
this.updateItem(val, m);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -239,14 +240,25 @@ export class MovieSearchComponent implements OnInit {
|
|||
return;
|
||||
}
|
||||
if (this.refineOpen) {
|
||||
this.searchService.searchMovieWithRefined(this.searchText, this.searchYear, this.selectedLanguage)
|
||||
.subscribe(x => {
|
||||
this.movieResults = x;
|
||||
this.searchApplied = true;
|
||||
// Now let's load some extra info including IMDB Id
|
||||
// This way the search is fast at displaying results.
|
||||
this.getExtraInfo();
|
||||
});
|
||||
if (!this.actorSearch) {
|
||||
this.searchService.searchMovieWithRefined(this.searchText, this.searchYear, this.selectedLanguage)
|
||||
.subscribe(x => {
|
||||
this.movieResults = x;
|
||||
this.searchApplied = true;
|
||||
// Now let's load some extra info including IMDB Id
|
||||
// This way the search is fast at displaying results.
|
||||
this.getExtraInfo();
|
||||
});
|
||||
} else {
|
||||
this.searchService.searchMovieByActor(this.searchText, this.selectedLanguage)
|
||||
.subscribe(x => {
|
||||
this.movieResults = x;
|
||||
this.searchApplied = true;
|
||||
// Now let's load some extra info including IMDB Id
|
||||
// This way the search is fast at displaying results.
|
||||
this.getExtraInfo();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
this.searchService.searchMovie(this.searchText)
|
||||
.subscribe(x => {
|
||||
|
|
|
@ -49,6 +49,10 @@ export class SearchService extends ServiceHelpers {
|
|||
return this.http.post<ISearchMovieResult>(`${this.url}/Movie/info`, { theMovieDbId, languageCode: langCode });
|
||||
}
|
||||
|
||||
public searchMovieByActor(searchTerm: string, langCode: string): Observable<ISearchMovieResult[]> {
|
||||
return this.http.post<ISearchMovieResult[]>(`${this.url}/Movie/Actor`, { searchTerm, languageCode: langCode });
|
||||
}
|
||||
|
||||
// TV
|
||||
public searchTv(searchTerm: string): Observable<ISearchTvResult[]> {
|
||||
return this.http.get<ISearchTvResult[]>(`${this.url}/Tv/${searchTerm}`, { headers: this.headers });
|
||||
|
|
|
@ -51,6 +51,25 @@ namespace Ombi.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Searches for movies by a certain actor.
|
||||
/// </summary>
|
||||
/// <param name="model">The refinement model, language code and year are both optional. Language code uses ISO 639-1</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("movie/actor")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesDefaultResponseType]
|
||||
public async Task<IActionResult> SearchActor([FromBody] SearchMovieRefineModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
return Json(await MovieEngine.SearchActor(model.SearchTerm, model.LanguageCode));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Searches for a movie.
|
||||
/// </summary>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue