forked from j62/ctbrec
1
0
Fork 0

Add setting to disable online check for paused models

This commit is contained in:
0xb00bface 2020-08-09 12:27:04 +02:00
parent 68cf2635df
commit 0fe16f8ff8
6 changed files with 23 additions and 9 deletions

View File

@ -151,7 +151,7 @@ public class CamrecApplication extends Application {
}
}
}
onlineMonitor = new OnlineMonitor(recorder);
onlineMonitor = new OnlineMonitor(recorder, config);
onlineMonitor.start();
}

View File

@ -83,6 +83,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
private DiscreteRange<Integer> rangeValues = new DiscreteRange<>(values, labels);
private SimpleIntegerProperty concurrentRecordings;
private SimpleIntegerProperty onlineCheckIntervalInSecs;
private SimpleBooleanProperty onlineCheckSkipsPausedModels;
private SimpleLongProperty leaveSpaceOnDevice;
private SimpleIntegerProperty minimumLengthInSecs;
private SimpleStringProperty ffmpegParameters;
@ -146,6 +147,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
postProcessing = new SimpleFileProperty(null, "postProcessing", settings.postProcessing);
postProcessingThreads = new SimpleIntegerProperty(null, "postProcessingThreads", settings.postProcessingThreads);
removeRecordingAfterPp = new SimpleBooleanProperty(null, "removeRecordingAfterPostProcessing", settings.removeRecordingAfterPostProcessing);
onlineCheckSkipsPausedModels = new SimpleBooleanProperty(null, "onlineCheckSkipsPausedModels", settings.onlineCheckSkipsPausedModels);
}
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("Restrict Resolution", resolutionRange, "Only record streams with resolution within the given range"),
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("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",
Setting.of("Record Location", recordLocal),

View File

@ -41,13 +41,17 @@ 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.
- **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.
- **minimumLengthInSeconds** - [0 - 2147483647] Automatically delete recordings, which are shorter than this amount of seconds. 0 disables this feature.
- **minimumSpaceLeftInBytes** - [0 - 9223372036854775807] The space in bytes ctbrec should conserve on the hard drive. 1 GiB = 1024 MiB = 1048576 KiB = 1073741824 bytes
- **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).

View File

@ -89,6 +89,7 @@ public class Settings {
public List<Model> models = new ArrayList<>();
public List<Model> modelsIgnored = new ArrayList<>();
public int onlineCheckIntervalInSecs = 60;
public boolean onlineCheckSkipsPausedModels = false;
public int overviewUpdateIntervalInSecs = 10;
public String password = ""; // chaturbate password TODO maybe rename this onetime
public String postProcessing = "";

View File

@ -38,9 +38,11 @@ public class OnlineMonitor extends Thread {
private Map<Model, Model.State> states = 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.config = config;
setName("OnlineMonitor");
setDaemon(true);
}
@ -80,7 +82,11 @@ public class OnlineMonitor extends Thread {
// submit online check jobs to the executor for the model's site
List<Future<?>> futures = new LinkedList<>();
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
for (Future<?> future : futures) {
@ -111,7 +117,7 @@ public class OnlineMonitor extends Thread {
model.setLastSeen(Instant.now());
}
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);
states.put(model, state);
if (state != oldState) {
@ -134,7 +140,7 @@ public class OnlineMonitor extends Thread {
private void suspendUntilNextIteration(List<Model> models, Duration timeCheckTook) {
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) {
try {
if (running) {

View File

@ -106,7 +106,7 @@ public class HttpServer {
safeLogin(site);
}
}
onlineMonitor = new OnlineMonitor(recorder);
onlineMonitor = new OnlineMonitor(recorder, config);
onlineMonitor.start();
startHttpServer();
}