From dc570d2e2ce4ca953147aad34a94b6bf06cc8163 Mon Sep 17 00:00:00 2001 From: TidusJar Date: Fri, 15 Feb 2019 09:49:30 +0000 Subject: [PATCH] Added more API's for getting Keyword Results and Movie Collections --- .../Search/V2/MovieFullInfoViewModel.cs | 8 +++ src/Ombi.Mapping/Profiles/MovieProfile.cs | 1 + src/Ombi.TheMovieDbApi/IMovieDbApi.cs | 2 + .../Models/BelongsToCollection.cs | 16 +++-- src/Ombi.TheMovieDbApi/Models/Collections.cs | 31 ++++++++ .../Models/DiscoverMovies.cs | 21 ++++++ .../Models/FullMovieInfo.cs | 18 ++++- src/Ombi.TheMovieDbApi/TheMovieDbApi.cs | 26 ++++++- .../app/interfaces/ISearchMovieResultV2.ts | 18 +++++ .../movie-details.component.html | 72 ++++++++++--------- 10 files changed, 171 insertions(+), 42 deletions(-) create mode 100644 src/Ombi.TheMovieDbApi/Models/Collections.cs create mode 100644 src/Ombi.TheMovieDbApi/Models/DiscoverMovies.cs diff --git a/src/Ombi.Core/Models/Search/V2/MovieFullInfoViewModel.cs b/src/Ombi.Core/Models/Search/V2/MovieFullInfoViewModel.cs index 97496f35f..138219458 100644 --- a/src/Ombi.Core/Models/Search/V2/MovieFullInfoViewModel.cs +++ b/src/Ombi.Core/Models/Search/V2/MovieFullInfoViewModel.cs @@ -8,6 +8,7 @@ namespace Ombi.Core.Models.Search.V2 public class MovieFullInfoViewModel : SearchViewModel { public bool Adult { get; set; } + public CollectionsViewModel BelongsToCollection { get; set; } public string BackdropPath { get; set; } public string OriginalLanguage { get; set; } public int Budget { get; set; } @@ -41,6 +42,13 @@ namespace Ombi.Core.Models.Search.V2 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 string ImdbId { get; set; } diff --git a/src/Ombi.Mapping/Profiles/MovieProfile.cs b/src/Ombi.Mapping/Profiles/MovieProfile.cs index aae7fae64..d0e1ea095 100644 --- a/src/Ombi.Mapping/Profiles/MovieProfile.cs +++ b/src/Ombi.Mapping/Profiles/MovieProfile.cs @@ -86,6 +86,7 @@ namespace Ombi.Mapping.Profiles CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); + CreateMap().ReverseMap(); } } } \ No newline at end of file diff --git a/src/Ombi.TheMovieDbApi/IMovieDbApi.cs b/src/Ombi.TheMovieDbApi/IMovieDbApi.cs index 379636929..694e220aa 100644 --- a/src/Ombi.TheMovieDbApi/IMovieDbApi.cs +++ b/src/Ombi.TheMovieDbApi/IMovieDbApi.cs @@ -23,5 +23,7 @@ namespace Ombi.Api.TheMovieDb Task GetActorMovieCredits(int actorId, string langCode); Task> MultiSearch(string searchTerm, string languageCode); Task GetFullMovieInfo(int movieId, string langCode); + Task> DiscoverMovies(string langCode, int keywordId); + Task GetCollection(string langCode, int collectionId); } } \ No newline at end of file diff --git a/src/Ombi.TheMovieDbApi/Models/BelongsToCollection.cs b/src/Ombi.TheMovieDbApi/Models/BelongsToCollection.cs index abbc69fef..f48941d83 100644 --- a/src/Ombi.TheMovieDbApi/Models/BelongsToCollection.cs +++ b/src/Ombi.TheMovieDbApi/Models/BelongsToCollection.cs @@ -1,10 +1,16 @@ -namespace Ombi.TheMovieDbApi.Models +using Newtonsoft.Json; + +namespace Ombi.TheMovieDbApi.Models { public class BelongsToCollection { - public int id { get; set; } - public string name { get; set; } - public string poster_path { get; set; } - public string backdrop_path { get; set; } + [JsonProperty("id")] + public int Id { get; set; } + [JsonProperty("name")] + public string Name { get; set; } + [JsonProperty("poster_path")] + public string PosterPath { get; set; } + [JsonProperty("backdrop_path")] + public string BackdropPath { get; set; } } } \ No newline at end of file diff --git a/src/Ombi.TheMovieDbApi/Models/Collections.cs b/src/Ombi.TheMovieDbApi/Models/Collections.cs new file mode 100644 index 000000000..951275180 --- /dev/null +++ b/src/Ombi.TheMovieDbApi/Models/Collections.cs @@ -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; } + } + +} \ No newline at end of file diff --git a/src/Ombi.TheMovieDbApi/Models/DiscoverMovies.cs b/src/Ombi.TheMovieDbApi/Models/DiscoverMovies.cs new file mode 100644 index 000000000..0ea5fb066 --- /dev/null +++ b/src/Ombi.TheMovieDbApi/Models/DiscoverMovies.cs @@ -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; } + } + +} \ No newline at end of file diff --git a/src/Ombi.TheMovieDbApi/Models/FullMovieInfo.cs b/src/Ombi.TheMovieDbApi/Models/FullMovieInfo.cs index 58e05b3f4..1ef96e4a8 100644 --- a/src/Ombi.TheMovieDbApi/Models/FullMovieInfo.cs +++ b/src/Ombi.TheMovieDbApi/Models/FullMovieInfo.cs @@ -1,4 +1,4 @@ -using System; +using System.Collections.Generic; using Newtonsoft.Json; using Ombi.TheMovieDbApi.Models; @@ -10,6 +10,8 @@ namespace Ombi.Api.TheMovieDb.Models public bool Adult { get; set; } [JsonProperty("backdrop_path")] public string BackdropPath { get; set; } + [JsonProperty("belongs_to_collection")] + public BelongsToCollection Collecion { get; set; } [JsonProperty("budget")] public int Budget { get; set; } [JsonProperty("genres")] @@ -66,6 +68,20 @@ namespace Ombi.Api.TheMovieDb.Models public ReleaseDates ReleaseDates { get; set; } [JsonProperty("external_ids")] public ExternalIds ExternalIds { get; set; } + [JsonProperty("keywords")] + public Keywords Keywords { get; set; } + } + + public class Keywords + { + [JsonProperty("keywords")] + public List KeywordsValue { get; set; } + } + + public class KeywordsValue + { + public int Id { get; set; } + public string Name { get; set; } } public class Videos diff --git a/src/Ombi.TheMovieDbApi/TheMovieDbApi.cs b/src/Ombi.TheMovieDbApi/TheMovieDbApi.cs index 3bdc952ac..ae1df478e 100644 --- a/src/Ombi.TheMovieDbApi/TheMovieDbApi.cs +++ b/src/Ombi.TheMovieDbApi/TheMovieDbApi.cs @@ -4,7 +4,6 @@ using System.Net.Http; using System.Threading.Tasks; using AutoMapper; using Ombi.Api.TheMovieDb.Models; -using Ombi.Helpers; using Ombi.TheMovieDbApi.Models; namespace Ombi.Api.TheMovieDb @@ -38,12 +37,35 @@ namespace Ombi.Api.TheMovieDb var request = new Request($"movie/{movieId}", BaseUri, HttpMethod.Get); request.FullUri = request.FullUri.AddQueryParameter("api_key", ApiToken); 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); return await Api.Request(request); } + public async Task> 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>(request); + } + + public async Task 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 (request); + } + public async Task Find(string externalId, ExternalSource source) { var request = new Request($"find/{externalId}", BaseUri, HttpMethod.Get); diff --git a/src/Ombi/ClientApp/src/app/interfaces/ISearchMovieResultV2.ts b/src/Ombi/ClientApp/src/app/interfaces/ISearchMovieResultV2.ts index b13ed3abd..1d95c800c 100644 --- a/src/Ombi/ClientApp/src/app/interfaces/ISearchMovieResultV2.ts +++ b/src/Ombi/ClientApp/src/app/interfaces/ISearchMovieResultV2.ts @@ -39,6 +39,8 @@ subscribed: boolean; showSubscribe: boolean; externalIds: IExternalIds; + keywords: IKeywords; + collections: ICollectionsModel; // for the UI requestProcessing: boolean; @@ -46,6 +48,22 @@ 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 { results: IVideoResult[]; } diff --git a/src/Ombi/ClientApp/src/app/media-details/movie-details.component.html b/src/Ombi/ClientApp/src/app/media-details/movie-details.component.html index 6da0d875c..7ccf8c2b1 100644 --- a/src/Ombi/ClientApp/src/app/media-details/movie-details.component.html +++ b/src/Ombi/ClientApp/src/app/media-details/movie-details.component.html @@ -8,7 +8,8 @@
-
+

{{movie.title}} ({{movie.releaseDate | date:'yyyy'}})

@@ -75,34 +76,42 @@
- Theatrical Release: - {{movie.releaseDate | date: 'mediumDate'}}
+ Theatrical Release: + {{movie.releaseDate | date: 'mediumDate'}}
- Digital Release: + Digital Release: {{movie.digitalReleaseDate | date: - 'mediumDate'}} + 'mediumDate'}}
- User Score: {{movie.voteAverage | - number:'1.0-1'}}/10 + User Score: {{movie.voteAverage | + number:'1.0-1'}}/10
- Votes: {{movie.voteCount | - thousandShort: 1}} + Votes: {{movie.voteCount | + thousandShort: 1}}
- Status: {{movie.status}} + Status: {{movie.status}}
- Runtime: {{movie.runtime}} Minutes + Runtime: {{movie.runtime}} Minutes
- Revenue: {{movie.revenue | currency: - 'USD'}} + Revenue: {{movie.revenue | currency: + 'USD'}}
- Budget: - {{movie.budget | currency: 'USD'}} + Budget: + {{movie.budget | currency: 'USD'}} +
+ +
+ Genres: + + {{genre.name}} | + +
@@ -110,14 +119,14 @@
-
+
{{movie.overview}}
-
+
-
-
- -
-
-
+
@@ -226,25 +230,25 @@
-
+