From b6b01264ed0049b35f544dd0b755fce426f07749 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Wed, 6 May 2015 06:17:02 +0000 Subject: [PATCH] * API requires 2-letter language codes, so translate non-2-letter language code locales to standard 2-letter codes --- source/net/filebot/web/TMDbClient.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/source/net/filebot/web/TMDbClient.java b/source/net/filebot/web/TMDbClient.java index 7a8dc17b..817778ea 100644 --- a/source/net/filebot/web/TMDbClient.java +++ b/source/net/filebot/web/TMDbClient.java @@ -32,6 +32,7 @@ import java.util.regex.Pattern; import javax.swing.Icon; +import net.filebot.Language; import net.filebot.ResourceManager; import net.filebot.web.TMDbClient.MovieInfo.MovieProperty; import net.filebot.web.TMDbClient.Person.PersonProperty; @@ -346,8 +347,18 @@ public class TMDbClient implements MovieIdentificationService { if (parameters != null) { data.putAll(parameters); } - if (locale != null && !locale.getLanguage().isEmpty()) { - data.put("language", locale.getLanguage()); + + if (locale != null && locale.getLanguage().length() > 0) { + String code = locale.getLanguage(); + + // require 2-letter language code + if (code.length() != 2) { + Language lang = Language.getLanguage(locale); + if (lang != null) { + code = lang.getISO2(); + } + } + data.put("language", code); } data.put("api_key", apikey);