Add setting to define a default period for "record until"

This commit is contained in:
0xb00bface 2021-12-19 13:26:58 +01:00
parent ea7f56c0fd
commit 923286ae51
4 changed files with 18 additions and 5 deletions

View File

@ -1,3 +1,7 @@
4.6.2
========================
* Add setting to define a default period for "record until"
4.6.1
========================
* Fixed adding of Streamate models

View File

@ -6,6 +6,7 @@ import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import ctbrec.Config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -27,14 +28,15 @@ public class RecordUntilDialog {
private static final Logger LOG = LoggerFactory.getLogger(RecordUntilDialog.class);
private Node source;
private Model model;
private final Node source;
private final Model model;
private final GridPane gridPane = new GridPane();
private RadioButton pauseButton;
private RadioButton removeButton;
private RadioButton recordLaterButton;
private DateTimePicker datePicker;
private GridPane gridPane = new GridPane();
private Config config = Config.getInstance();
public RecordUntilDialog(Node source, Model model) {
this.source = source;
@ -61,7 +63,7 @@ public class RecordUntilDialog {
removeButton = new RadioButton("remove model");
removeButton.setSelected(model.getRecordUntilSubsequentAction() == REMOVE);
removeButton.setToggleGroup(toggleGroup);
recordLaterButton = new RadioButton("mark for later");
RadioButton recordLaterButton = new RadioButton("mark for later");
recordLaterButton.setSelected(model.getRecordUntilSubsequentAction() == RECORD_LATER);
recordLaterButton.setToggleGroup(toggleGroup);
var row = new VBox();
@ -73,6 +75,9 @@ public class RecordUntilDialog {
if (model.isRecordingTimeLimited()) {
var localDate = LocalDateTime.ofInstant(model.getRecordUntil(), ZoneId.systemDefault());
datePicker.setDateTimeValue(localDate);
} else {
var localDate = LocalDateTime.now().plusHours(config.getSettings().recordUntilDefaultPeriodInHours);
datePicker.setDateTimeValue(localDate);
}
}

View File

@ -143,6 +143,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
private SimpleIntegerProperty defaultPriority;
private LocalTimeProperty timeoutRecordingStartingAt;
private LocalTimeProperty timeoutRecordingEndingAt;
private SimpleLongProperty recordUntilDefaultPeriodInHours;
public SettingsTab(List<Site> sites, Recorder recorder) {
this.sites = sites;
@ -212,6 +213,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
defaultPriority = new SimpleIntegerProperty(null, "defaultPriority", settings.defaultPriority);
timeoutRecordingStartingAt = new LocalTimeProperty(null, "timeoutRecordingStartingAt", settings.timeoutRecordingStartingAt);
timeoutRecordingEndingAt = new LocalTimeProperty(null, "timeoutRecordingEndingAt", settings.timeoutRecordingEndingAt);
recordUntilDefaultPeriodInHours = new SimpleLongProperty(null, "recordUntilDefaultPeriodInHours", settings.recordUntilDefaultPeriodInHours);
}
private void createGui() {
@ -265,6 +267,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
Setting.of("Restrict Resolution", resolutionRange, "Only record streams with resolution within the given range"),
Setting.of("Concurrent Recordings (0 = unlimited)", concurrentRecordings),
Setting.of("Default Priority", defaultPriority),
Setting.of("Default period for \"Record until\" (hours)", recordUntilDefaultPeriodInHours),
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"),

View File

@ -161,6 +161,7 @@ public class Settings {
public DirectoryStructure recordingsDirStructure = DirectoryStructure.FLAT;
public List<Model> recordLater = new ArrayList<>();
public boolean recordSingleFile = false;
public long recordUntilDefaultPeriodInHours = 24L;
public boolean removeRecordingAfterPostProcessing = false;
public boolean requireAuthentication = false;
public String servletContext = "";