forked from j62/ctbrec
1
0
Fork 0

Rename chaturbate username and password setting

This commit is contained in:
0xb00bface 2020-12-05 16:13:56 +01:00
parent f2d3026d0a
commit 8b66dce61a
6 changed files with 30 additions and 15 deletions

View File

@ -45,10 +45,10 @@ public class ChaturbateConfigUi extends AbstractConfigUI {
layout.add(enabled, 1, row++); layout.add(enabled, 1, row++);
layout.add(new Label("Chaturbate User"), 0, row); layout.add(new Label("Chaturbate User"), 0, row);
TextField username = new TextField(Config.getInstance().getSettings().username); TextField username = new TextField(Config.getInstance().getSettings().chaturbateUsername);
username.textProperty().addListener((ob, o, n) -> { username.textProperty().addListener((ob, o, n) -> {
if(!n.equals(Config.getInstance().getSettings().username)) { if(!n.equals(Config.getInstance().getSettings().chaturbateUsername)) {
Config.getInstance().getSettings().username = n; Config.getInstance().getSettings().chaturbateUsername = n;
chaturbate.getHttpClient().logout(); chaturbate.getHttpClient().logout();
save(); save();
} }
@ -60,10 +60,10 @@ public class ChaturbateConfigUi extends AbstractConfigUI {
layout.add(new Label("Chaturbate Password"), 0, row); layout.add(new Label("Chaturbate Password"), 0, row);
PasswordField password = new PasswordField(); PasswordField password = new PasswordField();
password.setText(Config.getInstance().getSettings().password); password.setText(Config.getInstance().getSettings().chaturbatePassword);
password.textProperty().addListener((ob, o, n) -> { password.textProperty().addListener((ob, o, n) -> {
if(!n.equals(Config.getInstance().getSettings().password)) { if(!n.equals(Config.getInstance().getSettings().chaturbatePassword)) {
Config.getInstance().getSettings().password = n; Config.getInstance().getSettings().chaturbatePassword = n;
chaturbate.getHttpClient().logout(); chaturbate.getHttpClient().logout();
save(); save();
} }

View File

@ -11,7 +11,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import ctbrec.Model; import ctbrec.Model;
import ctbrec.StringUtil;
import ctbrec.sites.chaturbate.Chaturbate; import ctbrec.sites.chaturbate.Chaturbate;
import ctbrec.sites.chaturbate.ChaturbateModelParser; import ctbrec.sites.chaturbate.ChaturbateModelParser;
import ctbrec.ui.SiteUiFactory; import ctbrec.ui.SiteUiFactory;
@ -49,7 +48,7 @@ public class ChaturbateUpdateService extends PaginatedScheduledService {
return new Task<List<Model>>() { return new Task<List<Model>>() {
@Override @Override
public List<Model> call() throws IOException { public List<Model> call() throws IOException {
if(loginRequired && StringUtil.isBlank(ctbrec.Config.getInstance().getSettings().username)) { if(loginRequired && !chaturbate.credentialsAvailable()) {
return Collections.emptyList(); return Collections.emptyList();
} else { } else {
String url = ChaturbateUpdateService.this.url + "?page="+page+"&keywords=&_=" + System.currentTimeMillis(); String url = ChaturbateUpdateService.this.url + "?page="+page+"&keywords=&_=" + System.currentTimeMillis();

View File

@ -102,6 +102,7 @@ public class Config {
migrateOldSettings(); migrateOldSettings();
} }
@SuppressWarnings("deprecation")
private void migrateOldSettings() { private void migrateOldSettings() {
// 3.8.0 from maxResolution only to resolution range // 3.8.0 from maxResolution only to resolution range
if(settings.minimumResolution == settings.maximumResolution && settings.minimumResolution == 0) { if(settings.minimumResolution == settings.maximumResolution && settings.minimumResolution == 0) {
@ -128,6 +129,16 @@ public class Config {
settings.postProcessors.add(removeKeepFile); settings.postProcessors.add(removeKeepFile);
settings.removeRecordingAfterPostProcessing = false; settings.removeRecordingAfterPostProcessing = false;
} }
// 3.10.7
if (StringUtil.isNotBlank(settings.username)) {
settings.chaturbateUsername = settings.username;
settings.username = null;
}
if (StringUtil.isNotBlank(settings.password)) {
settings.chaturbatePassword = settings.password;
settings.password = null;
}
} }
private void makeBackup(File source) { private void makeBackup(File source) {

View File

@ -41,6 +41,8 @@ public class Settings {
public String cam4Username = ""; public String cam4Username = "";
public String camsodaPassword = ""; public String camsodaPassword = "";
public String camsodaUsername = ""; public String camsodaUsername = "";
public String chaturbatePassword = "";
public String chaturbateUsername = "";
public String chaturbateBaseUrl = "https://chaturbate.com"; public String chaturbateBaseUrl = "https://chaturbate.com";
public boolean chooseStreamQuality = false; public boolean chooseStreamQuality = false;
public String colorAccent = "#FFFFFF"; public String colorAccent = "#FFFFFF";
@ -93,7 +95,9 @@ public class Settings {
public int onlineCheckIntervalInSecs = 60; public int onlineCheckIntervalInSecs = 60;
public boolean onlineCheckSkipsPausedModels = false; public boolean onlineCheckSkipsPausedModels = false;
public int overviewUpdateIntervalInSecs = 10; public int overviewUpdateIntervalInSecs = 10;
public String password = ""; // chaturbate password TODO maybe rename this onetime @Deprecated
public String password = "";
@Deprecated
public String postProcessing = ""; public String postProcessing = "";
public int postProcessingThreads = 2; public int postProcessingThreads = 2;
public List<PostProcessor> postProcessors = new ArrayList<>(); public List<PostProcessor> postProcessors = new ArrayList<>();
@ -130,7 +134,8 @@ public class Settings {
public boolean transportLayerSecurity = true; public boolean transportLayerSecurity = true;
public int thumbWidth = 180; public int thumbWidth = 180;
public boolean updateThumbnails = true; public boolean updateThumbnails = true;
public String username = ""; // chaturbate username TODO maybe rename this onetime @Deprecated
public String username = "";
public int windowHeight = 800; public int windowHeight = 800;
public boolean windowMaximized = false; public boolean windowMaximized = false;
public int windowWidth = 1340; public int windowWidth = 1340;

View File

@ -56,7 +56,7 @@ public class Chaturbate extends AbstractSite {
@Override @Override
public Double getTokenBalance() throws IOException { public Double getTokenBalance() throws IOException {
String username = Config.getInstance().getSettings().username; String username = Config.getInstance().getSettings().chaturbateUsername;
if (username == null || username.trim().isEmpty()) { if (username == null || username.trim().isEmpty()) {
throw new IOException("Not logged in"); throw new IOException("Not logged in");
} }
@ -157,7 +157,7 @@ public class Chaturbate extends AbstractSite {
@Override @Override
public boolean credentialsAvailable() { public boolean credentialsAvailable() {
String username = Config.getInstance().getSettings().username; String username = Config.getInstance().getSettings().chaturbateUsername;
return username != null && !username.trim().isEmpty(); return username != null && !username.trim().isEmpty();
} }

View File

@ -67,8 +67,8 @@ public class ChaturbateHttpClient extends HttpClient {
LOG.debug("csrf token is {}", token); LOG.debug("csrf token is {}", token);
RequestBody body = new FormBody.Builder() RequestBody body = new FormBody.Builder()
.add("username", Config.getInstance().getSettings().username) .add("username", Config.getInstance().getSettings().chaturbateUsername)
.add("password", Config.getInstance().getSettings().password) .add("password", Config.getInstance().getSettings().chaturbatePassword)
.add("next", "") .add("next", "")
.add("csrfmiddlewaretoken", token) .add("csrfmiddlewaretoken", token)
.build(); .build();
@ -103,7 +103,7 @@ public class ChaturbateHttpClient extends HttpClient {
} }
private boolean checkLogin() throws IOException { private boolean checkLogin() throws IOException {
String url = "https://chaturbate.com/p/" + Config.getInstance().getSettings().username + "/"; String url = "https://chaturbate.com/p/" + Config.getInstance().getSettings().chaturbateUsername + "/";
Request req = new Request.Builder() Request req = new Request.Builder()
.url(url) .url(url)
.header(USER_AGENT, Config.getInstance().getSettings().httpUserAgent) .header(USER_AGENT, Config.getInstance().getSettings().httpUserAgent)