Added more API's for getting Keyword Results and Movie Collections

pull/3895/head
TidusJar 6 years ago
parent 09144aa080
commit dc570d2e2c

@ -8,6 +8,7 @@ namespace Ombi.Core.Models.Search.V2
public class MovieFullInfoViewModel : SearchViewModel public class MovieFullInfoViewModel : SearchViewModel
{ {
public bool Adult { get; set; } public bool Adult { get; set; }
public CollectionsViewModel BelongsToCollection { get; set; }
public string BackdropPath { get; set; } public string BackdropPath { get; set; }
public string OriginalLanguage { get; set; } public string OriginalLanguage { get; set; }
public int Budget { get; set; } public int Budget { get; set; }
@ -41,6 +42,13 @@ namespace Ombi.Core.Models.Search.V2
public ExternalIds ExternalIds { get; set; } public ExternalIds ExternalIds { get; set; }
} }
public class CollectionsViewModel
{
public int Id { get; set; }
public string Name { get; set; }
public string PosterPath { get; set; }
public string BackdropPath { get; set; }
}
public class ExternalIds public class ExternalIds
{ {
public string ImdbId { get; set; } public string ImdbId { get; set; }

@ -86,6 +86,7 @@ namespace Ombi.Mapping.Profiles
CreateMap<Ombi.Api.TheMovieDb.Models.FullMovieCast, Ombi.Core.Models.Search.V2.FullMovieCastViewModel>().ReverseMap(); CreateMap<Ombi.Api.TheMovieDb.Models.FullMovieCast, Ombi.Core.Models.Search.V2.FullMovieCastViewModel>().ReverseMap();
CreateMap<Ombi.Api.TheMovieDb.Models.FullMovieCrew, Ombi.Core.Models.Search.V2.FullMovieCrewViewModel>().ReverseMap(); CreateMap<Ombi.Api.TheMovieDb.Models.FullMovieCrew, Ombi.Core.Models.Search.V2.FullMovieCrewViewModel>().ReverseMap();
CreateMap<Ombi.Api.TheMovieDb.Models.ExternalIds, Ombi.Core.Models.Search.V2.ExternalIds>().ReverseMap(); CreateMap<Ombi.Api.TheMovieDb.Models.ExternalIds, Ombi.Core.Models.Search.V2.ExternalIds>().ReverseMap();
CreateMap<BelongsToCollection, Ombi.Core.Models.Search.V2.CollectionsViewModel>().ReverseMap();
} }
} }
} }

@ -23,5 +23,7 @@ namespace Ombi.Api.TheMovieDb
Task<ActorCredits> GetActorMovieCredits(int actorId, string langCode); Task<ActorCredits> GetActorMovieCredits(int actorId, string langCode);
Task<TheMovieDbContainer<MultiSearch>> MultiSearch(string searchTerm, string languageCode); Task<TheMovieDbContainer<MultiSearch>> MultiSearch(string searchTerm, string languageCode);
Task<FullMovieInfo> GetFullMovieInfo(int movieId, string langCode); Task<FullMovieInfo> GetFullMovieInfo(int movieId, string langCode);
Task<TheMovieDbContainer<DiscoverMovies>> DiscoverMovies(string langCode, int keywordId);
Task<Collections> GetCollection(string langCode, int collectionId);
} }
} }

@ -1,10 +1,16 @@
namespace Ombi.TheMovieDbApi.Models using Newtonsoft.Json;
namespace Ombi.TheMovieDbApi.Models
{ {
public class BelongsToCollection public class BelongsToCollection
{ {
public int id { get; set; } [JsonProperty("id")]
public string name { get; set; } public int Id { get; set; }
public string poster_path { get; set; } [JsonProperty("name")]
public string backdrop_path { get; set; } public string Name { get; set; }
[JsonProperty("poster_path")]
public string PosterPath { get; set; }
[JsonProperty("backdrop_path")]
public string BackdropPath { get; set; }
} }
} }

@ -0,0 +1,31 @@
namespace Ombi.Api.TheMovieDb.Models
{
public class Collections
{
public int id { get; set; }
public string name { get; set; }
public string overview { get; set; }
public string poster_path { get; set; }
public string backdrop_path { get; set; }
public Part[] parts { get; set; }
}
public class Part
{
public bool adult { get; set; }
public string backdrop_path { get; set; }
public int[] genre_ids { get; set; }
public int id { get; set; }
public string original_language { get; set; }
public string original_title { get; set; }
public string overview { get; set; }
public string poster_path { get; set; }
public string release_date { get; set; }
public string title { get; set; }
public bool video { get; set; }
public float vote_average { get; set; }
public int vote_count { get; set; }
public float popularity { get; set; }
}
}

@ -0,0 +1,21 @@
namespace Ombi.Api.TheMovieDb.Models
public class DiscoverMovies
{
public int vote_count { get; set; }
public int id { get; set; }
public bool video { get; set; }
public float vote_average { get; set; }
public string title { get; set; }
public float popularity { get; set; }
public string poster_path { get; set; }
public string original_language { get; set; }
public string original_title { get; set; }
public int[] genre_ids { get; set; }
public string backdrop_path { get; set; }
public bool adult { get; set; }
public string overview { get; set; }
public string release_date { get; set; }
}
}

@ -1,4 +1,4 @@
using System; using System.Collections.Generic;
using Newtonsoft.Json; using Newtonsoft.Json;
using Ombi.TheMovieDbApi.Models; using Ombi.TheMovieDbApi.Models;
@ -10,6 +10,8 @@ namespace Ombi.Api.TheMovieDb.Models
public bool Adult { get; set; } public bool Adult { get; set; }
[JsonProperty("backdrop_path")] [JsonProperty("backdrop_path")]
public string BackdropPath { get; set; } public string BackdropPath { get; set; }
[JsonProperty("belongs_to_collection")]
public BelongsToCollection Collecion { get; set; }
[JsonProperty("budget")] [JsonProperty("budget")]
public int Budget { get; set; } public int Budget { get; set; }
[JsonProperty("genres")] [JsonProperty("genres")]
@ -66,6 +68,20 @@ namespace Ombi.Api.TheMovieDb.Models
public ReleaseDates ReleaseDates { get; set; } public ReleaseDates ReleaseDates { get; set; }
[JsonProperty("external_ids")] [JsonProperty("external_ids")]
public ExternalIds ExternalIds { get; set; } public ExternalIds ExternalIds { get; set; }
[JsonProperty("keywords")]
public Keywords Keywords { get; set; }
}
public class Keywords
{
[JsonProperty("keywords")]
public List<KeywordsValue> KeywordsValue { get; set; }
}
public class KeywordsValue
{
public int Id { get; set; }
public string Name { get; set; }
} }
public class Videos public class Videos

@ -4,7 +4,6 @@ using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using AutoMapper; using AutoMapper;
using Ombi.Api.TheMovieDb.Models; using Ombi.Api.TheMovieDb.Models;
using Ombi.Helpers;
using Ombi.TheMovieDbApi.Models; using Ombi.TheMovieDbApi.Models;
namespace Ombi.Api.TheMovieDb namespace Ombi.Api.TheMovieDb
@ -38,12 +37,35 @@ namespace Ombi.Api.TheMovieDb
var request = new Request($"movie/{movieId}", BaseUri, HttpMethod.Get); var request = new Request($"movie/{movieId}", BaseUri, HttpMethod.Get);
request.FullUri = request.FullUri.AddQueryParameter("api_key", ApiToken); request.FullUri = request.FullUri.AddQueryParameter("api_key", ApiToken);
request.FullUri = request.FullUri.AddQueryParameter("language", langCode); request.FullUri = request.FullUri.AddQueryParameter("language", langCode);
request.FullUri = request.FullUri.AddQueryParameter("append_to_response", "videos,credits,similar,recommendations,release_dates,external_ids"); request.FullUri = request.FullUri.AddQueryParameter("append_to_response", "videos,credits,similar,recommendations,release_dates,external_ids,keywords");
AddRetry(request); AddRetry(request);
return await Api.Request<FullMovieInfo>(request); return await Api.Request<FullMovieInfo>(request);
} }
public async Task<TheMovieDbContainer<DiscoverMovies>> DiscoverMovies(string langCode, int keywordId)
{
// https://developers.themoviedb.org/3/discover/movie-discover
var request = new Request("discover/movie", BaseUri, HttpMethod.Get);
request.FullUri = request.FullUri.AddQueryParameter("api_key", ApiToken);
request.FullUri = request.FullUri.AddQueryParameter("language", langCode);
request.FullUri = request.FullUri.AddQueryParameter("with_keyword", keywordId.ToString());
request.FullUri = request.FullUri.AddQueryParameter("sort_by", "popularity.desc");
return await Api.Request<TheMovieDbContainer<DiscoverMovies>>(request);
}
public async Task<Collections> GetCollection(string langCode, int collectionId)
{
// https://developers.themoviedb.org/3/discover/movie-discover
var request = new Request("discover/movie", BaseUri, HttpMethod.Get);
request.FullUri = request.FullUri.AddQueryParameter("api_key", ApiToken);
request.FullUri = request.FullUri.AddQueryParameter("language", langCode);
request.FullUri = request.FullUri.AddQueryParameter("collection_id", collectionId.ToString());
return await Api.Request<Collections> (request);
}
public async Task<FindResult> Find(string externalId, ExternalSource source) public async Task<FindResult> Find(string externalId, ExternalSource source)
{ {
var request = new Request($"find/{externalId}", BaseUri, HttpMethod.Get); var request = new Request($"find/{externalId}", BaseUri, HttpMethod.Get);

@ -39,6 +39,8 @@
subscribed: boolean; subscribed: boolean;
showSubscribe: boolean; showSubscribe: boolean;
externalIds: IExternalIds; externalIds: IExternalIds;
keywords: IKeywords;
collections: ICollectionsModel;
// for the UI // for the UI
requestProcessing: boolean; requestProcessing: boolean;
@ -46,6 +48,22 @@
background: any; background: any;
} }
export interface ICollectionsModel {
id: number;
name: string;
posterPath: string;
backdropPath: string;
}
export interface IKeywords {
keywordsValue: IKeywordsValue[];
}
export interface IKeywordsValue {
id: number;
name: string;
}
export interface IVideos { export interface IVideos {
results: IVideoResult[]; results: IVideoResult[];
} }

@ -8,7 +8,8 @@
<div class="container summary"> <div class="container summary">
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-lg-10 offset-lg-2 col-md-8 offset-md-4 col-sm-7 offset-sm-5 col-6 offset-6"> <div
class="col-xl-12 col-lg-11 offset-lg-1 col-md-8 offset-md-4 col-sm-7 offset-sm-5 col-6 offset-6">
<h1>{{movie.title}} <span *ngIf="movie.releaseDate" class="grey-text align-middle">({{movie.releaseDate <h1>{{movie.title}} <span *ngIf="movie.releaseDate" class="grey-text align-middle">({{movie.releaseDate
| date:'yyyy'}})</span> | date:'yyyy'}})</span>
</h1> </h1>
@ -75,34 +76,42 @@
<mat-card class="card-full mat-elevation-z8"> <mat-card class="card-full mat-elevation-z8">
<mat-card-content> <mat-card-content>
<div> <div>
<small><strong>Theatrical Release:</strong> <span><strong>Theatrical Release:</strong>
{{movie.releaseDate | date: 'mediumDate'}}</small></div> {{movie.releaseDate | date: 'mediumDate'}}</span></div>
<div> <div>
<small *ngIf="movie.digitalReleaseDate"><strong>Digital Release:</strong> <span *ngIf="movie.digitalReleaseDate"><strong>Digital Release:</strong>
{{movie.digitalReleaseDate | date: {{movie.digitalReleaseDate | date:
'mediumDate'}}</small> 'mediumDate'}}</span>
</div> </div>
<div> <div>
<small *ngIf="movie.voteAverage"><strong>User Score:</strong> {{movie.voteAverage | <span *ngIf="movie.voteAverage"><strong>User Score:</strong> {{movie.voteAverage |
number:'1.0-1'}}/10</small> number:'1.0-1'}}/10</span>
</div> </div>
<div> <div>
<small *ngIf="movie.voteCount"><strong>Votes:</strong> {{movie.voteCount | <span *ngIf="movie.voteCount"><strong>Votes:</strong> {{movie.voteCount |
thousandShort: 1}}</small> thousandShort: 1}}</span>
</div> </div>
<div> <div>
<small><strong>Status:</strong> {{movie.status}}</small> <span><strong>Status:</strong> {{movie.status}}</span>
</div> </div>
<div> <div>
<small><strong>Runtime:</strong> {{movie.runtime}} Minutes</small> <span><strong>Runtime:</strong> {{movie.runtime}} Minutes</span>
</div> </div>
<div> <div>
<small *ngIf="movie.revenue"><strong>Revenue:</strong> {{movie.revenue | currency: <span *ngIf="movie.revenue"><strong>Revenue:</strong> {{movie.revenue | currency:
'USD'}}</small> 'USD'}}</span>
</div> </div>
<div> <div>
<small *ngIf="movie.budget"><strong>Budget:</strong> <span *ngIf="movie.budget"><strong>Budget:</strong>
{{movie.budget | currency: 'USD'}}</small> {{movie.budget | currency: 'USD'}}</span>
</div>
<div>
<span *ngIf="movie.genres"><strong>Genres:</strong>
<span *ngFor="let genre of movie.genres">
{{genre.name}} |
</span>
</span>
</div> </div>
</mat-card-content> </mat-card-content>
</mat-card> </mat-card>
@ -110,14 +119,14 @@
</div> </div>
<div class="col-12 col-md-7"> <div class="col-12 col-md-9">
<mat-card class="card-full mat-elevation-z8"> <mat-card class="card-full mat-elevation-z8">
<mat-card-content> <mat-card-content>
{{movie.overview}} {{movie.overview}}
</mat-card-content> </mat-card-content>
</mat-card> </mat-card>
</div> </div>
<div class="col-12 col-md-2 card-full"> <!-- <div class="col-12 col-md-2 card-full">
<div><button mat-raised-button class="btn-green btn-spacing" *ngIf="movie.available"> {{ <div><button mat-raised-button class="btn-green btn-spacing" *ngIf="movie.available"> {{
'Common.Available' | translate }}</button></div> 'Common.Available' | translate }}</button></div>
@ -146,18 +155,13 @@
href="{{movie.embyUrl}}" target="_blank"><i class="fa fa-eye"></i> {{'Search.ViewOnEmby' | href="{{movie.embyUrl}}" target="_blank"><i class="fa fa-eye"></i> {{'Search.ViewOnEmby' |
translate}}</a> translate}}</a>
</div> </div>
</div> </div> -->
</div> </div>
<div class="row card-spacer">
<div class="col-12 col-md-2">
</div>
</div>
<div class="row card-spacer"> <div class="row card-spacer">
<div class="col-12 col-md-10"> <div class="col-12 col-md-9 offset-md-3">
<mat-accordion> <mat-accordion>
<mat-expansion-panel> <mat-expansion-panel>
<mat-expansion-panel-header> <mat-expansion-panel-header>
@ -226,25 +230,25 @@
</div> </div>
<div class="col-12 col-md-2"> <!-- <div class="col-12 col-md-2">
<div *ngFor="let castIndex of [0,1,2,3,4]" class="row align-items-center cast-row "> <div *ngFor="let castIndex of [0,1,2,3,4]" class="row align-items-center cast-row ">
<div class="col-4"> <div class="col-4">
<img src="https://image.tmdb.org/t/p/w300/{{movie.credits.cast[castIndex].profile_path}}" <img src="https://image.tmdb.org/t/p/w300/{{movie.credits.cast[castIndex].profile_path}}"
class="cast-profile-img mat-elevation-z8" /> class="cast-profile-img mat-elevation-z8" />
</div> </div>
<div class="col-8"> <div class="col-8">
<div class="row cast-names"> <div class="row cast-names">
<div class="col-12"> <div class="col-12">
<div><small>{{movie.credits.cast[castIndex].character}}</small></div> <div><small>{{movie.credits.cast[castIndex].character}}</small></div>
</div> </div>
<div class="col-12 cast-name"> <div class="col-12 cast-name">
<div><small>{{movie.credits.cast[castIndex].name}}</small></div> <div><small>{{movie.credits.cast[castIndex].name}}</small></div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div> -->
</div> </div>

Loading…
Cancel
Save