Add setting for chaturbate base URL

This commit is contained in:
0xboobface 2018-12-01 14:17:03 +01:00
parent 0edb17ae9f
commit 7192856c87
6 changed files with 35 additions and 23 deletions

View File

@ -42,14 +42,29 @@ public class ChaturbateConfigUi extends AbstractConfigUI {
GridPane.setColumnSpan(password, 2); GridPane.setColumnSpan(password, 2);
layout.add(password, 1, 1); layout.add(password, 1, 1);
layout.add(new Label("Chaturbate Base URL"), 0, 2);
TextField baseUrl = new TextField();
baseUrl.setText(Config.getInstance().getSettings().chaturbateBaseUrl);
baseUrl.textProperty().addListener((ob, o, n) -> {
Config.getInstance().getSettings().chaturbateBaseUrl = baseUrl.getText();
save();
});
GridPane.setFillWidth(baseUrl, true);
GridPane.setHgrow(baseUrl, Priority.ALWAYS);
GridPane.setColumnSpan(baseUrl, 2);
layout.add(baseUrl, 1, 2);
Button createAccount = new Button("Create new Account"); Button createAccount = new Button("Create new Account");
createAccount.setOnAction((e) -> DesktopIntegration.open(Chaturbate.REGISTRATION_LINK)); createAccount.setOnAction((e) -> DesktopIntegration.open(Chaturbate.REGISTRATION_LINK));
layout.add(createAccount, 1, 2); layout.add(createAccount, 1, 3);
GridPane.setColumnSpan(createAccount, 2); GridPane.setColumnSpan(createAccount, 2);
GridPane.setMargin(username, new Insets(0, 0, 0, SettingsTab.CHECKBOX_MARGIN)); GridPane.setMargin(username, new Insets(0, 0, 0, SettingsTab.CHECKBOX_MARGIN));
GridPane.setMargin(password, new Insets(0, 0, 0, SettingsTab.CHECKBOX_MARGIN)); GridPane.setMargin(password, new Insets(0, 0, 0, SettingsTab.CHECKBOX_MARGIN));
GridPane.setMargin(baseUrl, new Insets(0, 0, 0, SettingsTab.CHECKBOX_MARGIN));
GridPane.setMargin(createAccount, new Insets(0, 0, 0, SettingsTab.CHECKBOX_MARGIN)); GridPane.setMargin(createAccount, new Insets(0, 0, 0, SettingsTab.CHECKBOX_MARGIN));
username.setPrefWidth(300);
return layout; return layout;
} }
} }

View File

@ -1,7 +1,5 @@
package ctbrec.ui.sites.chaturbate; package ctbrec.ui.sites.chaturbate;
import static ctbrec.sites.chaturbate.Chaturbate.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -21,17 +19,17 @@ public class ChaturbateTabProvider extends TabProvider {
public ChaturbateTabProvider(Chaturbate chaturbate) { public ChaturbateTabProvider(Chaturbate chaturbate) {
this.chaturbate = chaturbate; this.chaturbate = chaturbate;
this.recorder = chaturbate.getRecorder(); this.recorder = chaturbate.getRecorder();
this.followedTab = new ChaturbateFollowedTab("Followed", BASE_URI + "/followed-cams/", chaturbate); this.followedTab = new ChaturbateFollowedTab("Followed", chaturbate.getBaseUrl() + "/followed-cams/", chaturbate);
} }
@Override @Override
public List<Tab> getTabs(Scene scene) { public List<Tab> getTabs(Scene scene) {
List<Tab> tabs = new ArrayList<>(); List<Tab> tabs = new ArrayList<>();
tabs.add(createTab("Featured", BASE_URI + "/")); tabs.add(createTab("Featured", chaturbate.getBaseUrl() + "/"));
tabs.add(createTab("Female", BASE_URI + "/female-cams/")); tabs.add(createTab("Female", chaturbate.getBaseUrl() + "/female-cams/"));
tabs.add(createTab("Male", BASE_URI + "/male-cams/")); tabs.add(createTab("Male", chaturbate.getBaseUrl() + "/male-cams/"));
tabs.add(createTab("Couples", BASE_URI + "/couple-cams/")); tabs.add(createTab("Couples", chaturbate.getBaseUrl() + "/couple-cams/"));
tabs.add(createTab("Trans", BASE_URI + "/trans-cams/")); tabs.add(createTab("Trans", chaturbate.getBaseUrl() + "/trans-cams/"));
followedTab.setScene(scene); followedTab.setScene(scene);
followedTab.setRecorder(recorder); followedTab.setRecorder(recorder);
tabs.add(followedTab); tabs.add(followedTab);

View File

@ -43,6 +43,7 @@ public class Settings {
public String postProcessing = ""; public String postProcessing = "";
public String username = ""; // chaturbate username TODO maybe rename this onetime public String username = ""; // chaturbate username TODO maybe rename this onetime
public String password = ""; // chaturbate password TODO maybe rename this onetime public String password = ""; // chaturbate password TODO maybe rename this onetime
public String chaturbateBaseUrl = "https://chaturbate.com";
public String bongaUsername = ""; public String bongaUsername = "";
public String bongaPassword = ""; public String bongaPassword = "";
public String mfcUsername = ""; public String mfcUsername = "";

View File

@ -45,14 +45,14 @@ import okhttp3.Response;
public class Chaturbate extends AbstractSite { public class Chaturbate extends AbstractSite {
private static final transient Logger LOG = LoggerFactory.getLogger(Chaturbate.class); private static final transient Logger LOG = LoggerFactory.getLogger(Chaturbate.class);
public static final String BASE_URI = "https://chaturbate.com"; static String baseUrl = "https://chaturbate.com";
public static final String AFFILIATE_LINK = BASE_URI + "/in/?track=default&tour=grq0&campaign=55vTi"; public static final String AFFILIATE_LINK = "https://chaturbate.com/in/?track=default&tour=grq0&campaign=55vTi";
public static final String REGISTRATION_LINK = BASE_URI + "/in/?track=default&tour=g4pe&campaign=55vTi"; public static final String REGISTRATION_LINK = "https://chaturbate.com/in/?track=default&tour=g4pe&campaign=55vTi";
private ChaturbateHttpClient httpClient; private ChaturbateHttpClient httpClient;
@Override @Override
public void init() throws IOException { public void init() throws IOException {
baseUrl = Config.getInstance().getSettings().chaturbateBaseUrl;
} }
@Override @Override
@ -62,7 +62,7 @@ public class Chaturbate extends AbstractSite {
@Override @Override
public String getBaseUrl() { public String getBaseUrl() {
return "https://chaturbate.com"; return baseUrl;
} }
@Override @Override
@ -139,7 +139,7 @@ public class Chaturbate extends AbstractSite {
@Override @Override
public List<Model> search(String q) throws IOException, InterruptedException { public List<Model> search(String q) throws IOException, InterruptedException {
String url = BASE_URI + "?keywords=" + URLEncoder.encode(q, "utf-8"); String url = baseUrl + "?keywords=" + URLEncoder.encode(q, "utf-8");
List<Model> result = new ArrayList<>(); List<Model> result = new ArrayList<>();
// search online models // search online models
@ -155,7 +155,7 @@ public class Chaturbate extends AbstractSite {
// since chaturbate does not return offline models, we at least try, if the profile page // since chaturbate does not return offline models, we at least try, if the profile page
// exists for the search string // exists for the search string
url = BASE_URI + '/' + q; url = baseUrl + '/' + q;
req = new Request.Builder() req = new Request.Builder()
.url(url) .url(url)
.addHeader("User-Agent", Config.getInstance().getSettings().httpUserAgent) .addHeader("User-Agent", Config.getInstance().getSettings().httpUserAgent)

View File

@ -54,7 +54,7 @@ public class ChaturbateHttpClient extends HttpClient {
try { try {
Request login = new Request.Builder() Request login = new Request.Builder()
.url(Chaturbate.BASE_URI + "/auth/login/") .url(Chaturbate.baseUrl + "/auth/login/")
.build(); .build();
Response response = client.newCall(login).execute(); Response response = client.newCall(login).execute();
String content = response.body().string(); String content = response.body().string();
@ -68,8 +68,8 @@ public class ChaturbateHttpClient extends HttpClient {
.add("csrfmiddlewaretoken", token) .add("csrfmiddlewaretoken", token)
.build(); .build();
login = new Request.Builder() login = new Request.Builder()
.url(Chaturbate.BASE_URI + "/auth/login/") .url(Chaturbate.baseUrl + "/auth/login/")
.header("Referer", Chaturbate.BASE_URI + "/auth/login/") .header("Referer", Chaturbate.baseUrl + "/auth/login/")
.post(body) .post(body)
.build(); .build();

View File

@ -1,7 +1,5 @@
package ctbrec.sites.chaturbate; package ctbrec.sites.chaturbate;
import static ctbrec.sites.chaturbate.Chaturbate.*;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -137,9 +135,9 @@ public class ChaturbateModel extends AbstractModel {
String url = null; String url = null;
if(follow) { if(follow) {
url = BASE_URI + "/follow/follow/" + getName() + "/"; url = getSite().getBaseUrl() + "/follow/follow/" + getName() + "/";
} else { } else {
url = BASE_URI + "/follow/unfollow/" + getName() + "/"; url = getSite().getBaseUrl() + "/follow/unfollow/" + getName() + "/";
} }
RequestBody body = RequestBody.create(null, new byte[0]); RequestBody body = RequestBody.create(null, new byte[0]);