From 341f6583de4d54b22efb019aac819e6dfbdd7123 Mon Sep 17 00:00:00 2001 From: first last Date: Wed, 19 May 2021 12:00:57 -0400 Subject: [PATCH 1/9] Create Genre structs --- .../ClientApp/src/app/interfaces/IMovieDb.ts | 5 +++ .../themoviedb/themoviedb.component.html | 44 ++++++++++++++++++- .../themoviedb/themoviedb.component.ts | 12 ++++- 3 files changed, 58 insertions(+), 3 deletions(-) diff --git a/src/Ombi/ClientApp/src/app/interfaces/IMovieDb.ts b/src/Ombi/ClientApp/src/app/interfaces/IMovieDb.ts index 63443ae4c..4aaaf0741 100644 --- a/src/Ombi/ClientApp/src/app/interfaces/IMovieDb.ts +++ b/src/Ombi/ClientApp/src/app/interfaces/IMovieDb.ts @@ -2,3 +2,8 @@ id: number; name: string; } + +export interface IMovieDbGenre { + id: number; + name: string; +} diff --git a/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.html b/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.html index 4d47aa8a9..af05fa08e 100644 --- a/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.html +++ b/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.html @@ -15,7 +15,7 @@
- + + + + + {{option.name}} + + + + + + + {{key.name}} + + + + + + + + + {{option.name}} + + + + + + + {{key.name}} + + + + @@ -52,4 +92,4 @@ - \ No newline at end of file + diff --git a/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.ts b/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.ts index 228d4fc42..d0686ef4d 100644 --- a/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.ts +++ b/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit, ElementRef, ViewChild } from "@angular/core"; import { MatAutocomplete } from "@angular/material/autocomplete"; -import { ITheMovieDbSettings, IMovieDbKeyword } from "../../interfaces"; +import { ITheMovieDbSettings, IMovieDbKeyword, IMovieDbGenre } from "../../interfaces"; import { NotificationService } from "../../services"; import { SettingsService } from "../../services"; import { TheMovieDbService } from "../../services"; @@ -15,6 +15,11 @@ interface IKeywordTag { initial: boolean; } +interface IGenres { + id: number; + name: string; +} + @Component({ templateUrl: "./themoviedb.component.html", styleUrls: ["./themoviedb.component.scss"] @@ -23,8 +28,13 @@ export class TheMovieDbComponent implements OnInit { public settings: ITheMovieDbSettings; public excludedKeywords: IKeywordTag[]; + public excludedMovieGenres: IGenres[]; + public excludedTvGenres: IGenres[]; public tagForm: FormGroup; public filteredTags: IMovieDbKeyword[]; + public filteredMovieGenres: IMovieDbGenre[]; + public filteredTvGenres: IMovieDbGenre[]; + @ViewChild('fruitInput') public fruitInput: ElementRef; constructor(private settingsService: SettingsService, From c217235d564df8b43b18c95e4774df4282e49886 Mon Sep 17 00:00:00 2001 From: first last Date: Wed, 19 May 2021 15:38:23 -0400 Subject: [PATCH 2/9] Add backend API calls for genres --- src/Ombi.TheMovieDbApi/IMovieDbApi.cs | 7 ++- .../Models/TheMovieDbContainer.cs | 7 ++- src/Ombi.TheMovieDbApi/TheMovieDbApi.cs | 14 +++++ .../ClientApp/src/app/interfaces/ISettings.ts | 2 + .../applications/themoviedb.service.ts | 6 ++- .../themoviedb/themoviedb.component.ts | 53 ++++++++++++++++--- .../V1/External/TheMovieDbController.cs | 12 +++++ 7 files changed, 92 insertions(+), 9 deletions(-) diff --git a/src/Ombi.TheMovieDbApi/IMovieDbApi.cs b/src/Ombi.TheMovieDbApi/IMovieDbApi.cs index ea2465c1d..fb15aab5f 100644 --- a/src/Ombi.TheMovieDbApi/IMovieDbApi.cs +++ b/src/Ombi.TheMovieDbApi/IMovieDbApi.cs @@ -4,6 +4,10 @@ using System.Threading.Tasks; using Ombi.Api.TheMovieDb.Models; using Ombi.TheMovieDbApi.Models; +// Due to conflicting Genre models in +// Ombi.TheMovieDbApi.Models and Ombi.Api.TheMovieDb.Models +using Genre = Ombi.TheMovieDbApi.Models.Genre; + namespace Ombi.Api.TheMovieDb { public interface IMovieDbApi @@ -34,5 +38,6 @@ namespace Ombi.Api.TheMovieDb Task GetKeyword(int keywordId); Task GetMovieWatchProviders(int theMoviedbId, CancellationToken token); Task GetTvWatchProviders(int theMoviedbId, CancellationToken token); + Task> GetGenres(string media); } -} \ No newline at end of file +} diff --git a/src/Ombi.TheMovieDbApi/Models/TheMovieDbContainer.cs b/src/Ombi.TheMovieDbApi/Models/TheMovieDbContainer.cs index 72f58dd02..5eb5dbeac 100644 --- a/src/Ombi.TheMovieDbApi/Models/TheMovieDbContainer.cs +++ b/src/Ombi.TheMovieDbApi/Models/TheMovieDbContainer.cs @@ -36,4 +36,9 @@ namespace Ombi.TheMovieDbApi.Models public int total_results { get; set; } public int total_pages { get; set; } } -} \ No newline at end of file + + public class GenreContainer + { + public List genres { get; set; } + } +} diff --git a/src/Ombi.TheMovieDbApi/TheMovieDbApi.cs b/src/Ombi.TheMovieDbApi/TheMovieDbApi.cs index 74c849d59..1439c1c93 100644 --- a/src/Ombi.TheMovieDbApi/TheMovieDbApi.cs +++ b/src/Ombi.TheMovieDbApi/TheMovieDbApi.cs @@ -13,6 +13,10 @@ using Ombi.Core.Settings.Models.External; using Ombi.Helpers; using Ombi.TheMovieDbApi.Models; +// Due to conflicting Genre models in +// Ombi.TheMovieDbApi.Models and Ombi.Api.TheMovieDb.Models +using Genre = Ombi.TheMovieDbApi.Models.Genre; + namespace Ombi.Api.TheMovieDb { public class TheMovieDbApi : IMovieDbApi @@ -344,6 +348,16 @@ namespace Ombi.Api.TheMovieDb return keyword == null || keyword.Id == 0 ? null : keyword; } + public async Task> GetGenres(string media) + { + var request = new Request($"genre/{media}/list", BaseUri, HttpMethod.Get); + request.AddQueryString("api_key", ApiToken); + AddRetry(request); + + var result = await Api.Request>(request); + return result.genres ?? new List(); + } + public Task> MultiSearch(string searchTerm, string languageCode, CancellationToken cancellationToken) { var request = new Request("search/multi", BaseUri, HttpMethod.Get); diff --git a/src/Ombi/ClientApp/src/app/interfaces/ISettings.ts b/src/Ombi/ClientApp/src/app/interfaces/ISettings.ts index d73fdddc8..5dfaa3e15 100644 --- a/src/Ombi/ClientApp/src/app/interfaces/ISettings.ts +++ b/src/Ombi/ClientApp/src/app/interfaces/ISettings.ts @@ -284,6 +284,8 @@ export interface IVoteSettings extends ISettings { export interface ITheMovieDbSettings extends ISettings { showAdultMovies: boolean; excludedKeywordIds: number[]; + excludedMovieGenreIds: number[]; + excludedTvGenreIds: number[] } export interface IUpdateModel diff --git a/src/Ombi/ClientApp/src/app/services/applications/themoviedb.service.ts b/src/Ombi/ClientApp/src/app/services/applications/themoviedb.service.ts index 677034143..c8303f58c 100644 --- a/src/Ombi/ClientApp/src/app/services/applications/themoviedb.service.ts +++ b/src/Ombi/ClientApp/src/app/services/applications/themoviedb.service.ts @@ -4,7 +4,7 @@ import { Injectable, Inject } from "@angular/core"; import { empty, Observable, throwError } from "rxjs"; import { catchError } from "rxjs/operators"; -import { IMovieDbKeyword } from "../../interfaces"; +import { IMovieDbGenre, IMovieDbKeyword } from "../../interfaces"; import { ServiceHelpers } from "../service.helpers"; @Injectable() @@ -22,4 +22,8 @@ export class TheMovieDbService extends ServiceHelpers { return this.http.get(`${this.url}/Keywords/${keywordId}`, { headers: this.headers }) .pipe(catchError((error: HttpErrorResponse) => error.status === 404 ? empty() : throwError(error))); } + + public getGenres(media: string): Observable { + return this.http.get(`${this.url}/Genres/${media}`, { headers: this.headers }) + } } diff --git a/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.ts b/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.ts index d0686ef4d..c3c78324d 100644 --- a/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.ts +++ b/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.ts @@ -18,6 +18,7 @@ interface IKeywordTag { interface IGenres { id: number; name: string; + initial: boolean; } @Component({ @@ -48,6 +49,8 @@ export class TheMovieDbComponent implements OnInit { }); this.settingsService.getTheMovieDbSettings().subscribe(settings => { this.settings = settings; + + // Map Keyword ids -> keyword name this.excludedKeywords = settings.excludedKeywordIds ? settings.excludedKeywordIds.map(id => ({ id, @@ -55,13 +58,52 @@ export class TheMovieDbComponent implements OnInit { initial: true, })) : []; - this.excludedKeywords.forEach(key => { - this.tmdbService.getKeyword(key.id).subscribe(keyResult => { - this.excludedKeywords.filter((val, idx) => { - val.name = keyResult.name; + + this.excludedKeywords.forEach(key => { + this.tmdbService.getKeyword(key.id).subscribe(keyResult => { + this.excludedKeywords.filter((val, idx) => { + val.name = keyResult.name; + }) + }); + }); + + // Map Movie Genre ids -> genre name + this.excludedMovieGenres = settings.excludedMovieGenreIds + ? settings.excludedMovieGenreIds.map(id => ({ + id, + name: "", + initial: true, + })) + : []; + + this.tmdbService.getGenres("movie").subscribe(results => { + results.forEach(genre => { + this.excludedMovieGenres.forEach(key => { + this.excludedMovieGenres.filter((val, idx) => { + val.name = genre.name + }) + }) + }); + }); + + // Map Tv Genre ids -> genre name + this.excludedTvGenres = settings.excludedTvGenreIds + ? settings.excludedTvGenreIds.map(id => ({ + id, + name: "", + initial: true, + })) + : []; + + this.tmdbService.getGenres("tv").subscribe(results => { + results.forEach(genre => { + this.excludedTvGenres.forEach(key => { + this.excludedTvGenres.filter((val, idx) => { + val.name = genre.name }) - }); + }) }); + }); }); this.tagForm @@ -75,7 +117,6 @@ export class TheMovieDbComponent implements OnInit { }) ) .subscribe((r) => (this.filteredTags = r)); - } public remove(tag: IKeywordTag): void { diff --git a/src/Ombi/Controllers/V1/External/TheMovieDbController.cs b/src/Ombi/Controllers/V1/External/TheMovieDbController.cs index 714831633..ac4bb4eea 100644 --- a/src/Ombi/Controllers/V1/External/TheMovieDbController.cs +++ b/src/Ombi/Controllers/V1/External/TheMovieDbController.cs @@ -5,6 +5,10 @@ using Ombi.Attributes; using System.Collections.Generic; using System.Threading.Tasks; +// Due to conflicting Genre models in +// Ombi.TheMovieDbApi.Models and Ombi.Api.TheMovieDb.Models +using Genre = Ombi.TheMovieDbApi.Models.Genre; + namespace Ombi.Controllers.External { [Admin] @@ -34,5 +38,13 @@ namespace Ombi.Controllers.External var keyword = await TmdbApi.GetKeyword(keywordId); return keyword == null ? NotFound() : (IActionResult)Ok(keyword); } + + /// + /// Gets the genres for either Tv or Movies depending on media type + /// + /// Either `tv` or `movie`. + [HttpGet("Genres/{media}")] + public async Task> GetGenres(string media) => + await TmdbApi.GetGenres(media); } } From e899428feb8a35eb57a3ebc9935fd932036eb670 Mon Sep 17 00:00:00 2001 From: first last Date: Thu, 20 May 2021 13:57:24 -0400 Subject: [PATCH 3/9] Made genre exclusion a drop down --- .../themoviedb/themoviedb.component.html | 36 ++++++++----------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.html b/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.html index af05fa08e..007193058 100644 --- a/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.html +++ b/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.html @@ -28,47 +28,41 @@ + (removed)="remove(key, 'keyword')"> {{key.name}} - - - - - {{option.name}} + + Movie Genres + + + {{genre.name}} - + + (removed)="remove(key, 'movieGenre')"> {{key.name}} - - - - - {{option.name}} + + Tv Genres + + + {{genre.name}} - + + (removed)="remove(key, 'tvGenre')"> {{key.name}} From cd7db8bb44c157ceff912240e43ff678a833d346 Mon Sep 17 00:00:00 2001 From: first last Date: Thu, 20 May 2021 13:59:17 -0400 Subject: [PATCH 4/9] Populate and save the dropdown selections --- .../themoviedb/themoviedb.component.ts | 88 +++++++++++++------ 1 file changed, 59 insertions(+), 29 deletions(-) diff --git a/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.ts b/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.ts index c3c78324d..2ea02af47 100644 --- a/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.ts +++ b/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.ts @@ -1,8 +1,8 @@ -import {COMMA, ENTER} from "@angular/cdk/keycodes"; +import {COMMA, ENTER, K} from "@angular/cdk/keycodes"; import { Component, OnInit, ElementRef, ViewChild } from "@angular/core"; import { MatAutocomplete } from "@angular/material/autocomplete"; -import { ITheMovieDbSettings, IMovieDbKeyword, IMovieDbGenre } from "../../interfaces"; +import { ITheMovieDbSettings, IMovieDbKeyword } from "../../interfaces"; import { NotificationService } from "../../services"; import { SettingsService } from "../../services"; import { TheMovieDbService } from "../../services"; @@ -15,12 +15,6 @@ interface IKeywordTag { initial: boolean; } -interface IGenres { - id: number; - name: string; - initial: boolean; -} - @Component({ templateUrl: "./themoviedb.component.html", styleUrls: ["./themoviedb.component.scss"] @@ -29,12 +23,12 @@ export class TheMovieDbComponent implements OnInit { public settings: ITheMovieDbSettings; public excludedKeywords: IKeywordTag[]; - public excludedMovieGenres: IGenres[]; - public excludedTvGenres: IGenres[]; + public excludedMovieGenres: IKeywordTag[]; + public excludedTvGenres: IKeywordTag[]; public tagForm: FormGroup; public filteredTags: IMovieDbKeyword[]; - public filteredMovieGenres: IMovieDbGenre[]; - public filteredTvGenres: IMovieDbGenre[]; + public filteredMovieGenres: IMovieDbKeyword[]; + public filteredTvGenres: IMovieDbKeyword[]; @ViewChild('fruitInput') public fruitInput: ElementRef; @@ -46,6 +40,8 @@ export class TheMovieDbComponent implements OnInit { public ngOnInit() { this.tagForm = this.fb.group({ input: null, + excludedMovieGenres: null, + excludedTvGenres: null, }); this.settingsService.getTheMovieDbSettings().subscribe(settings => { this.settings = settings; @@ -77,14 +73,16 @@ export class TheMovieDbComponent implements OnInit { : []; this.tmdbService.getGenres("movie").subscribe(results => { - results.forEach(genre => { - this.excludedMovieGenres.forEach(key => { - this.excludedMovieGenres.filter((val, idx) => { - val.name = genre.name - }) - }) + this.filteredMovieGenres = results; + + this.excludedMovieGenres.forEach(genre => { + results.forEach(result => { + if (genre.id == result.id) { + genre.name = result.name; + } + }); }); - }); + }); // Map Tv Genre ids -> genre name this.excludedTvGenres = settings.excludedTvGenreIds @@ -96,13 +94,15 @@ export class TheMovieDbComponent implements OnInit { : []; this.tmdbService.getGenres("tv").subscribe(results => { - results.forEach(genre => { - this.excludedTvGenres.forEach(key => { - this.excludedTvGenres.filter((val, idx) => { - val.name = genre.name - }) - }) - }); + this.filteredTvGenres = results; + + this.excludedTvGenres.forEach(genre => { + results.forEach(result => { + if (genre.id == result.id) { + genre.name = result.name; + } + }); + }); }); }); @@ -119,16 +119,46 @@ export class TheMovieDbComponent implements OnInit { .subscribe((r) => (this.filteredTags = r)); } - public remove(tag: IKeywordTag): void { - const index = this.excludedKeywords.indexOf(tag); + public remove(tag: IKeywordTag, tag_type: string): void { + var exclusion_list; + + switch (tag_type) { + case "keyword": + exclusion_list = this.excludedKeywords; + break; + case "movieGenre": + exclusion_list = this.excludedMovieGenres; + break; + case "tvGenre": + exclusion_list = this.excludedTvGenres; + break; + default: + return; + } + + const index = exclusion_list.indexOf(tag); if (index >= 0) { - this.excludedKeywords.splice(index, 1); + exclusion_list.splice(index, 1); } } public save() { + + var selectedMovieGenres: number[] = this.tagForm.controls.excludedMovieGenres.value ?? []; + var selectedTvGenres: number[] = this.tagForm.controls.excludedTvGenres.value ?? []; + + var movieIds: number[] = this.excludedMovieGenres.map(k => k.id); + var tvIds: number[] = this.excludedTvGenres.map(k => k.id) + + // Concat and dedup already excluded genres + newly selected ones + selectedMovieGenres = movieIds.concat(selectedMovieGenres.filter(item => movieIds.indexOf(item) < 0)); + selectedTvGenres = tvIds.concat(selectedTvGenres.filter(item => tvIds.indexOf(item) < 0)); + this.settings.excludedKeywordIds = this.excludedKeywords.map(k => k.id); + this.settings.excludedMovieGenreIds = selectedMovieGenres; + this.settings.excludedTvGenreIds = selectedTvGenres; + this.settingsService.saveTheMovieDbSettings(this.settings).subscribe(x => { if (x) { this.notificationService.success("Successfully saved The Movie Database settings"); From 910f6380fc18401f0c89f2d40ec6c47c368668ee Mon Sep 17 00:00:00 2001 From: first last Date: Thu, 20 May 2021 13:59:56 -0400 Subject: [PATCH 5/9] Remove unnecessary structs --- src/Ombi/ClientApp/src/app/interfaces/IMovieDb.ts | 5 ----- .../src/app/services/applications/themoviedb.service.ts | 6 +++--- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/Ombi/ClientApp/src/app/interfaces/IMovieDb.ts b/src/Ombi/ClientApp/src/app/interfaces/IMovieDb.ts index 4aaaf0741..63443ae4c 100644 --- a/src/Ombi/ClientApp/src/app/interfaces/IMovieDb.ts +++ b/src/Ombi/ClientApp/src/app/interfaces/IMovieDb.ts @@ -2,8 +2,3 @@ id: number; name: string; } - -export interface IMovieDbGenre { - id: number; - name: string; -} diff --git a/src/Ombi/ClientApp/src/app/services/applications/themoviedb.service.ts b/src/Ombi/ClientApp/src/app/services/applications/themoviedb.service.ts index c8303f58c..ff76d591b 100644 --- a/src/Ombi/ClientApp/src/app/services/applications/themoviedb.service.ts +++ b/src/Ombi/ClientApp/src/app/services/applications/themoviedb.service.ts @@ -4,7 +4,7 @@ import { Injectable, Inject } from "@angular/core"; import { empty, Observable, throwError } from "rxjs"; import { catchError } from "rxjs/operators"; -import { IMovieDbGenre, IMovieDbKeyword } from "../../interfaces"; +import { IMovieDbKeyword } from "../../interfaces"; import { ServiceHelpers } from "../service.helpers"; @Injectable() @@ -23,7 +23,7 @@ export class TheMovieDbService extends ServiceHelpers { .pipe(catchError((error: HttpErrorResponse) => error.status === 404 ? empty() : throwError(error))); } - public getGenres(media: string): Observable { - return this.http.get(`${this.url}/Genres/${media}`, { headers: this.headers }) + public getGenres(media: string): Observable { + return this.http.get(`${this.url}/Genres/${media}`, { headers: this.headers }) } } From 53523b35dbe2b9e9668386bd78f4e15424ad1345 Mon Sep 17 00:00:00 2001 From: first last Date: Thu, 20 May 2021 14:00:13 -0400 Subject: [PATCH 6/9] Add settings for exlcuded genre and movie Ids --- .../Settings/Models/External/TheMovieDbSettings.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Ombi.Settings/Settings/Models/External/TheMovieDbSettings.cs b/src/Ombi.Settings/Settings/Models/External/TheMovieDbSettings.cs index fe0c238d8..c2df1b9b3 100644 --- a/src/Ombi.Settings/Settings/Models/External/TheMovieDbSettings.cs +++ b/src/Ombi.Settings/Settings/Models/External/TheMovieDbSettings.cs @@ -7,5 +7,9 @@ namespace Ombi.Core.Settings.Models.External public bool ShowAdultMovies { get; set; } public List ExcludedKeywordIds { get; set; } + + public List ExcludedMovieGenreIds { get; set; } + + public List ExcludedTvGenreIds { get; set; } } } From 2c94f982c65f8316fc5bd89a7a3a9c08d4e9d8b4 Mon Sep 17 00:00:00 2001 From: first last Date: Thu, 20 May 2021 15:00:17 -0400 Subject: [PATCH 7/9] Add genre filtering function; Add genre filter to discovery --- src/Ombi.TheMovieDbApi/TheMovieDbApi.cs | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/Ombi.TheMovieDbApi/TheMovieDbApi.cs b/src/Ombi.TheMovieDbApi/TheMovieDbApi.cs index 1439c1c93..c5a290e04 100644 --- a/src/Ombi.TheMovieDbApi/TheMovieDbApi.cs +++ b/src/Ombi.TheMovieDbApi/TheMovieDbApi.cs @@ -202,6 +202,7 @@ namespace Ombi.Api.TheMovieDb request.AddQueryString("page", page.ToString()); } await AddDiscoverSettings(request); + await AddGenreFilter(request, type); AddRetry(request); var result = await Api.Request>(request, cancellationToken); return Mapper.Map>(result.results); @@ -237,6 +238,7 @@ namespace Ombi.Api.TheMovieDb request.AddQueryString("vote_count.gte", "250"); await AddDiscoverSettings(request); + await AddGenreFilter(request, type); AddRetry(request); var result = await Api.Request>(request); return Mapper.Map>(result.results); @@ -273,6 +275,7 @@ namespace Ombi.Api.TheMovieDb request.AddQueryString("page", page.ToString()); } await AddDiscoverSettings(request); + await AddGenreFilter(request, type); AddRetry(request); var result = await Api.Request>(request); return Mapper.Map>(result.results); @@ -301,6 +304,7 @@ namespace Ombi.Api.TheMovieDb } await AddDiscoverSettings(request); + await AddGenreFilter(request, "movie"); AddRetry(request); var result = await Api.Request>(request); return Mapper.Map>(result.results); @@ -394,6 +398,28 @@ namespace Ombi.Api.TheMovieDb } } + private async Task AddGenreFilter(Request request, string media_type) + { + var settings = await Settings; + List excludedGenres; + + switch (media_type) { + case "tv": + excludedGenres = settings.ExcludedTvGenreIds; + break; + case "movie": + excludedGenres = settings.ExcludedMovieGenreIds; + break; + default: + return; + } + + if (excludedGenres?.Any() == true) + { + request.AddQueryString("without_genres", string.Join(",", excludedGenres)); + } + } + private static void AddRetry(Request request) { request.Retry = true; From 9082aaeeb91cb9f1c593411d4d3d76f90a712151 Mon Sep 17 00:00:00 2001 From: first last Date: Thu, 20 May 2021 15:03:08 -0400 Subject: [PATCH 8/9] Add 1em to margin top of the genre drop down --- .../themoviedb/themoviedb.component.html | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.html b/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.html index 007193058..fb10cc142 100644 --- a/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.html +++ b/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.html @@ -33,15 +33,17 @@ - - - Movie Genres - - - {{genre.name}} - - - + +
+ + Movie Genres + + + {{genre.name}} + + + +
- - Tv Genres - - - {{genre.name}} - - - +
+ + Tv Genres + + + {{genre.name}} + + + +
Date: Thu, 20 May 2021 15:14:26 -0400 Subject: [PATCH 9/9] Remove incorrect import --- .../src/app/settings/themoviedb/themoviedb.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.ts b/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.ts index 2ea02af47..49ec3e51f 100644 --- a/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.ts +++ b/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.ts @@ -1,4 +1,4 @@ -import {COMMA, ENTER, K} from "@angular/cdk/keycodes"; +import {COMMA, ENTER} from "@angular/cdk/keycodes"; import { Component, OnInit, ElementRef, ViewChild } from "@angular/core"; import { MatAutocomplete } from "@angular/material/autocomplete";