Merge branch 'dev' into camsoda
This commit is contained in:
commit
02b50f61c5
|
@ -53,6 +53,9 @@ public class Config {
|
||||||
BufferedSource source = buffer.readFrom(fin);
|
BufferedSource source = buffer.readFrom(fin);
|
||||||
settings = adapter.fromJson(source);
|
settings = adapter.fromJson(source);
|
||||||
settings.httpTimeout = Math.max(settings.httpTimeout, 10_000);
|
settings.httpTimeout = Math.max(settings.httpTimeout, 10_000);
|
||||||
|
for (Site site : sites) {
|
||||||
|
site.setEnabled(!settings.disabledSites.contains(site.getName()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LOG.error("Config file does not exist. Falling back to default values.");
|
LOG.error("Config file does not exist. Falling back to default values.");
|
||||||
|
|
|
@ -43,4 +43,5 @@ public class Settings {
|
||||||
public int windowX;
|
public int windowX;
|
||||||
public int windowY;
|
public int windowY;
|
||||||
public int splitRecordings = 0;
|
public int splitRecordings = 0;
|
||||||
|
public List<String> disabledSites = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package ctbrec.sites;
|
||||||
|
|
||||||
|
public abstract class AbstractSite implements Site {
|
||||||
|
|
||||||
|
private boolean enabled;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setEnabled(boolean enabled) {
|
||||||
|
this.enabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,4 +26,6 @@ public interface Site {
|
||||||
public boolean isSiteForModel(Model m);
|
public boolean isSiteForModel(Model m);
|
||||||
public Node getConfigurationGui();
|
public Node getConfigurationGui();
|
||||||
public boolean credentialsAvailable();
|
public boolean credentialsAvailable();
|
||||||
|
public void setEnabled(boolean enabled);
|
||||||
|
public boolean isEnabled();
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ import ctbrec.Model;
|
||||||
import ctbrec.Settings;
|
import ctbrec.Settings;
|
||||||
import ctbrec.io.HttpClient;
|
import ctbrec.io.HttpClient;
|
||||||
import ctbrec.recorder.Recorder;
|
import ctbrec.recorder.Recorder;
|
||||||
import ctbrec.sites.Site;
|
import ctbrec.sites.AbstractSite;
|
||||||
import ctbrec.ui.DesktopIntergation;
|
import ctbrec.ui.DesktopIntergation;
|
||||||
import ctbrec.ui.HtmlParser;
|
import ctbrec.ui.HtmlParser;
|
||||||
import ctbrec.ui.SettingsTab;
|
import ctbrec.ui.SettingsTab;
|
||||||
|
@ -47,7 +47,7 @@ import okhttp3.Request;
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
public class Chaturbate implements Site {
|
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";
|
public static final String BASE_URI = "https://chaturbate.com";
|
||||||
|
|
|
@ -7,7 +7,7 @@ import org.jsoup.select.Elements;
|
||||||
import ctbrec.Config;
|
import ctbrec.Config;
|
||||||
import ctbrec.Model;
|
import ctbrec.Model;
|
||||||
import ctbrec.recorder.Recorder;
|
import ctbrec.recorder.Recorder;
|
||||||
import ctbrec.sites.Site;
|
import ctbrec.sites.AbstractSite;
|
||||||
import ctbrec.ui.DesktopIntergation;
|
import ctbrec.ui.DesktopIntergation;
|
||||||
import ctbrec.ui.HtmlParser;
|
import ctbrec.ui.HtmlParser;
|
||||||
import ctbrec.ui.SettingsTab;
|
import ctbrec.ui.SettingsTab;
|
||||||
|
@ -23,7 +23,7 @@ import javafx.scene.layout.Priority;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
public class MyFreeCams implements Site {
|
public class MyFreeCams extends AbstractSite {
|
||||||
|
|
||||||
public static final String BASE_URI = "https://www.myfreecams.com";
|
public static final String BASE_URI = "https://www.myfreecams.com";
|
||||||
|
|
||||||
|
@ -158,7 +158,6 @@ public class MyFreeCams implements Site {
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean credentialsAvailable() {
|
public boolean credentialsAvailable() {
|
||||||
String username = Config.getInstance().getSettings().mfcUsername;
|
String username = Config.getInstance().getSettings().mfcUsername;
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
@ -67,14 +68,16 @@ public class CamrecApplication extends Application {
|
||||||
hostServices = getHostServices();
|
hostServices = getHostServices();
|
||||||
createRecorder();
|
createRecorder();
|
||||||
for (Site site : sites) {
|
for (Site site : sites) {
|
||||||
try {
|
if(site.isEnabled()) {
|
||||||
site.setRecorder(recorder);
|
try {
|
||||||
site.init();
|
site.setRecorder(recorder);
|
||||||
if (!Objects.equals(System.getenv("CTBREC_DEV"), "1")) {
|
site.init();
|
||||||
site.login();
|
if (!Objects.equals(System.getenv("CTBREC_DEV"), "1")) {
|
||||||
|
site.login();
|
||||||
|
}
|
||||||
|
} catch(Exception e) {
|
||||||
|
LOG.error("Error while initializing site {}", site.getName(), e);
|
||||||
}
|
}
|
||||||
} catch(Exception e) {
|
|
||||||
LOG.error("Error while initializing site {}", site.getName(), e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
createGui(primaryStage);
|
createGui(primaryStage);
|
||||||
|
@ -92,11 +95,16 @@ public class CamrecApplication extends Application {
|
||||||
rootPane = new TabPane();
|
rootPane = new TabPane();
|
||||||
Scene scene = new Scene(rootPane, windowWidth, windowHeight);
|
Scene scene = new Scene(rootPane, windowWidth, windowHeight);
|
||||||
primaryStage.setScene(scene);
|
primaryStage.setScene(scene);
|
||||||
for (Site site : sites) {
|
for (Iterator<Site> iterator = sites.iterator(); iterator.hasNext();) {
|
||||||
SiteTab siteTab = new SiteTab(site, scene);
|
Site site = iterator.next();
|
||||||
rootPane.getTabs().add(siteTab);
|
if(site.isEnabled()) {
|
||||||
|
SiteTab siteTab = new SiteTab(site, scene);
|
||||||
|
rootPane.getTabs().add(siteTab);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
((SiteTab)rootPane.getTabs().get(0)).selected();
|
try {
|
||||||
|
((SiteTab)rootPane.getTabs().get(0)).selected();
|
||||||
|
} catch(ClassCastException | IndexOutOfBoundsException e) {}
|
||||||
|
|
||||||
RecordedModelsTab modelsTab = new RecordedModelsTab("Recording", recorder, sites);
|
RecordedModelsTab modelsTab = new RecordedModelsTab("Recording", recorder, sites);
|
||||||
rootPane.getTabs().add(modelsTab);
|
rootPane.getTabs().add(modelsTab);
|
||||||
|
@ -131,7 +139,9 @@ public class CamrecApplication extends Application {
|
||||||
settingsTab.saveConfig();
|
settingsTab.saveConfig();
|
||||||
recorder.shutdown();
|
recorder.shutdown();
|
||||||
for (Site site : sites) {
|
for (Site site : sites) {
|
||||||
site.shutdown();
|
if(site.isEnabled()) {
|
||||||
|
site.shutdown();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Config.getInstance().save();
|
Config.getInstance().save();
|
||||||
|
|
|
@ -24,8 +24,10 @@ public class ProxySettingsPane extends TitledPane implements EventHandler<Action
|
||||||
private TextField proxyPort = new TextField();
|
private TextField proxyPort = new TextField();
|
||||||
private TextField proxyUser = new TextField();
|
private TextField proxyUser = new TextField();
|
||||||
private PasswordField proxyPassword = new PasswordField();
|
private PasswordField proxyPassword = new PasswordField();
|
||||||
|
private SettingsTab settingsTab;
|
||||||
|
|
||||||
public ProxySettingsPane() {
|
public ProxySettingsPane(SettingsTab settingsTab) {
|
||||||
|
this.settingsTab = settingsTab;
|
||||||
createGui();
|
createGui();
|
||||||
loadConfig();
|
loadConfig();
|
||||||
}
|
}
|
||||||
|
@ -84,7 +86,7 @@ public class ProxySettingsPane extends TitledPane implements EventHandler<Action
|
||||||
@Override
|
@Override
|
||||||
public void handle(ActionEvent event) {
|
public void handle(ActionEvent event) {
|
||||||
setComponentDisableState();
|
setComponentDisableState();
|
||||||
SettingsTab.showRestartRequired();
|
settingsTab.showRestartRequired();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setComponentDisableState() {
|
private void setComponentDisableState() {
|
||||||
|
|
|
@ -13,13 +13,14 @@ import com.sun.javafx.collections.ObservableListWrapper;
|
||||||
|
|
||||||
import ctbrec.Config;
|
import ctbrec.Config;
|
||||||
import ctbrec.Hmac;
|
import ctbrec.Hmac;
|
||||||
|
import ctbrec.Settings;
|
||||||
import ctbrec.sites.Site;
|
import ctbrec.sites.Site;
|
||||||
import javafx.beans.value.ChangeListener;
|
import javafx.beans.value.ChangeListener;
|
||||||
import javafx.beans.value.ObservableValue;
|
import javafx.beans.value.ObservableValue;
|
||||||
|
import javafx.geometry.HPos;
|
||||||
import javafx.geometry.Insets;
|
import javafx.geometry.Insets;
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
import javafx.scene.control.Alert;
|
import javafx.scene.control.Alert;
|
||||||
import javafx.scene.control.Alert.AlertType;
|
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.CheckBox;
|
import javafx.scene.control.CheckBox;
|
||||||
import javafx.scene.control.ComboBox;
|
import javafx.scene.control.ComboBox;
|
||||||
|
@ -41,6 +42,7 @@ import javafx.scene.layout.GridPane;
|
||||||
import javafx.scene.layout.Priority;
|
import javafx.scene.layout.Priority;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
|
import javafx.scene.text.Font;
|
||||||
import javafx.stage.DirectoryChooser;
|
import javafx.stage.DirectoryChooser;
|
||||||
import javafx.stage.FileChooser;;
|
import javafx.stage.FileChooser;;
|
||||||
|
|
||||||
|
@ -64,6 +66,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
|
||||||
private ProxySettingsPane proxySettingsPane;
|
private ProxySettingsPane proxySettingsPane;
|
||||||
private ComboBox<SplitAfterOption> splitAfter;
|
private ComboBox<SplitAfterOption> splitAfter;
|
||||||
private List<Site> sites;
|
private List<Site> sites;
|
||||||
|
private Label restartLabel;
|
||||||
|
|
||||||
public SettingsTab(List<Site> sites) {
|
public SettingsTab(List<Site> sites) {
|
||||||
this.sites = sites;
|
this.sites = sites;
|
||||||
|
@ -74,6 +77,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createGui() {
|
private void createGui() {
|
||||||
|
// set up main layout, 2 columns with VBoxes 50/50
|
||||||
GridPane mainLayout = createGridLayout();
|
GridPane mainLayout = createGridLayout();
|
||||||
mainLayout.setHgap(15);
|
mainLayout.setHgap(15);
|
||||||
mainLayout.setVgap(15);
|
mainLayout.setVgap(15);
|
||||||
|
@ -82,22 +86,33 @@ public class SettingsTab extends Tab implements TabSelectionListener {
|
||||||
cc.setPercentWidth(50);
|
cc.setPercentWidth(50);
|
||||||
mainLayout.getColumnConstraints().setAll(cc, cc);
|
mainLayout.getColumnConstraints().setAll(cc, cc);
|
||||||
setContent(mainLayout);
|
setContent(mainLayout);
|
||||||
|
|
||||||
VBox leftSide = new VBox(15);
|
VBox leftSide = new VBox(15);
|
||||||
VBox rightSide = new VBox(15);
|
VBox rightSide = new VBox(15);
|
||||||
GridPane.setHgrow(leftSide, Priority.ALWAYS);
|
GridPane.setHgrow(leftSide, Priority.ALWAYS);
|
||||||
GridPane.setHgrow(rightSide, Priority.ALWAYS);
|
GridPane.setHgrow(rightSide, Priority.ALWAYS);
|
||||||
GridPane.setFillWidth(leftSide, true);
|
GridPane.setFillWidth(leftSide, true);
|
||||||
GridPane.setFillWidth(rightSide, true);
|
GridPane.setFillWidth(rightSide, true);
|
||||||
mainLayout.add(leftSide, 0, 0);
|
mainLayout.add(leftSide, 0, 1);
|
||||||
mainLayout.add(rightSide, 1, 0);
|
mainLayout.add(rightSide, 1, 1);
|
||||||
|
|
||||||
|
// restart info label
|
||||||
|
restartLabel = new Label("A restart is required to apply changes you made!");
|
||||||
|
restartLabel.setVisible(false);
|
||||||
|
restartLabel.setFont(Font.font(24));
|
||||||
|
restartLabel.setTextFill(Color.RED);
|
||||||
|
mainLayout.add(restartLabel, 0, 0);
|
||||||
|
GridPane.setColumnSpan(restartLabel, 2);
|
||||||
|
GridPane.setHalignment(restartLabel, HPos.CENTER);
|
||||||
|
|
||||||
|
// left side
|
||||||
leftSide.getChildren().add(createGeneralPanel());
|
leftSide.getChildren().add(createGeneralPanel());
|
||||||
leftSide.getChildren().add(createLocationsPanel());
|
leftSide.getChildren().add(createLocationsPanel());
|
||||||
leftSide.getChildren().add(createRecordLocationPanel());
|
leftSide.getChildren().add(createRecordLocationPanel());
|
||||||
proxySettingsPane = new ProxySettingsPane();
|
proxySettingsPane = new ProxySettingsPane(this);
|
||||||
leftSide.getChildren().add(proxySettingsPane);
|
leftSide.getChildren().add(proxySettingsPane);
|
||||||
|
|
||||||
|
//right side
|
||||||
|
rightSide.getChildren().add(createSiteSelectionPanel());
|
||||||
for (Site site : sites) {
|
for (Site site : sites) {
|
||||||
Node siteConfig = site.getConfigurationGui();
|
Node siteConfig = site.getConfigurationGui();
|
||||||
if(siteConfig != null) {
|
if(siteConfig != null) {
|
||||||
|
@ -108,6 +123,34 @@ public class SettingsTab extends Tab implements TabSelectionListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Node createSiteSelectionPanel() {
|
||||||
|
Settings settings = Config.getInstance().getSettings();
|
||||||
|
GridPane layout = createGridLayout();
|
||||||
|
|
||||||
|
int row = 0;
|
||||||
|
for (Site site : sites) {
|
||||||
|
Label l = new Label(site.getName());
|
||||||
|
layout.add(l, 0, row);
|
||||||
|
CheckBox enabled = new CheckBox();
|
||||||
|
enabled.setSelected(!settings.disabledSites.contains(site.getName()));
|
||||||
|
enabled.setOnAction((e) -> {
|
||||||
|
if(enabled.isSelected()) {
|
||||||
|
settings.disabledSites.remove(site.getName());
|
||||||
|
} else {
|
||||||
|
settings.disabledSites.add(site.getName());
|
||||||
|
}
|
||||||
|
showRestartRequired();
|
||||||
|
});
|
||||||
|
GridPane.setMargin(l, new Insets(CHECKBOX_MARGIN, 0, 0, 0));
|
||||||
|
GridPane.setMargin(enabled, new Insets(CHECKBOX_MARGIN, 0, 0, CHECKBOX_MARGIN));
|
||||||
|
layout.add(enabled, 1, row++);
|
||||||
|
}
|
||||||
|
|
||||||
|
TitledPane siteSelection = new TitledPane("Enabled Sites", layout);
|
||||||
|
siteSelection.setCollapsible(false);
|
||||||
|
return siteSelection;
|
||||||
|
}
|
||||||
|
|
||||||
private Node createRecordLocationPanel() {
|
private Node createRecordLocationPanel() {
|
||||||
GridPane layout = createGridLayout();
|
GridPane layout = createGridLayout();
|
||||||
Label l = new Label("Record Location");
|
Label l = new Label("Record Location");
|
||||||
|
@ -284,12 +327,8 @@ public class SettingsTab extends Tab implements TabSelectionListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void showRestartRequired() {
|
void showRestartRequired() {
|
||||||
Alert restart = new AutosizeAlert(AlertType.INFORMATION);
|
restartLabel.setVisible(true);
|
||||||
restart.setTitle("Restart required");
|
|
||||||
restart.setHeaderText("Restart required");
|
|
||||||
restart.setContentText("Changes get applied after a restart of the application");
|
|
||||||
restart.show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GridPane createGridLayout() {
|
public static GridPane createGridLayout() {
|
||||||
|
|
Loading…
Reference in New Issue