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() {
|
||||
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;
|
||||
|
||||
import static ctbrec.SubsequentAction.*;
|
||||
import static ctbrec.event.Event.Type.*;
|
||||
import static java.lang.Thread.*;
|
||||
import static java.util.concurrent.TimeUnit.*;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import ctbrec.*;
|
||||
import ctbrec.Recording.State;
|
||||
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.IOException;
|
||||
|
@ -14,52 +21,16 @@ import java.security.NoSuchAlgorithmException;
|
|||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
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.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
|
||||
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;
|
||||
import static ctbrec.SubsequentAction.*;
|
||||
import static ctbrec.event.Event.Type.MODEL_ONLINE;
|
||||
import static java.lang.Thread.MAX_PRIORITY;
|
||||
import static java.lang.Thread.MIN_PRIORITY;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
|
||||
public class NextGenLocalRecorder implements Recorder {
|
||||
|
||||
|
@ -146,14 +117,14 @@ public class NextGenLocalRecorder implements Recorder {
|
|||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
LOG.error("Error while getting recording result from download queue", e);
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error in completion handler", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void rescheduleRecordingTask(ScheduledFuture<Recording> future) throws InterruptedException{
|
||||
private void rescheduleRecordingTask(ScheduledFuture<Recording> future) throws InterruptedException {
|
||||
try {
|
||||
if (!future.isDone()) {
|
||||
downloadFutureQueue.put(future);
|
||||
|
@ -266,6 +237,10 @@ public class NextGenLocalRecorder implements Recorder {
|
|||
public void addModel(Model model) throws IOException, InvalidKeyException, NoSuchAlgorithmException {
|
||||
Optional<Model> result = findModel(model);
|
||||
if (result.isEmpty()) {
|
||||
if (config.isIgnored(model)) {
|
||||
throw new ModelIsIgnoredException(model);
|
||||
}
|
||||
|
||||
LOG.info("Model {} added", model);
|
||||
recorderLock.lock();
|
||||
try {
|
||||
|
@ -393,7 +368,7 @@ public class NextGenLocalRecorder implements Recorder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void stopRecording(Model model) throws IOException, InvalidKeyException, NoSuchAlgorithmException {
|
||||
public void stopRecording(Model model) throws IOException {
|
||||
recorderLock.lock();
|
||||
try {
|
||||
if (models.contains(model)) {
|
||||
|
|
Loading…
Reference in New Issue