forked from j62/ctbrec
Add setting for chaturbate base URL
This commit is contained in:
parent
0edb17ae9f
commit
7192856c87
|
@ -42,14 +42,29 @@ public class ChaturbateConfigUi extends AbstractConfigUI {
|
|||
GridPane.setColumnSpan(password, 2);
|
||||
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");
|
||||
createAccount.setOnAction((e) -> DesktopIntegration.open(Chaturbate.REGISTRATION_LINK));
|
||||
layout.add(createAccount, 1, 2);
|
||||
layout.add(createAccount, 1, 3);
|
||||
GridPane.setColumnSpan(createAccount, 2);
|
||||
GridPane.setMargin(username, 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));
|
||||
|
||||
username.setPrefWidth(300);
|
||||
|
||||
return layout;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package ctbrec.ui.sites.chaturbate;
|
||||
|
||||
import static ctbrec.sites.chaturbate.Chaturbate.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -21,17 +19,17 @@ public class ChaturbateTabProvider extends TabProvider {
|
|||
public ChaturbateTabProvider(Chaturbate chaturbate) {
|
||||
this.chaturbate = chaturbate;
|
||||
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
|
||||
public List<Tab> getTabs(Scene scene) {
|
||||
List<Tab> tabs = new ArrayList<>();
|
||||
tabs.add(createTab("Featured", BASE_URI + "/"));
|
||||
tabs.add(createTab("Female", BASE_URI + "/female-cams/"));
|
||||
tabs.add(createTab("Male", BASE_URI + "/male-cams/"));
|
||||
tabs.add(createTab("Couples", BASE_URI + "/couple-cams/"));
|
||||
tabs.add(createTab("Trans", BASE_URI + "/trans-cams/"));
|
||||
tabs.add(createTab("Featured", chaturbate.getBaseUrl() + "/"));
|
||||
tabs.add(createTab("Female", chaturbate.getBaseUrl() + "/female-cams/"));
|
||||
tabs.add(createTab("Male", chaturbate.getBaseUrl() + "/male-cams/"));
|
||||
tabs.add(createTab("Couples", chaturbate.getBaseUrl() + "/couple-cams/"));
|
||||
tabs.add(createTab("Trans", chaturbate.getBaseUrl() + "/trans-cams/"));
|
||||
followedTab.setScene(scene);
|
||||
followedTab.setRecorder(recorder);
|
||||
tabs.add(followedTab);
|
||||
|
|
|
@ -43,6 +43,7 @@ public class Settings {
|
|||
public String postProcessing = "";
|
||||
public String username = ""; // chaturbate username 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 bongaPassword = "";
|
||||
public String mfcUsername = "";
|
||||
|
|
|
@ -45,14 +45,14 @@ import okhttp3.Response;
|
|||
public class Chaturbate extends AbstractSite {
|
||||
|
||||
private static final transient Logger LOG = LoggerFactory.getLogger(Chaturbate.class);
|
||||
public static final String BASE_URI = "https://chaturbate.com";
|
||||
public static final String AFFILIATE_LINK = BASE_URI + "/in/?track=default&tour=grq0&campaign=55vTi";
|
||||
public static final String REGISTRATION_LINK = BASE_URI + "/in/?track=default&tour=g4pe&campaign=55vTi";
|
||||
static String baseUrl = "https://chaturbate.com";
|
||||
public static final String AFFILIATE_LINK = "https://chaturbate.com/in/?track=default&tour=grq0&campaign=55vTi";
|
||||
public static final String REGISTRATION_LINK = "https://chaturbate.com/in/?track=default&tour=g4pe&campaign=55vTi";
|
||||
private ChaturbateHttpClient httpClient;
|
||||
|
||||
@Override
|
||||
public void init() throws IOException {
|
||||
|
||||
baseUrl = Config.getInstance().getSettings().chaturbateBaseUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -62,7 +62,7 @@ public class Chaturbate extends AbstractSite {
|
|||
|
||||
@Override
|
||||
public String getBaseUrl() {
|
||||
return "https://chaturbate.com";
|
||||
return baseUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -139,7 +139,7 @@ public class Chaturbate extends AbstractSite {
|
|||
|
||||
@Override
|
||||
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<>();
|
||||
|
||||
// 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
|
||||
// exists for the search string
|
||||
url = BASE_URI + '/' + q;
|
||||
url = baseUrl + '/' + q;
|
||||
req = new Request.Builder()
|
||||
.url(url)
|
||||
.addHeader("User-Agent", Config.getInstance().getSettings().httpUserAgent)
|
||||
|
|
|
@ -54,7 +54,7 @@ public class ChaturbateHttpClient extends HttpClient {
|
|||
|
||||
try {
|
||||
Request login = new Request.Builder()
|
||||
.url(Chaturbate.BASE_URI + "/auth/login/")
|
||||
.url(Chaturbate.baseUrl + "/auth/login/")
|
||||
.build();
|
||||
Response response = client.newCall(login).execute();
|
||||
String content = response.body().string();
|
||||
|
@ -68,8 +68,8 @@ public class ChaturbateHttpClient extends HttpClient {
|
|||
.add("csrfmiddlewaretoken", token)
|
||||
.build();
|
||||
login = new Request.Builder()
|
||||
.url(Chaturbate.BASE_URI + "/auth/login/")
|
||||
.header("Referer", Chaturbate.BASE_URI + "/auth/login/")
|
||||
.url(Chaturbate.baseUrl + "/auth/login/")
|
||||
.header("Referer", Chaturbate.baseUrl + "/auth/login/")
|
||||
.post(body)
|
||||
.build();
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package ctbrec.sites.chaturbate;
|
||||
|
||||
import static ctbrec.sites.chaturbate.Chaturbate.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -137,9 +135,9 @@ public class ChaturbateModel extends AbstractModel {
|
|||
|
||||
String url = null;
|
||||
if(follow) {
|
||||
url = BASE_URI + "/follow/follow/" + getName() + "/";
|
||||
url = getSite().getBaseUrl() + "/follow/follow/" + getName() + "/";
|
||||
} else {
|
||||
url = BASE_URI + "/follow/unfollow/" + getName() + "/";
|
||||
url = getSite().getBaseUrl() + "/follow/unfollow/" + getName() + "/";
|
||||
}
|
||||
|
||||
RequestBody body = RequestBody.create(null, new byte[0]);
|
||||
|
|
Loading…
Reference in New Issue