Add setting to disable online check for paused models
This commit is contained in:
parent
68cf2635df
commit
0fe16f8ff8
|
@ -151,7 +151,7 @@ public class CamrecApplication extends Application {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onlineMonitor = new OnlineMonitor(recorder);
|
onlineMonitor = new OnlineMonitor(recorder, config);
|
||||||
onlineMonitor.start();
|
onlineMonitor.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
|
||||||
private DiscreteRange<Integer> rangeValues = new DiscreteRange<>(values, labels);
|
private DiscreteRange<Integer> rangeValues = new DiscreteRange<>(values, labels);
|
||||||
private SimpleIntegerProperty concurrentRecordings;
|
private SimpleIntegerProperty concurrentRecordings;
|
||||||
private SimpleIntegerProperty onlineCheckIntervalInSecs;
|
private SimpleIntegerProperty onlineCheckIntervalInSecs;
|
||||||
|
private SimpleBooleanProperty onlineCheckSkipsPausedModels;
|
||||||
private SimpleLongProperty leaveSpaceOnDevice;
|
private SimpleLongProperty leaveSpaceOnDevice;
|
||||||
private SimpleIntegerProperty minimumLengthInSecs;
|
private SimpleIntegerProperty minimumLengthInSecs;
|
||||||
private SimpleStringProperty ffmpegParameters;
|
private SimpleStringProperty ffmpegParameters;
|
||||||
|
@ -146,6 +147,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
|
||||||
postProcessing = new SimpleFileProperty(null, "postProcessing", settings.postProcessing);
|
postProcessing = new SimpleFileProperty(null, "postProcessing", settings.postProcessing);
|
||||||
postProcessingThreads = new SimpleIntegerProperty(null, "postProcessingThreads", settings.postProcessingThreads);
|
postProcessingThreads = new SimpleIntegerProperty(null, "postProcessingThreads", settings.postProcessingThreads);
|
||||||
removeRecordingAfterPp = new SimpleBooleanProperty(null, "removeRecordingAfterPostProcessing", settings.removeRecordingAfterPostProcessing);
|
removeRecordingAfterPp = new SimpleBooleanProperty(null, "removeRecordingAfterPostProcessing", settings.removeRecordingAfterPostProcessing);
|
||||||
|
onlineCheckSkipsPausedModels = new SimpleBooleanProperty(null, "onlineCheckSkipsPausedModels", settings.onlineCheckSkipsPausedModels);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createGui() {
|
private void createGui() {
|
||||||
|
@ -183,10 +185,11 @@ public class SettingsTab extends Tab implements TabSelectionListener {
|
||||||
Setting.of("Split recordings after (minutes)", splitAfter).converter(SplitAfterOption.converter()),
|
Setting.of("Split recordings after (minutes)", splitAfter).converter(SplitAfterOption.converter()),
|
||||||
Setting.of("Restrict Resolution", resolutionRange, "Only record streams with resolution within the given range"),
|
Setting.of("Restrict Resolution", resolutionRange, "Only record streams with resolution within the given range"),
|
||||||
Setting.of("Concurrent Recordings (0 = unlimited)", concurrentRecordings),
|
Setting.of("Concurrent Recordings (0 = unlimited)", concurrentRecordings),
|
||||||
Setting.of("Check online state every (seconds)", onlineCheckIntervalInSecs, "Check every x seconds, if a model came online"),
|
|
||||||
Setting.of("Leave space on device (GiB)", leaveSpaceOnDevice, "Stop recording, if the free space on the device gets below this threshold").converter(new GigabytesConverter()),
|
Setting.of("Leave space on device (GiB)", leaveSpaceOnDevice, "Stop recording, if the free space on the device gets below this threshold").converter(new GigabytesConverter()),
|
||||||
Setting.of("FFmpeg parameters", ffmpegParameters, "FFmpeg parameters to use when merging stream segments"),
|
Setting.of("FFmpeg parameters", ffmpegParameters, "FFmpeg parameters to use when merging stream segments"),
|
||||||
Setting.of("File Extension", fileExtension, "File extension to use for recordings")
|
Setting.of("File Extension", fileExtension, "File extension to use for recordings"),
|
||||||
|
Setting.of("Check online state every (seconds)", onlineCheckIntervalInSecs, "Check every x seconds, if a model came online"),
|
||||||
|
Setting.of("Skip online check for paused models", onlineCheckSkipsPausedModels, "Skip online check for paused models")
|
||||||
),
|
),
|
||||||
Group.of("Location",
|
Group.of("Location",
|
||||||
Setting.of("Record Location", recordLocal),
|
Setting.of("Record Location", recordLocal),
|
||||||
|
|
|
@ -41,6 +41,8 @@ the port ctbrec tries to connect to, if it is run in remote mode.
|
||||||
|
|
||||||
- **livePreviews** (app only) - Enables the live preview feature in the app.
|
- **livePreviews** (app only) - Enables the live preview feature in the app.
|
||||||
|
|
||||||
|
- **minimumResolution** - [1 - 2147483647]. Sets the minimum video height for a recording. ctbrec tries to find a stream quality, which is higher than or equal to this value. If the only provided stream quality is below this threshold, ctbrec won't record the stream.
|
||||||
|
|
||||||
- **maximumResolution** - [1 - 2147483647]. Sets the maximum video height for a recording. ctbrec tries to find a stream quality, which is lower than or equal to this value. If the only provided stream quality is above this threshold, ctbrec won't record the stream.
|
- **maximumResolution** - [1 - 2147483647]. Sets the maximum video height for a recording. ctbrec tries to find a stream quality, which is lower than or equal to this value. If the only provided stream quality is above this threshold, ctbrec won't record the stream.
|
||||||
|
|
||||||
- **minimumLengthInSeconds** - [0 - 2147483647] Automatically delete recordings, which are shorter than this amount of seconds. 0 disables this feature.
|
- **minimumLengthInSeconds** - [0 - 2147483647] Automatically delete recordings, which are shorter than this amount of seconds. 0 disables this feature.
|
||||||
|
@ -49,6 +51,8 @@ the port ctbrec tries to connect to, if it is run in remote mode.
|
||||||
|
|
||||||
- **onlineCheckIntervalInSecs** - [1 - 2147483647] How often ctbrec checks, if a model is online. This is not a guaranteed interval: If you record many models, the online check for all models can take longer than this interval. A minute is a reasonable value, but you can go lower, if you don't want to miss a anything. But don't go too low, or you risk to do too many requests in a short amount of time and get banned by some sites.
|
- **onlineCheckIntervalInSecs** - [1 - 2147483647] How often ctbrec checks, if a model is online. This is not a guaranteed interval: If you record many models, the online check for all models can take longer than this interval. A minute is a reasonable value, but you can go lower, if you don't want to miss a anything. But don't go too low, or you risk to do too many requests in a short amount of time and get banned by some sites.
|
||||||
|
|
||||||
|
- **onlineCheckSkipsPausedModels** - [`true`,`false`] Skip the online check for paused models. If you have many models in the recording list, this can reduce the delay when a recording starts after a model came online.
|
||||||
|
|
||||||
- **postProcessing** - Absolute path to a script, which is executed once a recording is finished. See [Post-Processing](/docs/PostProcessing.md).
|
- **postProcessing** - Absolute path to a script, which is executed once a recording is finished. See [Post-Processing](/docs/PostProcessing.md).
|
||||||
|
|
||||||
- **recordingsDir** - Where ctbrec saves the recordings.
|
- **recordingsDir** - Where ctbrec saves the recordings.
|
||||||
|
|
|
@ -89,6 +89,7 @@ public class Settings {
|
||||||
public List<Model> models = new ArrayList<>();
|
public List<Model> models = new ArrayList<>();
|
||||||
public List<Model> modelsIgnored = new ArrayList<>();
|
public List<Model> modelsIgnored = new ArrayList<>();
|
||||||
public int onlineCheckIntervalInSecs = 60;
|
public int onlineCheckIntervalInSecs = 60;
|
||||||
|
public boolean onlineCheckSkipsPausedModels = false;
|
||||||
public int overviewUpdateIntervalInSecs = 10;
|
public int overviewUpdateIntervalInSecs = 10;
|
||||||
public String password = ""; // chaturbate password TODO maybe rename this onetime
|
public String password = ""; // chaturbate password TODO maybe rename this onetime
|
||||||
public String postProcessing = "";
|
public String postProcessing = "";
|
||||||
|
|
|
@ -38,9 +38,11 @@ public class OnlineMonitor extends Thread {
|
||||||
private Map<Model, Model.State> states = new HashMap<>();
|
private Map<Model, Model.State> states = new HashMap<>();
|
||||||
|
|
||||||
private Map<String, ExecutorService> executors = new HashMap<>();
|
private Map<String, ExecutorService> executors = new HashMap<>();
|
||||||
|
private Config config;
|
||||||
|
|
||||||
public OnlineMonitor(Recorder recorder) {
|
public OnlineMonitor(Recorder recorder, Config config) {
|
||||||
this.recorder = recorder;
|
this.recorder = recorder;
|
||||||
|
this.config = config;
|
||||||
setName("OnlineMonitor");
|
setName("OnlineMonitor");
|
||||||
setDaemon(true);
|
setDaemon(true);
|
||||||
}
|
}
|
||||||
|
@ -80,7 +82,11 @@ public class OnlineMonitor extends Thread {
|
||||||
// submit online check jobs to the executor for the model's site
|
// submit online check jobs to the executor for the model's site
|
||||||
List<Future<?>> futures = new LinkedList<>();
|
List<Future<?>> futures = new LinkedList<>();
|
||||||
for (Model model : models) {
|
for (Model model : models) {
|
||||||
futures.add(updateModel(model));
|
if (config.getSettings().onlineCheckSkipsPausedModels && model.isSuspended()) {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
futures.add(updateModel(model));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// wait for all jobs to finish
|
// wait for all jobs to finish
|
||||||
for (Future<?> future : futures) {
|
for (Future<?> future : futures) {
|
||||||
|
@ -111,7 +117,7 @@ public class OnlineMonitor extends Thread {
|
||||||
model.setLastSeen(Instant.now());
|
model.setLastSeen(Instant.now());
|
||||||
}
|
}
|
||||||
Model.State state = model.getOnlineState(false);
|
Model.State state = model.getOnlineState(false);
|
||||||
LOG.trace("Model online state: {} {}", model.getName(), state);
|
LOG.debug("Model online state: {} {}", model.getName(), state);
|
||||||
Model.State oldState = states.getOrDefault(model, UNKNOWN);
|
Model.State oldState = states.getOrDefault(model, UNKNOWN);
|
||||||
states.put(model, state);
|
states.put(model, state);
|
||||||
if (state != oldState) {
|
if (state != oldState) {
|
||||||
|
@ -134,7 +140,7 @@ public class OnlineMonitor extends Thread {
|
||||||
|
|
||||||
private void suspendUntilNextIteration(List<Model> models, Duration timeCheckTook) {
|
private void suspendUntilNextIteration(List<Model> models, Duration timeCheckTook) {
|
||||||
LOG.trace("Online check for {} models took {} seconds", models.size(), timeCheckTook.getSeconds());
|
LOG.trace("Online check for {} models took {} seconds", models.size(), timeCheckTook.getSeconds());
|
||||||
long sleepTime = Config.getInstance().getSettings().onlineCheckIntervalInSecs;
|
long sleepTime = config.getSettings().onlineCheckIntervalInSecs;
|
||||||
if(timeCheckTook.getSeconds() < sleepTime) {
|
if(timeCheckTook.getSeconds() < sleepTime) {
|
||||||
try {
|
try {
|
||||||
if (running) {
|
if (running) {
|
||||||
|
|
|
@ -106,7 +106,7 @@ public class HttpServer {
|
||||||
safeLogin(site);
|
safeLogin(site);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onlineMonitor = new OnlineMonitor(recorder);
|
onlineMonitor = new OnlineMonitor(recorder, config);
|
||||||
onlineMonitor.start();
|
onlineMonitor.start();
|
||||||
startHttpServer();
|
startHttpServer();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue