mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-24 00:38:52 -05:00
* Built-in links for Registering & Upgrading OpenSubtitles accounts
This commit is contained in:
parent
f0566e8fa7
commit
162945c6e3
@ -234,17 +234,25 @@ public final class WebServices {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String[] getLogin(String key) {
|
public static String[] getLogin(String key) {
|
||||||
return Settings.forPackage(WebServices.class).get(key, ":").split(":", 2);
|
try {
|
||||||
|
String[] values = Settings.forPackage(WebServices.class).get(key, ":").split(":", 2); // empty username/password by default
|
||||||
|
if (values != null && values.length == 2 && values[0] != null && values[1] != null) {
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.getLogger(WebServices.class.getName()).log(Level.WARNING, e.getMessage(), e);
|
||||||
|
}
|
||||||
|
return new String[] { "", "" };
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setLogin(String id, String user, String password) {
|
public static void setLogin(String id, String user, String password) {
|
||||||
Settings settings = Settings.forPackage(WebServices.class);
|
if (user == null || password == null || user.contains(":") || (user.isEmpty() && !password.isEmpty()) || (!user.isEmpty() && password.isEmpty())) {
|
||||||
String value = user.length() > 0 && password.length() > 0 ? user + ":" + password : null;
|
throw new IllegalArgumentException("Illegal login: " + user);
|
||||||
if (value == null) {
|
|
||||||
user = "";
|
|
||||||
password = "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Settings settings = Settings.forPackage(WebServices.class);
|
||||||
|
String value = user.isEmpty() && password.isEmpty() ? null : user + ":" + password;
|
||||||
|
|
||||||
if (id.equals("osdb.user")) {
|
if (id.equals("osdb.user")) {
|
||||||
settings.put(id, value);
|
settings.put(id, value);
|
||||||
OpenSubtitles.setUser(user, password);
|
OpenSubtitles.setUser(user, password);
|
||||||
|
@ -40,6 +40,7 @@ import net.filebot.ui.AbstractSearchPanel;
|
|||||||
import net.filebot.ui.LanguageComboBox;
|
import net.filebot.ui.LanguageComboBox;
|
||||||
import net.filebot.ui.SelectDialog;
|
import net.filebot.ui.SelectDialog;
|
||||||
import net.filebot.util.ui.LabelProvider;
|
import net.filebot.util.ui.LabelProvider;
|
||||||
|
import net.filebot.util.ui.LinkButton;
|
||||||
import net.filebot.util.ui.SimpleLabelProvider;
|
import net.filebot.util.ui.SimpleLabelProvider;
|
||||||
import net.filebot.web.OpenSubtitlesClient;
|
import net.filebot.web.OpenSubtitlesClient;
|
||||||
import net.filebot.web.SearchResult;
|
import net.filebot.web.SearchResult;
|
||||||
@ -261,7 +262,18 @@ public class SubtitlePanel extends AbstractSearchPanel<SubtitleProvider, Subtitl
|
|||||||
|
|
||||||
osdbGroup.add(new JLabel("Password:"), "gap rel");
|
osdbGroup.add(new JLabel("Password:"), "gap rel");
|
||||||
final JPasswordField osdbPass = new JPasswordField(12);
|
final JPasswordField osdbPass = new JPasswordField(12);
|
||||||
osdbGroup.add(osdbPass, "growx, wrap rel");
|
osdbGroup.add(osdbPass, "growx, wrap unrel");
|
||||||
|
|
||||||
|
// restore values
|
||||||
|
String[] osdbAuth = WebServices.getLogin("osdb.user");
|
||||||
|
osdbUser.setText(osdbAuth[0]);
|
||||||
|
osdbPass.setText(osdbAuth[1]);
|
||||||
|
|
||||||
|
if (osdbUser.getText().isEmpty()) {
|
||||||
|
osdbGroup.add(new LinkButton("Register", WebServices.OpenSubtitles.getIcon(), URI.create("http://www.opensubtitles.org/en/newuser")), "spanx 2, tag help");
|
||||||
|
} else {
|
||||||
|
osdbGroup.add(new LinkButton("Upgrade", WebServices.OpenSubtitles.getIcon(), URI.create("http://www.opensubtitles.org/en/support")), "spanx 2, tag help");
|
||||||
|
}
|
||||||
|
|
||||||
JRootPane container = authPanel.getRootPane();
|
JRootPane container = authPanel.getRootPane();
|
||||||
container.setLayout(new MigLayout("fill, insets dialog"));
|
container.setLayout(new MigLayout("fill, insets dialog"));
|
||||||
@ -304,11 +316,6 @@ public class SubtitlePanel extends AbstractSearchPanel<SubtitleProvider, Subtitl
|
|||||||
container.add(new JButton(cancel), "tag cancel, split 2");
|
container.add(new JButton(cancel), "tag cancel, split 2");
|
||||||
container.add(new JButton(ok), "tag ok");
|
container.add(new JButton(ok), "tag ok");
|
||||||
|
|
||||||
// restore values
|
|
||||||
String[] osdbAuth = WebServices.getLogin("osdb.user");
|
|
||||||
osdbUser.setText(osdbAuth[0]);
|
|
||||||
osdbPass.setText(osdbAuth[1]);
|
|
||||||
|
|
||||||
authPanel.pack();
|
authPanel.pack();
|
||||||
authPanel.setVisible(true);
|
authPanel.setVisible(true);
|
||||||
}
|
}
|
||||||
|
@ -423,7 +423,7 @@ public class SubtitleUploadDialog extends JDialog {
|
|||||||
icon = ResourceManager.getIcon("database.ok");
|
icon = ResourceManager.getIcon("database.ok");
|
||||||
break;
|
break;
|
||||||
case Identifying:
|
case Identifying:
|
||||||
text = "Auto-detecting missing information";
|
text = "Auto-detect missing information";
|
||||||
icon = ResourceManager.getIcon("action.export");
|
icon = ResourceManager.getIcon("action.export");
|
||||||
break;
|
break;
|
||||||
case IdentificationRequired:
|
case IdentificationRequired:
|
||||||
|
Loading…
Reference in New Issue
Block a user