diff --git a/source/net/filebot/WebServices.java b/source/net/filebot/WebServices.java index 557d9fae..2c78dc4e 100644 --- a/source/net/filebot/WebServices.java +++ b/source/net/filebot/WebServices.java @@ -8,7 +8,6 @@ import static net.filebot.util.FileUtilities.*; import java.io.IOException; import java.net.URI; -import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; @@ -287,16 +286,27 @@ public final class WebServices { } public static void setLogin(String id, String user, String password) { - if (user == null || password == null || user.contains(LOGIN_SEPARATOR) || (user.isEmpty() && !password.isEmpty()) || (!user.isEmpty() && password.isEmpty())) { - throw new IllegalArgumentException(String.format("Illegal login: %s:%s", user, password)); - } - - if (LOGIN_OPENSUBTITLES.equals(id)) { - String password_md5 = md5(StandardCharsets.UTF_8.encode(password)); - OpenSubtitles.setUser(user, password_md5); - Settings.forPackage(WebServices.class).put(id, String.join(LOGIN_SEPARATOR, user, password_md5)); + // delete login + if ((user == null || user.isEmpty()) && (password == null || password.isEmpty())) { + if (LOGIN_OPENSUBTITLES.equals(id)) { + OpenSubtitles.setUser("", ""); + Settings.forPackage(WebServices.class).remove(id); + } else { + throw new IllegalArgumentException(); + } } else { - throw new IllegalArgumentException(); + // enter login + if (user == null || password == null || user.contains(LOGIN_SEPARATOR) || (user.isEmpty() && !password.isEmpty()) || (!user.isEmpty() && password.isEmpty())) { + throw new IllegalArgumentException(String.format("Illegal login: %s:%s", user, password)); + } + + if (LOGIN_OPENSUBTITLES.equals(id)) { + String password_md5 = md5(password); + OpenSubtitles.setUser(user, password_md5); + Settings.forPackage(WebServices.class).put(id, String.join(LOGIN_SEPARATOR, user, password_md5)); + } else { + throw new IllegalArgumentException(); + } } } diff --git a/source/net/filebot/ui/subtitle/SubtitlePanel.java b/source/net/filebot/ui/subtitle/SubtitlePanel.java index 7dfb36c3..9a7e9906 100644 --- a/source/net/filebot/ui/subtitle/SubtitlePanel.java +++ b/source/net/filebot/ui/subtitle/SubtitlePanel.java @@ -3,6 +3,7 @@ package net.filebot.ui.subtitle; import static net.filebot.Settings.*; import static net.filebot.ui.LanguageComboBoxModel.*; import static net.filebot.ui.NotificationLogging.*; +import static net.filebot.util.FileUtilities.*; import static net.filebot.util.ui.SwingUI.*; import java.awt.Color; @@ -291,9 +292,9 @@ public class SubtitlePanel extends AbstractSearchPanel 0 && osdbPass.getPassword().length > 0) { final OpenSubtitlesClient osdb = new OpenSubtitlesClient(getApplicationName(), getApplicationVersion()); - osdb.setUser(osdbUser.getText(), new String(osdbPass.getPassword())); + osdb.setUser(osdbUser.getText(), md5(new String(osdbPass.getPassword()))); osdb.login(); // do some status checks in background (since OpenSubtitles can be really really slow) @@ -333,6 +334,8 @@ public class SubtitlePanel extends AbstractSearchPanel