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;