forked from j62/ctbrec
Added config param for the chaturbate request throttle
This commit is contained in:
parent
7e3073544e
commit
ff0864bbf7
|
@ -1,6 +1,10 @@
|
|||
4.4.4
|
||||
========================
|
||||
* Fixed Camsoda token label
|
||||
* Removed Camsoda Shows Tab
|
||||
* Added Chaturbate configuration parameter to throttle requests to avoid
|
||||
429 errors. Be aware that this also slows down the online check for Chaturbate
|
||||
models, especially, if you have a lot of models in your list.
|
||||
|
||||
4.4.3
|
||||
========================
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<parent>
|
||||
<groupId>ctbrec</groupId>
|
||||
<artifactId>master</artifactId>
|
||||
<version>4.4.3</version>
|
||||
<version>4.4.4</version>
|
||||
<relativePath>../master</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -84,6 +84,26 @@ public class ChaturbateConfigUi extends AbstractConfigUI {
|
|||
GridPane.setColumnSpan(baseUrl, 2);
|
||||
layout.add(baseUrl, 1, row++);
|
||||
|
||||
layout.add(new Label("Time between requests (ms)"), 0, row);
|
||||
var requestThrottle = new TextField(Integer.toString(Config.getInstance().getSettings().chaturbateMsBetweenRequests));
|
||||
requestThrottle.textProperty().addListener((ob, o, n) -> {
|
||||
int newValue = -1;
|
||||
try {
|
||||
newValue = Integer.parseInt(n);
|
||||
} catch (Exception e) {
|
||||
requestThrottle.setText(o);
|
||||
return;
|
||||
}
|
||||
if (newValue != Config.getInstance().getSettings().chaturbateMsBetweenRequests) {
|
||||
Config.getInstance().getSettings().chaturbateMsBetweenRequests = newValue;
|
||||
save();
|
||||
}
|
||||
});
|
||||
GridPane.setFillWidth(requestThrottle, true);
|
||||
GridPane.setHgrow(requestThrottle, Priority.ALWAYS);
|
||||
GridPane.setColumnSpan(requestThrottle, 2);
|
||||
layout.add(requestThrottle, 1, row++);
|
||||
|
||||
var createAccount = new Button("Create new Account");
|
||||
createAccount.setOnAction(e -> DesktopIntegration.open(Chaturbate.REGISTRATION_LINK));
|
||||
layout.add(createAccount, 1, row);
|
||||
|
@ -91,6 +111,7 @@ public class ChaturbateConfigUi extends AbstractConfigUI {
|
|||
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(requestThrottle, new Insets(0, 0, 0, SettingsTab.CHECKBOX_MARGIN));
|
||||
GridPane.setMargin(createAccount, new Insets(0, 0, 0, SettingsTab.CHECKBOX_MARGIN));
|
||||
|
||||
username.setPrefWidth(300);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<parent>
|
||||
<groupId>ctbrec</groupId>
|
||||
<artifactId>master</artifactId>
|
||||
<version>4.4.3</version>
|
||||
<version>4.4.4</version>
|
||||
<relativePath>../master</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ public class Settings {
|
|||
TIME_OR_SIZE
|
||||
}
|
||||
|
||||
|
||||
public String amateurTvUsername = "";
|
||||
public String amateurTvPassword = "";
|
||||
public String bongacamsBaseUrl = "https://bongacams.com";
|
||||
|
@ -55,6 +56,7 @@ public class Settings {
|
|||
public String chaturbatePassword = "";
|
||||
public String chaturbateUsername = "";
|
||||
public String chaturbateBaseUrl = "https://chaturbate.com";
|
||||
public int chaturbateMsBetweenRequests = 1000;
|
||||
public boolean chooseStreamQuality = false;
|
||||
public String colorAccent = "#FFFFFF";
|
||||
public String colorBase = "#FFFFFF";
|
||||
|
|
|
@ -152,7 +152,7 @@ public class ChaturbateHttpClient extends HttpClient {
|
|||
}
|
||||
|
||||
private static void acquireSlot() throws InterruptedException {
|
||||
long pauseBetweenRequests = 500;
|
||||
long pauseBetweenRequests = Config.getInstance().getSettings().chaturbateMsBetweenRequests;
|
||||
requestThrottle.acquire();
|
||||
long now = System.currentTimeMillis();
|
||||
long millisSinceLastRequest = now - lastRequest;
|
||||
|
|
|
@ -45,7 +45,6 @@ public class ChaturbateModel extends AbstractModel { // NOSONAR
|
|||
private static final Logger LOG = LoggerFactory.getLogger(ChaturbateModel.class);
|
||||
private int[] resolution = new int[2];
|
||||
private transient StreamInfo streamInfo;
|
||||
private long streamInfoTimestamp = 0;
|
||||
|
||||
/**
|
||||
* This constructor exists only for deserialization. Please don't call it directly
|
||||
|
@ -261,12 +260,6 @@ public class ChaturbateModel extends AbstractModel { // NOSONAR
|
|||
}
|
||||
|
||||
private StreamInfo loadStreamInfo() throws IOException, InterruptedException {
|
||||
long now = System.currentTimeMillis();
|
||||
long streamInfoAge = now - streamInfoTimestamp;
|
||||
if (streamInfo != null && streamInfoAge < 5000) {
|
||||
return streamInfo;
|
||||
}
|
||||
|
||||
RequestBody body = new FormBody.Builder()
|
||||
.add("room_slug", getName())
|
||||
.add("bandwidth", "high")
|
||||
|
@ -284,7 +277,6 @@ public class ChaturbateModel extends AbstractModel { // NOSONAR
|
|||
Moshi moshi = new Moshi.Builder().build();
|
||||
JsonAdapter<StreamInfo> adapter = moshi.adapter(StreamInfo.class);
|
||||
streamInfo = adapter.fromJson(content);
|
||||
streamInfoTimestamp = System.currentTimeMillis();
|
||||
return streamInfo;
|
||||
} else {
|
||||
int code = response.code();
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<groupId>ctbrec</groupId>
|
||||
<artifactId>master</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>4.4.3</version>
|
||||
<version>4.4.4</version>
|
||||
|
||||
<modules>
|
||||
<module>../common</module>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<parent>
|
||||
<groupId>ctbrec</groupId>
|
||||
<artifactId>master</artifactId>
|
||||
<version>4.4.3</version>
|
||||
<version>4.4.4</version>
|
||||
<relativePath>../master</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ public class ConfigServlet extends AbstractCtbrecServlet {
|
|||
|
||||
JSONArray json = new JSONArray();
|
||||
addParameter("concurrentRecordings", "Concurrent Recordings", DataType.INTEGER, settings.concurrentRecordings, json);
|
||||
addParameter("chaturbateMsBetweenRequests", "Chaturbate time between requests (ms)", DataType.INTEGER, settings.chaturbateMsBetweenRequests, json);
|
||||
addParameter("ffmpegFileSuffix", "File Suffix", DataType.STRING, settings.ffmpegFileSuffix, json);
|
||||
addParameter("ffmpegMergedDownloadArgs", "FFmpeg Parameters", DataType.STRING, settings.ffmpegMergedDownloadArgs, json);
|
||||
addParameter("httpPort", "HTTP port", DataType.INTEGER, settings.httpPort, json);
|
||||
|
|
Loading…
Reference in New Issue