From e24c381afe1b466b621e5de88f95d9ef71ce4c5b Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Wed, 30 Sep 2015 17:51:13 +0000 Subject: [PATCH] * fix "Chinese" language subtitle upload issues --- source/net/filebot/web/OpenSubtitlesClient.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/source/net/filebot/web/OpenSubtitlesClient.java b/source/net/filebot/web/OpenSubtitlesClient.java index 6f510b17..ae105a59 100644 --- a/source/net/filebot/web/OpenSubtitlesClient.java +++ b/source/net/filebot/web/OpenSubtitlesClient.java @@ -118,7 +118,7 @@ public class OpenSubtitlesClient implements SubtitleProvider, VideoHashSubtitleS // singleton array with or empty array int imdbid = ((Movie) searchResult).getImdbId(); - String[] languageFilter = languageName != null ? new String[] { getSubLanguageID(languageName) } : new String[0]; + String[] languageFilter = languageName != null ? new String[] { getSubLanguageID(languageName, true) } : new String[0]; // require login login(); @@ -159,7 +159,7 @@ public class OpenSubtitlesClient implements SubtitleProvider, VideoHashSubtitleS public synchronized Map> getSubtitleListByHash(File[] files, String languageName) throws Exception { // singleton array with or empty array - String[] languageFilter = languageName != null ? new String[] { getSubLanguageID(languageName) } : new String[0]; + String[] languageFilter = languageName != null ? new String[] { getSubLanguageID(languageName, true) } : new String[0]; // remember hash for each file Map hashMap = new HashMap(files.length); @@ -222,7 +222,7 @@ public class OpenSubtitlesClient implements SubtitleProvider, VideoHashSubtitleS public synchronized Map> getSubtitleListByTag(File[] files, String languageName) throws Exception { // singleton array with or empty array - String[] languageFilter = languageName != null ? new String[] { getSubLanguageID(languageName) } : new String[0]; + String[] languageFilter = languageName != null ? new String[] { getSubLanguageID(languageName, true) } : new String[0]; // remember tag for each file Map tagMap = new HashMap(files.length); @@ -329,7 +329,7 @@ public class OpenSubtitlesClient implements SubtitleProvider, VideoHashSubtitleS } int imdbid = ((Movie) identity).getImdbId(); - String languageName = getSubLanguageID(language.getDisplayName(Locale.ENGLISH)); + String languageName = getSubLanguageID(language.getDisplayName(Locale.ENGLISH), false); // subhash (md5 of subtitles), subfilename, moviehash, moviebytesize, moviefilename SubFile sub = new SubFile(); @@ -474,7 +474,7 @@ public class OpenSubtitlesClient implements SubtitleProvider, VideoHashSubtitleS if (languageName != null) { try { - sublanguageid = getSubLanguageID(languageName); + sublanguageid = getSubLanguageID(languageName, true); } catch (Exception e) { Logger.getLogger(getClass().getName()).log(Level.WARNING, e.getMessage(), e); } @@ -593,11 +593,14 @@ public class OpenSubtitlesClient implements SubtitleProvider, VideoHashSubtitleS return subLanguageMap; } - protected String getSubLanguageID(String languageName) throws Exception { + protected String getSubLanguageID(String languageName, boolean allowMultiLanguageID) throws Exception { String subLanguageID = getSubLanguageMap().get(languageName.toLowerCase()); if (subLanguageID == null) { throw new IllegalArgumentException(String.format("SubLanguageID for '%s' not found", languageName)); } + if (!allowMultiLanguageID && subLanguageID.contains(",")) { + subLanguageID = subLanguageID.substring(0, subLanguageID.indexOf(",")); + } return subLanguageID; }