More stuff for BongaCams
This commit is contained in:
parent
26bd482eac
commit
46c3feeb1f
|
@ -2,12 +2,19 @@ package ctbrec.sites.bonga;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.Model;
|
||||
import ctbrec.io.HttpClient;
|
||||
import ctbrec.recorder.Recorder;
|
||||
import ctbrec.sites.AbstractSite;
|
||||
import ctbrec.sites.ConfigUI;
|
||||
import ctbrec.ui.TabProvider;
|
||||
import javafx.scene.Node;
|
||||
import okhttp3.FormBody;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
|
||||
public class BongaCams extends AbstractSite {
|
||||
|
||||
|
@ -29,7 +36,7 @@ public class BongaCams extends AbstractSite {
|
|||
|
||||
@Override
|
||||
public String getAffiliateLink() {
|
||||
return BASE_URL;
|
||||
return "http://bongacams2.com/track?c=610249";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -54,20 +61,43 @@ public class BongaCams extends AbstractSite {
|
|||
|
||||
@Override
|
||||
public Integer getTokenBalance() throws IOException {
|
||||
// TODO Auto-generated method stub
|
||||
String url = BongaCams.BASE_URL + "/tools/amf.php";
|
||||
RequestBody body = new FormBody.Builder()
|
||||
.add("method", "ping")
|
||||
.add("args[]", "66050808")
|
||||
.build();
|
||||
Request request = new Request.Builder()
|
||||
.url(url)
|
||||
.addHeader("User-Agent", "Mozilla/5.0 (Android 9.0; Mobile; rv:61.0) Gecko/61.0 Firefox/61.0")
|
||||
.addHeader("Accept", "application/json, text/javascript, */*")
|
||||
.addHeader("Accept-Language", "en")
|
||||
.addHeader("Referer", BongaCams.BASE_URL)
|
||||
.addHeader("X-Requested-With", "XMLHttpRequest")
|
||||
.post(body)
|
||||
.build();
|
||||
try(Response response = getHttpClient().execute(request, true)) {
|
||||
if(response.isSuccessful()) {
|
||||
JSONObject json = new JSONObject(response.body().string());
|
||||
if(json.optString("status").equals("success")) {
|
||||
System.out.println(json.toString(2));
|
||||
} else {
|
||||
throw new IOException("Request was not successful: " + json.toString(2));
|
||||
}
|
||||
} else {
|
||||
throw new IOException(response.code() + " " + response.message());
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBuyTokensLink() {
|
||||
// TODO Auto-generated method stub
|
||||
return getBaseUrl();
|
||||
return getAffiliateLink();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void login() throws IOException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
getHttpClient().login();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -80,20 +110,18 @@ public class BongaCams extends AbstractSite {
|
|||
|
||||
@Override
|
||||
public void init() throws IOException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
if(httpClient != null) {
|
||||
httpClient.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsTips() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -104,20 +132,18 @@ public class BongaCams extends AbstractSite {
|
|||
|
||||
@Override
|
||||
public boolean isSiteForModel(Model m) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
return m instanceof BongaCamsModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node getConfigurationGui() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
public ConfigUI getConfigurationGui() {
|
||||
return new BongaCamsConfigUI(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean credentialsAvailable() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
String username = Config.getInstance().getSettings().bongaUsername;
|
||||
return username != null && !username.trim().isEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
package ctbrec.sites.bonga;
|
||||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.sites.ConfigUI;
|
||||
import ctbrec.ui.DesktopIntergation;
|
||||
import ctbrec.ui.SettingsTab;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.PasswordField;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.Priority;
|
||||
|
||||
public class BongaCamsConfigUI implements ConfigUI {
|
||||
|
||||
private BongaCams bongaCams;
|
||||
|
||||
public BongaCamsConfigUI(BongaCams bongaCams) {
|
||||
this.bongaCams = bongaCams;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Parent createConfigPanel() {
|
||||
GridPane layout = SettingsTab.createGridLayout();
|
||||
layout.add(new Label("BongaCams User"), 0, 0);
|
||||
TextField username = new TextField(Config.getInstance().getSettings().bongaUsername);
|
||||
username.focusedProperty().addListener((e) -> Config.getInstance().getSettings().bongaUsername = username.getText());
|
||||
GridPane.setFillWidth(username, true);
|
||||
GridPane.setHgrow(username, Priority.ALWAYS);
|
||||
GridPane.setColumnSpan(username, 2);
|
||||
layout.add(username, 1, 0);
|
||||
|
||||
layout.add(new Label("BongaCams Password"), 0, 1);
|
||||
PasswordField password = new PasswordField();
|
||||
password.setText(Config.getInstance().getSettings().bongaPassword);
|
||||
password.focusedProperty().addListener((e) -> Config.getInstance().getSettings().bongaPassword = password.getText());
|
||||
GridPane.setFillWidth(password, true);
|
||||
GridPane.setHgrow(password, Priority.ALWAYS);
|
||||
GridPane.setColumnSpan(password, 2);
|
||||
layout.add(password, 1, 1);
|
||||
|
||||
Button createAccount = new Button("Create new Account");
|
||||
createAccount.setOnAction((e) -> DesktopIntergation.open(bongaCams.getAffiliateLink()));
|
||||
layout.add(createAccount, 1, 2);
|
||||
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(createAccount, new Insets(0, 0, 0, SettingsTab.CHECKBOX_MARGIN));
|
||||
return layout;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,15 +1,58 @@
|
|||
package ctbrec.sites.bonga;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.io.HttpClient;
|
||||
import okhttp3.FormBody;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
|
||||
public class BongaCamsHttpClient extends HttpClient {
|
||||
|
||||
private static final transient Logger LOG = LoggerFactory.getLogger(BongaCamsHttpClient.class);
|
||||
|
||||
@Override
|
||||
public boolean login() throws IOException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
String url = BongaCams.BASE_URL + "/login";
|
||||
String dateTime = new SimpleDateFormat("d.MM.yyyy', 'HH:mm:ss").format(new Date());
|
||||
RequestBody body = new FormBody.Builder()
|
||||
.add("security_log_additional_info","{\"language\":\"en\",\"cookieEnabled\":true,\"javaEnabled\":false,\"flashVersion\":\"31.0.0\",\"dateTime\":\""+dateTime+"\",\"ips\":[\"192.168.0.1\"]}")
|
||||
.add("log_in[username]", Config.getInstance().getSettings().bongaUsername)
|
||||
.add("log_in[password]", Config.getInstance().getSettings().bongaPassword)
|
||||
.add("log_in[remember]", "1")
|
||||
.add("log_in[bfpt]", "")
|
||||
.add("header_form", "1")
|
||||
.build();
|
||||
Request request = new Request.Builder()
|
||||
.url(url)
|
||||
.post(body)
|
||||
.addHeader("User-Agent", "Mozilla/5.0 (Android 9.0; Mobile; rv:61.0) Gecko/61.0 Firefox/61.0")
|
||||
.addHeader("Accept","application/json")
|
||||
.addHeader("Accept-Language", "en")
|
||||
.addHeader("Referer", BongaCams.BASE_URL)
|
||||
.addHeader("X-Requested-With", "XMLHttpRequest")
|
||||
.build();
|
||||
try(Response response = execute(request)) {
|
||||
if(response.isSuccessful()) {
|
||||
JSONObject json = new JSONObject(response.body().string());
|
||||
if(json.optString("status").equals("success")) {
|
||||
return true;
|
||||
} else {
|
||||
LOG.debug("Login response: {}", json.toString(2));
|
||||
throw new IOException("Login not successful");
|
||||
}
|
||||
} else {
|
||||
throw new IOException(response.code() + " " + response.message());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -113,6 +113,7 @@ public class BongaCamsModel extends AbstractModel {
|
|||
if(response.isSuccessful()) {
|
||||
JSONObject json = new JSONObject(response.body().string());
|
||||
if(json.optString("status").equals("success")) {
|
||||
System.out.println(json.toString(2));
|
||||
JSONObject localData = json.getJSONObject("localData");
|
||||
String server = localData.getString("videoServerUrl");
|
||||
return "https:" + server + "/hls/stream_" + getName() + "/playlist.m3u8";
|
||||
|
|
|
@ -61,11 +61,11 @@ public class CamrecApplication extends Application {
|
|||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
sites.add(new BongaCams());
|
||||
sites.add(new Cam4());
|
||||
sites.add(new Camsoda());
|
||||
sites.add(new Chaturbate());
|
||||
sites.add(new MyFreeCams());
|
||||
sites.add(new Camsoda());
|
||||
sites.add(new Cam4());
|
||||
sites.add(new BongaCams());
|
||||
loadConfig();
|
||||
createHttpClient();
|
||||
bus = new AsyncEventBus(Executors.newSingleThreadExecutor());
|
||||
|
|
Loading…
Reference in New Issue