From 46562be17d6f0bd3860edc6c16ecf6bbbed25b6c Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Mon, 14 Nov 2016 01:00:45 +0800 Subject: [PATCH] -Dnet.filebot.WebServices.TheMovieDB.adult=true --- source/net/filebot/WebServices.java | 3 ++- source/net/filebot/web/TMDbClient.java | 15 ++++++++++----- test/net/filebot/web/TMDbClientTest.java | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/source/net/filebot/WebServices.java b/source/net/filebot/WebServices.java index 28f0e4ab..5fb3f58e 100644 --- a/source/net/filebot/WebServices.java +++ b/source/net/filebot/WebServices.java @@ -18,6 +18,7 @@ import java.util.logging.Level; import net.filebot.media.XattrMetaInfoProvider; import net.filebot.similarity.MetricAvg; +import net.filebot.util.SystemProperty; import net.filebot.web.AcoustIDClient; import net.filebot.web.AnidbClient; import net.filebot.web.Datasource; @@ -48,7 +49,7 @@ public final class WebServices { // movie sources public static final OMDbClient OMDb = new OMDbClient(); - public static final TMDbClient TheMovieDB = new TMDbClient(getApiKey("themoviedb")); + public static final TMDbClient TheMovieDB = new TMDbClient(getApiKey("themoviedb"), SystemProperty.of("net.filebot.WebServices.TheMovieDB.adult", Boolean::parseBoolean, false).get()); // episode sources public static final TVMazeClient TVmaze = new TVMazeClient(); diff --git a/source/net/filebot/web/TMDbClient.java b/source/net/filebot/web/TMDbClient.java index f3f4ec5c..ef38e5d7 100644 --- a/source/net/filebot/web/TMDbClient.java +++ b/source/net/filebot/web/TMDbClient.java @@ -41,16 +41,18 @@ import net.filebot.ResourceManager; public class TMDbClient implements MovieIdentificationService, ArtworkProvider { - private static final String host = "api.themoviedb.org"; - private static final String version = "3"; - // X-RateLimit: 40 requests per 10 seconds => https://developers.themoviedb.org/3/getting-started/request-rate-limiting private static final FloodLimit REQUEST_LIMIT = new FloodLimit(35, 10, TimeUnit.SECONDS); - private final String apikey; + private final String host = "api.themoviedb.org"; + private final String version = "3"; - public TMDbClient(String apikey) { + private String apikey; + private boolean adult; + + public TMDbClient(String apikey, boolean adult) { this.apikey = apikey; + this.adult = adult; } @Override @@ -89,6 +91,9 @@ public class TMDbClient implements MovieIdentificationService, ArtworkProvider { if (movieYear > 0) { query.put("year", movieYear); } + if (adult) { + query.put("include_adult", adult); + } Object response = request("search/movie", query, locale); diff --git a/test/net/filebot/web/TMDbClientTest.java b/test/net/filebot/web/TMDbClientTest.java index 99b2dfea..d5df4bfa 100644 --- a/test/net/filebot/web/TMDbClientTest.java +++ b/test/net/filebot/web/TMDbClientTest.java @@ -21,7 +21,7 @@ import net.filebot.web.TMDbClient.MovieInfo; public class TMDbClientTest { - static TMDbClient db = new TMDbClient("66308fb6e3fd850dde4c7d21df2e8306"); + static TMDbClient db = new TMDbClient("66308fb6e3fd850dde4c7d21df2e8306", false); @Test public void searchByName() throws Exception {