From 63f5775ada390144e70739ace6076e10246435b8 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Thu, 7 Mar 2019 17:26:57 +0700 Subject: [PATCH] Support for non-default TheTVDBv2 API mirrors (possibly useful in China where *.thetvdb.com is blocked) --- source/net/filebot/web/TheTVDBClient.java | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/source/net/filebot/web/TheTVDBClient.java b/source/net/filebot/web/TheTVDBClient.java index 6df066c0..e61126ce 100644 --- a/source/net/filebot/web/TheTVDBClient.java +++ b/source/net/filebot/web/TheTVDBClient.java @@ -33,12 +33,26 @@ import net.filebot.ResourceManager; public class TheTVDBClient extends AbstractEpisodeListProvider implements ArtworkProvider { + private static URL getEndpoint() { + try { + return new URL(System.getProperty("net.filebot.TheTVDB.url", "https://api.thetvdb.com/")); + } catch (Exception e) { + throw new IllegalStateException(e); + } + } + private static final Locale DEFAULT_LOCALE = Locale.ENGLISH; - private String apikey; + private final URL api; + private final String apikey; + + public TheTVDBClient(URL api, String apikey) { + this.api = api; + this.apikey = apikey; + } public TheTVDBClient(String apikey) { - this.apikey = apikey; + this(getEndpoint(), apikey); } @Override @@ -68,7 +82,7 @@ public class TheTVDBClient extends AbstractEpisodeListProvider implements Artwor } protected URL getEndpoint(String path) throws Exception { - return new URL("https://api.thetvdb.com/" + path); + return new URL(api, path); } private Map getRequestHeader(Locale locale) {