Add check to the recorder, if a model is ignored
Ignored models will not be added. Instead a ModelIsIgnoredException will be thrown
This commit is contained in:
parent
57cecf0818
commit
4ad492721f
|
@ -377,4 +377,9 @@ public class Config {
|
||||||
public void enableSaving() {
|
public void enableSaving() {
|
||||||
savingDisabled = false;
|
savingDisabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isIgnored(Model model) {
|
||||||
|
List<String> ignored = Config.getInstance().getSettings().ignoredModels;
|
||||||
|
return ignored.contains(model.getUrl());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
package ctbrec;
|
||||||
|
|
||||||
|
public class ModelIsIgnoredException extends RuntimeException {
|
||||||
|
private final Model model;
|
||||||
|
|
||||||
|
public ModelIsIgnoredException(Model model) {
|
||||||
|
super("Model " + model.getDisplayName() + " [" + model.getUrl() + "] is ignored");
|
||||||
|
this.model = model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Model getModel() {
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,9 +1,16 @@
|
||||||
package ctbrec.recorder;
|
package ctbrec.recorder;
|
||||||
|
|
||||||
import static ctbrec.SubsequentAction.*;
|
import com.google.common.eventbus.Subscribe;
|
||||||
import static ctbrec.event.Event.Type.*;
|
import ctbrec.*;
|
||||||
import static java.lang.Thread.*;
|
import ctbrec.Recording.State;
|
||||||
import static java.util.concurrent.TimeUnit.*;
|
import ctbrec.event.*;
|
||||||
|
import ctbrec.io.HttpClient;
|
||||||
|
import ctbrec.recorder.download.Download;
|
||||||
|
import ctbrec.recorder.postprocessing.PostProcessingContext;
|
||||||
|
import ctbrec.recorder.postprocessing.PostProcessor;
|
||||||
|
import ctbrec.sites.Site;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -14,52 +21,16 @@ import java.security.NoSuchAlgorithmException;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collections;
|
import java.util.concurrent.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.NoSuchElementException;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.BlockingQueue;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
|
||||||
import java.util.concurrent.ScheduledFuture;
|
|
||||||
import java.util.concurrent.SynchronousQueue;
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import static ctbrec.SubsequentAction.*;
|
||||||
import org.slf4j.LoggerFactory;
|
import static ctbrec.event.Event.Type.MODEL_ONLINE;
|
||||||
|
import static java.lang.Thread.MAX_PRIORITY;
|
||||||
import com.google.common.eventbus.Subscribe;
|
import static java.lang.Thread.MIN_PRIORITY;
|
||||||
|
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||||
import ctbrec.Config;
|
|
||||||
import ctbrec.Model;
|
|
||||||
import ctbrec.ModelGroup;
|
|
||||||
import ctbrec.Recording;
|
|
||||||
import ctbrec.Recording.State;
|
|
||||||
import ctbrec.event.Event;
|
|
||||||
import ctbrec.event.EventBusHolder;
|
|
||||||
import ctbrec.event.ModelIsOnlineEvent;
|
|
||||||
import ctbrec.event.NoSpaceLeftEvent;
|
|
||||||
import ctbrec.event.RecordingStateChangedEvent;
|
|
||||||
import ctbrec.io.HttpClient;
|
|
||||||
import ctbrec.recorder.download.Download;
|
|
||||||
import ctbrec.recorder.postprocessing.PostProcessingContext;
|
|
||||||
import ctbrec.recorder.postprocessing.PostProcessor;
|
|
||||||
import ctbrec.sites.Site;
|
|
||||||
|
|
||||||
public class NextGenLocalRecorder implements Recorder {
|
public class NextGenLocalRecorder implements Recorder {
|
||||||
|
|
||||||
|
@ -266,6 +237,10 @@ public class NextGenLocalRecorder implements Recorder {
|
||||||
public void addModel(Model model) throws IOException, InvalidKeyException, NoSuchAlgorithmException {
|
public void addModel(Model model) throws IOException, InvalidKeyException, NoSuchAlgorithmException {
|
||||||
Optional<Model> result = findModel(model);
|
Optional<Model> result = findModel(model);
|
||||||
if (result.isEmpty()) {
|
if (result.isEmpty()) {
|
||||||
|
if (config.isIgnored(model)) {
|
||||||
|
throw new ModelIsIgnoredException(model);
|
||||||
|
}
|
||||||
|
|
||||||
LOG.info("Model {} added", model);
|
LOG.info("Model {} added", model);
|
||||||
recorderLock.lock();
|
recorderLock.lock();
|
||||||
try {
|
try {
|
||||||
|
@ -393,7 +368,7 @@ public class NextGenLocalRecorder implements Recorder {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stopRecording(Model model) throws IOException, InvalidKeyException, NoSuchAlgorithmException {
|
public void stopRecording(Model model) throws IOException {
|
||||||
recorderLock.lock();
|
recorderLock.lock();
|
||||||
try {
|
try {
|
||||||
if (models.contains(model)) {
|
if (models.contains(model)) {
|
||||||
|
|
Loading…
Reference in New Issue