Convert Logback calls to Slf4j

This commit is contained in:
jafea7 2025-05-02 21:22:26 +10:00 committed by Jafea7
parent 727b38a969
commit 77baa37663
122 changed files with 778 additions and 1005 deletions

View File

@ -55,6 +55,8 @@ import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -76,6 +78,7 @@ import static ctbrec.event.Event.Type.*;
import static javafx.scene.control.TabPane.TabDragPolicy.FIXED;
import static javafx.scene.control.TabPane.TabDragPolicy.REORDER;
@Slf4j
public class CamrecApplication extends Application {
static final Logger LOG = LoggerFactory.getLogger(CamrecApplication.class);
@ -148,18 +151,18 @@ public class CamrecApplication extends Application {
@Subscribe
public void trayActionRequest(Map<String, Object> evt) {
if (Objects.equals("shutdown", evt.get("event"))) {
LOG.debug("Shutdown request from tray icon");
log.debug("Shutdown request from tray icon");
try {
Platform.runLater(() -> {
primaryStage.show();
shutdown();
});
} catch (Exception ex) {
LOG.error(ex.getMessage(), ex);
log.error(ex.getMessage(), ex);
}
}
if (Objects.equals("stage_restored", evt.get("event"))) {
LOG.debug("Main stage restored");
log.debug("Main stage restored");
Platform.runLater(() -> {
if (tabPane.getSelectionModel().getSelectedItem() instanceof TabSelectionListener listener) {
listener.selected();
@ -203,7 +206,7 @@ public class CamrecApplication extends Application {
site.init();
}
} catch (Exception e) {
LOG.error("Error while initializing site {}", site.getName(), e);
log.error("Error while initializing site {}", site.getName(), e);
}
});
}
@ -214,13 +217,13 @@ public class CamrecApplication extends Application {
}
private void logEnvironment() {
LOG.debug("OS:\t{} {}", System.getProperty("os.name"), System.getProperty("os.version"));
LOG.debug("Java:\t{} {} {}", System.getProperty("java.vendor"), System.getProperty("java.vm.name"), System.getProperty("java.version"));
LOG.debug("JavaFX:\t{} ({})", System.getProperty("javafx.version"), System.getProperty("javafx.runtime.version"));
log.debug("OS:\t{} {}", System.getProperty("os.name"), System.getProperty("os.version"));
log.debug("Java:\t{} {} {}", System.getProperty("java.vendor"), System.getProperty("java.vm.name"), System.getProperty("java.version"));
log.debug("JavaFX:\t{} ({})", System.getProperty("javafx.version"), System.getProperty("javafx.runtime.version"));
}
private void createGui(Stage primaryStage) throws IOException {
LOG.debug("Creating GUI");
log.debug("Creating GUI");
DesktopIntegration.setRecorder(recorder);
DesktopIntegration.setPrimaryStage(primaryStage);
CamrecApplication.title = "CTB Recorder " + Version.getVersion();
@ -286,10 +289,10 @@ public class CamrecApplication extends Application {
});
if (config.getSettings().startMinimized) {
LOG.info("Minimize to tray on start");
log.info("Minimize to tray on start");
DesktopIntegration.minimizeToTray(primaryStage);
} else {
LOG.info("Showing primary stage");
log.info("Showing primary stage");
primaryStage.show();
}
primaryStage.setOnCloseRequest(createShutdownHandler());
@ -324,7 +327,7 @@ public class CamrecApplication extends Application {
l.selected();
}
} catch (Exception e) {
LOG.error("Error switching tabs", e);
log.error("Error switching tabs", e);
}
}
@ -363,7 +366,7 @@ public class CamrecApplication extends Application {
}
}
} catch (InvalidKeyException | NoSuchAlgorithmException | IOException ex) {
LOG.warn("Couldn't check, if recordings are running");
log.warn("Couldn't check, if recordings are running");
}
}
@ -392,7 +395,7 @@ public class CamrecApplication extends Application {
try {
Config.getInstance().save();
clearHttpCache();
LOG.info("Shutdown complete. Goodbye!");
log.info("Shutdown complete. Goodbye!");
Platform.runLater(() -> {
primaryStage.close();
shutdownInfo.close();
@ -421,13 +424,13 @@ public class CamrecApplication extends Application {
private void clearHttpCache() throws IOException {
try {
File httpCacheDir = new File(config.getConfigDir(), "cache");
LOG.debug("Deleting http cache {}", httpCacheDir);
log.debug("Deleting http cache {}", httpCacheDir);
HttpClientCacheProvider.getCache(config).evictAll();
HttpClientCacheProvider.getCache(config).close();
IoUtils.deleteDirectory(httpCacheDir);
LOG.debug("Cache has been deleted");
log.debug("Cache has been deleted");
} catch (Exception e) {
LOG.info("The HTTP cache was not completely deleted: {}", e.getLocalizedMessage());
log.info("The HTTP cache was not completely deleted: {}", e.getLocalizedMessage());
}
}
@ -435,9 +438,9 @@ public class CamrecApplication extends Application {
for (EventHandlerConfiguration eventHandlerConfig : Config.getInstance().getSettings().eventHandlers) {
var handler = new EventHandler(eventHandlerConfig);
EventBusHolder.register(handler);
LOG.debug("Registered event handler for {} {}", eventHandlerConfig.getEvent(), eventHandlerConfig.getName());
log.debug("Registered event handler for {} {}", eventHandlerConfig.getEvent(), eventHandlerConfig.getName());
}
LOG.debug("Alert System registered");
log.debug("Alert System registered");
}
private void registerActiveRecordingsCounter() {
@ -454,7 +457,7 @@ public class CamrecApplication extends Application {
Platform.runLater(() -> primaryStage.setTitle(windowTitle));
updateStatus();
} catch (Exception e) {
LOG.warn("Couldn't update window title", e);
log.warn("Couldn't update window title", e);
}
}
}
@ -500,7 +503,7 @@ public class CamrecApplication extends Application {
+ " -fx-control-inner-background-alt: derive(-fx-base, 95%);\n" + "}";
fos.write(content.getBytes(StandardCharsets.UTF_8));
} catch (Exception e) {
LOG.error("Couldn't write stylesheet for user defined color theme");
log.error("Couldn't write stylesheet for user defined color theme");
}
}
@ -548,7 +551,7 @@ public class CamrecApplication extends Application {
try {
recorder = new SimplifiedLocalRecorder(config, sites);
} catch (IOException e) {
LOG.error("Couldn't initialize recorder", e);
log.error("Couldn't initialize recorder", e);
Alert alert = new AutosizeAlert(Alert.AlertType.ERROR, primaryStage.getScene());
alert.setTitle("Whoopsie");
alert.setContentText("Couldn't initialize recorder: " + e.getLocalizedMessage());
@ -563,7 +566,7 @@ public class CamrecApplication extends Application {
try {
Config.init(sites);
} catch (Exception e) {
LOG.error("Couldn't load settings", e);
log.error("Couldn't load settings", e);
Alert alert = new AutosizeAlert(Alert.AlertType.ERROR, primaryStage.getScene());
alert.setTitle("Whoopsie");
alert.setContentText("Couldn't load settings. Falling back to defaults. A backup of your settings has been created.");

View File

@ -6,17 +6,15 @@ import java.security.NoSuchAlgorithmException;
import java.util.List;
import java.util.Objects;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.recorder.Recorder;
import ctbrec.sites.Site;
import javafx.application.Platform;
import javafx.scene.input.Clipboard;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class ClipboardListener implements Runnable {
private static final Logger LOG = LoggerFactory.getLogger(ClipboardListener.class);
private Recorder recorder;
private List<Site> sites;
private Clipboard systemClipboard;
@ -43,7 +41,7 @@ public class ClipboardListener implements Runnable {
addModelIfUrlMatches(url);
}
} catch (Exception e) {
LOG.error("Error in clipboard polling loop", e);
log.error("Error in clipboard polling loop", e);
}
});
}

View File

@ -12,8 +12,7 @@ import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import java.awt.*;
import java.awt.TrayIcon.MessageType;
@ -21,13 +20,12 @@ import java.io.File;
import java.io.IOException;
import java.net.URI;
@Slf4j
public class DesktopIntegration {
private DesktopIntegration() {
}
private static final Logger LOG = LoggerFactory.getLogger(DesktopIntegration.class);
private static Recorder recorder;
private static Stage primaryStage;
private static TrayIcon trayIcon;
@ -42,7 +40,7 @@ public class DesktopIntegration {
rt.exec(cmdline);
return;
} catch (Exception e) {
LOG.debug("Couldn't open URL with user-defined {} {}", cmdline, uri);
log.debug("Couldn't open URL with user-defined {} {}", cmdline, uri);
}
}
@ -51,7 +49,7 @@ public class DesktopIntegration {
CamrecApplication.hostServices.showDocument(uri);
return;
} catch (Exception e) {
LOG.debug("Couldn't open URL with host services {}", uri);
log.debug("Couldn't open URL with host services {}", uri);
}
// opening with HostServices failed, now try Desktop
@ -59,7 +57,7 @@ public class DesktopIntegration {
Desktop.getDesktop().browse(new URI(uri));
return;
} catch (Exception e) {
LOG.debug("Couldn't open URL with Desktop {}", uri);
log.debug("Couldn't open URL with Desktop {}", uri);
}
// try external helpers
@ -69,7 +67,7 @@ public class DesktopIntegration {
rt.exec(helper + " " + uri);
return;
} catch (IOException e) {
LOG.debug("Couldn't open URL with {} {}", helper, uri);
log.debug("Couldn't open URL with {} {}", helper, uri);
}
}
}
@ -111,7 +109,7 @@ public class DesktopIntegration {
Desktop.getDesktop().open(f);
return;
} catch (Exception e) {
LOG.debug("Couldn't open file with Desktop {}", f);
log.debug("Couldn't open file with Desktop {}", f);
}
// try external helpers
@ -122,7 +120,7 @@ public class DesktopIntegration {
rt.exec(helper + " " + f.getAbsolutePath());
return;
} catch (IOException e) {
LOG.debug("Couldn't open file with {} {}", helper, f);
log.debug("Couldn't open file with {} {}", helper, f);
}
}
@ -170,7 +168,7 @@ public class DesktopIntegration {
} catch (NullPointerException e) {
// can happen at start, ignore
} catch (IOException e1) {
LOG.error("Notification failed", e1);
log.error("Notification failed", e1);
}
}
@ -187,7 +185,7 @@ public class DesktopIntegration {
createTrayIcon(primaryStage);
trayIcon.displayMessage(header, msg, MessageType.INFO);
} else {
LOG.error("SystemTray notifications not supported by this OS");
log.error("SystemTray notifications not supported by this OS");
}
}
@ -208,7 +206,7 @@ public class DesktopIntegration {
}
return created;
} else {
LOG.error("SystemTray notifications not supported by this OS");
log.error("SystemTray notifications not supported by this OS");
return false;
}
}

View File

@ -6,17 +6,14 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.io.HttpClient;
import ctbrec.recorder.ProgressListener;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Request;
@Slf4j
public class FileDownload {
private static final Logger LOG = LoggerFactory.getLogger(FileDownload.class);
private HttpClient httpClient;
private ProgressListener downloadListener;
@ -26,7 +23,7 @@ public class FileDownload {
}
public void start(URL url, File target) throws IOException {
LOG.trace("Downloading file {} to {}", url, target);
log.trace("Downloading file {} to {}", url, target);
var request = new Request.Builder().url(url).addHeader("connection", "keep-alive").build();
var response = httpClient.execute(request);
var fileSize = Long.parseLong(response.header("Content-Length", String.valueOf(Long.MAX_VALUE)));

View File

@ -1,20 +1,18 @@
package ctbrec.ui;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.Java;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class Launcher {
private static final Logger LOG = LoggerFactory.getLogger(Launcher.class);
public static void main(String[] args) {
int javaVersion = Java.version();
if(javaVersion == 0) {
LOG.warn("Unknown Java version {}. App might not work as expected", javaVersion);
log.warn("Unknown Java version {}. App might not work as expected", javaVersion);
} else if (javaVersion < 10) {
LOG.error("Your Java version ({}) is too old. Please update to Java 10 or newer", javaVersion);
log.error("Your Java version ({}) is too old. Please update to Java 10 or newer", javaVersion);
System.exit(1);
}
System.setProperty("awt.useSystemAAFontSettings","lcd");

View File

@ -7,8 +7,6 @@ import java.time.LocalDateTime;
import java.time.ZoneId;
import ctbrec.Config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.Model;
import ctbrec.SubsequentAction;
@ -23,11 +21,11 @@ import javafx.scene.control.RadioButton;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class RecordUntilDialog {
private static final Logger LOG = LoggerFactory.getLogger(RecordUntilDialog.class);
private final Node source;
private final Model model;
private final GridPane gridPane = new GridPane();
@ -85,7 +83,7 @@ public class RecordUntilDialog {
boolean confirmed = Dialogs.showCustomInput(source.getScene(), "Stop Recording of " + model.getDisplayName() + " at", gridPane);
if (confirmed) {
SubsequentAction action = getSubsequentAction();
LOG.info("Stop at {} and {}", datePicker.getDateTimeValue(), action);
log.info("Stop at {} and {}", datePicker.getDateTimeValue(), action);
var stopAt = Instant.from(datePicker.getDateTimeValue().atZone(ZoneId.systemDefault()));
model.setRecordUntil(stopAt);
model.setRecordUntilSubsequentAction(action);

View File

@ -4,9 +4,6 @@ import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.GlobalThreadPool;
import ctbrec.Model;
import ctbrec.recorder.download.StreamSource;
@ -19,11 +16,11 @@ import javafx.scene.control.ButtonType;
import javafx.scene.control.ChoiceDialog;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class StreamSourceSelectionDialog extends ChoiceDialog<StreamSource> {
private static final Logger LOG = LoggerFactory.getLogger(StreamSourceSelectionDialog.class);
public static final StreamSource BEST = new BestStreamSource();
public static final StreamSource LOADING = new LoadingStreamSource();
private Scene parent;
@ -66,9 +63,9 @@ public class StreamSourceSelectionDialog extends ChoiceDialog<StreamSource> {
loadStreamSources.get();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
LOG.error("Couldn't fetch available stream sources", e);
log.error("Couldn't fetch available stream sources", e);
} catch (ExecutionException e) {
LOG.error("Couldn't fetch available stream sources", e);
log.error("Couldn't fetch available stream sources", e);
}
boolean confirmed = Dialogs.showConfirmDialog("Error loading stream resolutions", "Do you want to add the model anyway?", "Stream resolutions unknown", parent);

View File

@ -4,9 +4,6 @@ import java.text.DecimalFormat;
import java.util.Objects;
import java.util.concurrent.ExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.GlobalThreadPool;
import ctbrec.sites.Site;
import javafx.application.Platform;
@ -16,10 +13,11 @@ import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
import javafx.scene.control.TextInputDialog;
import javafx.stage.Stage;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class TipDialog extends TextInputDialog {
private static final Logger LOG = LoggerFactory.getLogger(TipDialog.class);
private Site site;
private Scene parent;
@ -84,7 +82,7 @@ public class TipDialog extends TextInputDialog {
}
private void handleExcetion(Exception e) {
LOG.error("Couldn't retrieve account balance", e);
log.error("Couldn't retrieve account balance", e);
showErrorDialog(e);
}

View File

@ -8,17 +8,16 @@ import javafx.application.Platform;
import javafx.concurrent.Task;
import javafx.scene.control.Label;
import javafx.scene.control.Tooltip;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import java.text.DecimalFormat;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ExecutionException;
@Slf4j
public class TokenLabel extends Label {
private static final Logger LOG = LoggerFactory.getLogger(TokenLabel.class);
private double tokens = -1;
private final Site site;
@ -85,7 +84,7 @@ public class TokenLabel extends Label {
}
private void handleException(Exception e) {
LOG.error("Couldn't retrieve account balance", e);
log.error("Couldn't retrieve account balance", e);
Platform.runLater(() -> {
setText("Tokens: error");
setTooltip(new Tooltip(e.getMessage()));

View File

@ -6,8 +6,7 @@ import ctbrec.recorder.Recorder;
import ctbrec.ui.controls.Dialogs;
import javafx.application.Platform;
import javafx.stage.Stage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import javax.imageio.ImageIO;
import javax.swing.*;
@ -26,10 +25,9 @@ import static java.awt.Font.BOLD;
import static java.awt.RenderingHints.KEY_ANTIALIASING;
import static java.awt.RenderingHints.VALUE_ANTIALIAS_ON;
@Slf4j
public class TrayIcon {
private static final Logger LOG = LoggerFactory.getLogger(TrayIcon.class);
private final Stage stage;
private final Recorder recorder;
private SystemTray tray;
@ -60,7 +58,7 @@ public class TrayIcon {
try {
tray.add(awtTrayIcon);
} catch (AWTException e) {
LOG.error("Couldn't add tray icon", e);
log.error("Couldn't add tray icon", e);
}
awtTrayIcon.addMouseListener(new MouseAdapter() {
@Override
@ -73,7 +71,7 @@ public class TrayIcon {
}
return true;
} else {
LOG.error("SystemTray notifications not supported by this OS");
log.error("SystemTray notifications not supported by this OS");
return false;
}
}
@ -113,7 +111,7 @@ public class TrayIcon {
Platform.runLater(() -> {
stage.setX(Config.getInstance().getSettings().windowX);
stage.setY(Config.getInstance().getSettings().windowY);
LOG.debug("Restoring window location {},{}", stage.getX(), stage.getY());
log.debug("Restoring window location {},{}", stage.getX(), stage.getY());
stage.setIconified(false);
stage.show();
stage.toFront();
@ -146,7 +144,7 @@ public class TrayIcon {
awtTrayIcon.setImage(createImage(activeRecordings));
}
} catch (IOException e) {
LOG.error("Couldn't update tray icon image", e);
log.error("Couldn't update tray icon image", e);
}
}

View File

@ -6,19 +6,16 @@ import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.GlobalThreadPool;
import ctbrec.Model;
import ctbrec.recorder.Recorder;
import ctbrec.ui.controls.Dialogs;
import javafx.application.Platform;
import javafx.scene.control.Button;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class CheckModelAccountAction {
private static final Logger LOG = LoggerFactory.getLogger(CheckModelAccountAction.class);
private Button b;
private Recorder recorder;
@ -78,7 +75,7 @@ public class CheckModelAccountAction {
deletedAccounts.add(modelToCheck);
}
} catch (IOException e) {
LOG.warn("Couldn't check, if model account still exists", e);
log.warn("Couldn't check, if model account still exists", e);
}
}
}

View File

@ -6,15 +6,13 @@ import ctbrec.ui.CamrecApplication;
import ctbrec.ui.controls.Dialogs;
import javafx.scene.Cursor;
import javafx.scene.Node;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import java.io.IOException;
import java.util.Optional;
@Slf4j
public class EditNotesAction {
private static final Logger LOG = LoggerFactory.getLogger(EditNotesAction.class);
private final Node source;
private final Model model;
private final Runnable callback;
@ -39,14 +37,14 @@ public class EditNotesAction {
notesService.removeModelNotes(model.getUrl());
}
} catch (IOException e) {
LOG.warn("Couldn't save config", e);
log.warn("Couldn't save config", e);
}
});
if (callback != null) {
try {
callback.run();
} catch (Exception e) {
LOG.error("Error while executing callback", e);
log.error("Error while executing callback", e);
}
}
} catch (Exception e) {

View File

@ -7,20 +7,17 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.function.Consumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.GlobalThreadPool;
import ctbrec.Model;
import ctbrec.ui.controls.Dialogs;
import javafx.application.Platform;
import javafx.scene.Cursor;
import javafx.scene.Node;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class ModelMassEditAction {
private static final Logger LOG = LoggerFactory.getLogger(ModelMassEditAction.class);
protected List<? extends Model> models;
protected Consumer<Model> action;
protected Node source;
@ -64,7 +61,7 @@ public class ModelMassEditAction {
}
}
if (ex != null) {
LOG.error("Error while executing model mass edit", ex);
log.error("Error while executing model mass edit", ex);
Dialogs.showError(source.getScene(), "Error", "Error while execution action", ex);
}
Platform.runLater(() -> source.setCursor(Cursor.DEFAULT));

View File

@ -10,8 +10,7 @@ import javafx.scene.Cursor;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
@ -20,9 +19,8 @@ import java.io.IOException;
import java.util.Arrays;
import java.util.function.Consumer;
@Slf4j
public class SetPortraitAction extends AbstractPortraitAction {
private static final Logger LOG = LoggerFactory.getLogger(SetPortraitAction.class);
private final Consumer<Model> callback;
public SetPortraitAction(Node source, Model selectedModel, Consumer<Model> callback) {
@ -50,7 +48,7 @@ public class SetPortraitAction extends AbstractPortraitAction {
if (StringUtil.isBlank(selectedFile)) {
removePortrait(model.getUrl());
} else {
LOG.debug("User selected {}", selectedFile);
log.debug("User selected {}", selectedFile);
boolean success = processImageFile(selectedFile);
if (success) {
try {
@ -79,7 +77,7 @@ public class SetPortraitAction extends AbstractPortraitAction {
try {
callback.accept(model);
} catch (Exception e) {
LOG.error("Error while executing callback", e);
log.error("Error while executing callback", e);
}
}
}
@ -91,12 +89,12 @@ public class SetPortraitAction extends AbstractPortraitAction {
BufferedImage portrait = convertToScaledJpg(croppedImage);
boolean success = store(model.getUrl(), portrait);
if (!success) {
LOG.debug("Available formats: {}", Arrays.toString(ImageIO.getWriterFormatNames()));
log.debug("Available formats: {}", Arrays.toString(ImageIO.getWriterFormatNames()));
throw new IOException("No suitable writer found for image format " + FORMAT);
}
return success;
} catch (IOException e) {
LOG.error("Error while changing portrait image", e);
log.error("Error while changing portrait image", e);
Dialogs.showError("Set Portrait", "Couldn't change portrait image: ", e);
return false;
}

View File

@ -5,9 +5,6 @@ import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.concurrent.CompletableFuture;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.GlobalThreadPool;
import ctbrec.Model;
import ctbrec.recorder.Recorder;
@ -17,11 +14,10 @@ import ctbrec.ui.tasks.StartRecordingTask;
import javafx.application.Platform;
import javafx.scene.Cursor;
import javafx.scene.Node;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class SetStopDateAction {
private static final Logger LOG = LoggerFactory.getLogger(SetStopDateAction.class);
private Node source;
private Model model;
private Recorder recorder;
@ -48,7 +44,7 @@ public class SetStopDateAction {
}, GlobalThreadPool.get()).whenComplete((r, e) -> {
Platform.runLater(() -> source.setCursor(Cursor.DEFAULT));
if (e != null) {
LOG.error("Error", e);
log.error("Error", e);
}
});
}

View File

@ -8,15 +8,13 @@ import javafx.embed.swing.SwingFXUtils;
import javafx.scene.Cursor;
import javafx.scene.Node;
import javafx.scene.image.Image;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import java.awt.image.BufferedImage;
@Slf4j
public class SetThumbAsPortraitAction extends AbstractPortraitAction {
private static final Logger LOG = LoggerFactory.getLogger(SetThumbAsPortraitAction.class);
private final Image image;
public SetThumbAsPortraitAction(Node source, Model model, Image image) {
@ -35,7 +33,7 @@ public class SetThumbAsPortraitAction extends AbstractPortraitAction {
store(model.getUrl(), portrait);
firePortraitChanged();
} catch (Exception e) {
LOG.error("Error while changing portrait image", e);
log.error("Error while changing portrait image", e);
Platform.runLater(() -> Dialogs.showError("Set Portrait", "Couldn't change portrait image: ", e));
} finally {
Platform.runLater(() -> source.setCursor(Cursor.DEFAULT));

View File

@ -8,8 +8,6 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import org.eclipse.jetty.io.RuntimeIOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.GlobalThreadPool;
import ctbrec.Model;
@ -21,10 +19,10 @@ import ctbrec.ui.controls.Dialogs;
import javafx.application.Platform;
import javafx.scene.Cursor;
import javafx.scene.Node;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class SwitchStreamResolutionAction {
private static final Logger LOG = LoggerFactory.getLogger(SwitchStreamResolutionAction.class);
private Node source;
private Model selectedModel;
private Recorder recorder;
@ -54,7 +52,7 @@ public class SwitchStreamResolutionAction {
try {
recorder.switchStreamSource(selectedModel);
} catch (InvalidKeyException | NoSuchAlgorithmException | IllegalStateException | IOException e) {
LOG.error(couldntSwitchHeaderText, e);
log.error(couldntSwitchHeaderText, e);
Dialogs.showError(source.getScene(), "Couldn't switch stream resolution", "Error while switching stream resolution", e);
}
}

View File

@ -7,20 +7,17 @@ import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.Model;
import ctbrec.event.EventBusHolder;
import ctbrec.ui.SiteUiFactory;
import ctbrec.ui.TipDialog;
import javafx.scene.Cursor;
import javafx.scene.Node;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class TipAction {
private static final Logger LOG = LoggerFactory.getLogger(TipAction.class);
private Model model;
private Node source;
@ -47,7 +44,7 @@ public class TipAction {
event.put("amount", tokens.doubleValue());
EventBusHolder.BUS.post(event);
} catch (IOException ex) {
LOG.error("An error occurred while sending tip", ex);
log.error("An error occurred while sending tip", ex);
showError(source.getScene(), "Couldn't send tip", "An error occurred while sending tip:", ex);
} catch (Exception ex) {
showError(source.getScene(), "Couldn't send tip", "You entered an invalid amount of tokens", ex);

View File

@ -4,9 +4,6 @@ import java.io.File;
import java.io.IOException;
import java.util.Objects;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.StringUtil;
import ctbrec.ui.AutosizeAlert;
import javafx.beans.property.SimpleStringProperty;
@ -25,11 +22,11 @@ import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.paint.Color;
import javafx.stage.FileChooser;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public abstract class AbstractFileSelectionBox extends HBox {
private static final Logger LOG = LoggerFactory.getLogger(AbstractFileSelectionBox.class);
private final StringProperty fileProperty = new SimpleStringProperty();
private final Tooltip validationError = new Tooltip();
protected TextField fileInput;
@ -151,7 +148,7 @@ public abstract class AbstractFileSelectionBox extends HBox {
try {
fileInput.setText(program.getCanonicalPath());
} catch (IOException e1) {
LOG.error("Couldn't determine path", e1);
log.error("Couldn't determine path", e1);
var alert = new AutosizeAlert(Alert.AlertType.ERROR, getScene());
alert.setTitle("Whoopsie");
alert.setContentText("Couldn't determine path");

View File

@ -6,13 +6,11 @@ import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.scene.control.DatePicker;
import javafx.util.StringConverter;
import lombok.extern.slf4j.Slf4j;
/**
* A DateTimePicker with configurable datetime format where both date and time can be changed
@ -25,8 +23,8 @@ import javafx.util.StringConverter;
* license Apache 2.0
*
*/
@Slf4j
public class DateTimePicker extends DatePicker {
private static final Logger LOG = LoggerFactory.getLogger(DateTimePicker.class);
public static final String DefaultFormat = "yyyy-MM-dd HH:mm";
private DateTimeFormatter formatter;
@ -56,7 +54,7 @@ public class DateTimePicker extends DatePicker {
dateTimeValue.set(LocalDateTime.of(newValue, time));
}
}
LOG.debug("{} {}", newValue, dateTimeValue);
log.debug("{} {}", newValue, dateTimeValue);
});
editorProperty().get().textProperty().addListener((obs, ov, nv) -> {

View File

@ -52,8 +52,7 @@ import javafx.scene.input.ContextMenuEvent;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;
import javafx.scene.shape.Rectangle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import java.net.URL;
import java.util.List;
@ -63,8 +62,8 @@ import java.util.Optional;
/**
* Popover page that displays a list of samples and sample categories for a given SampleCategory.
*/
@Slf4j
public class SearchPopoverTreeList extends PopoverTreeList<Model> implements Popover.Page {
private static final Logger LOG = LoggerFactory.getLogger(SearchPopoverTreeList.class);
private Popover popover;
@ -195,9 +194,9 @@ public class SearchPopoverTreeList extends PopoverTreeList<Model> implements Pop
get();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
LOG.warn("Search failed: {}", e.getMessage());
log.warn("Search failed: {}", e.getMessage());
} catch (Exception e) {
LOG.warn("Search failed: {}", e.getMessage());
log.warn("Search failed: {}", e.getMessage());
}
Platform.runLater(() -> setCursor(Cursor.DEFAULT));
}

View File

@ -8,9 +8,6 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.Config;
import ctbrec.GlobalThreadPool;
import ctbrec.Model;
@ -26,10 +23,10 @@ import javafx.scene.layout.StackPane;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.scene.media.MediaView;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class StreamPreview extends StackPane {
private static final Logger LOG = LoggerFactory.getLogger(StreamPreview.class);
private ImageView preview = new ImageView();
private MediaView videoPreview;
private MediaPlayer videoPlayer;
@ -69,7 +66,7 @@ public class StreamPreview extends StackPane {
return;
}
running = true;
LOG.debug("Starting preview stream for model {}", model);
log.debug("Starting preview stream for model {}", model);
progressIndicator.setVisible(true);
if(model.getPreview() != null) {
try {
@ -91,9 +88,9 @@ public class StreamPreview extends StackPane {
List<StreamSource> sources = model.getStreamSources();
Collections.sort(sources);
StreamSource best = sources.get(0);
LOG.debug("StreamSource {}", best);
log.debug("StreamSource {}", best);
checkInterrupt();
LOG.debug("Preview url for {} is {}", model.getName(), best.getMediaPlaylistUrl());
log.debug("Preview url for {} is {}", model.getName(), best.getMediaPlaylistUrl());
video = new Media(best.getMediaPlaylistUrl());
video.setOnError(() -> onError(videoPlayer));
if(videoPlayer != null) {
@ -121,12 +118,12 @@ public class StreamPreview extends StackPane {
if(e.getMessage().equals("Stream url unknown")) {
// fine hls url for mfc not known yet
} else {
LOG.warn("Couldn't start preview video: {}", e.getMessage());
log.warn("Couldn't start preview video: {}", e.getMessage());
}
showTestImage();
} catch (HttpException e) {
if(e.getResponseCode() != 404) {
LOG.warn("Couldn't start preview video: {}", e.getMessage());
log.warn("Couldn't start preview video: {}", e.getMessage());
}
showTestImage();
} catch (InterruptedException | InterruptedIOException e) {
@ -136,11 +133,11 @@ public class StreamPreview extends StackPane {
if(e.getCause() instanceof InterruptedException || e.getCause() instanceof InterruptedIOException) {
// future has been canceled, that's fine
} else {
LOG.warn("Couldn't start preview video: {}", e.getMessage());
log.warn("Couldn't start preview video: {}", e.getMessage());
}
showTestImage();
} catch (Exception e) {
LOG.warn("Couldn't start preview video: {}", e.getMessage());
log.warn("Couldn't start preview video: {}", e.getMessage());
showTestImage();
}
});
@ -169,7 +166,7 @@ public class StreamPreview extends StackPane {
}
private void onError(MediaPlayer videoPlayer) {
LOG.error("Error while starting preview stream", videoPlayer.getError());
log.error("Error while starting preview stream", videoPlayer.getError());
showTestImage();
}

View File

@ -1,8 +1,5 @@
package ctbrec.ui.controls;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
@ -11,10 +8,10 @@ import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class Wizard extends BorderPane {
private static final transient Logger LOG = LoggerFactory.getLogger(Wizard.class);
private Pane[] pages;
private StackPane stack;
private Stage stage;
@ -90,7 +87,7 @@ public class Wizard extends BorderPane {
prev.setDisable(page == 0);
next.setDisable(page == pages.length - 1);
finish.setDisable(page != pages.length - 1);
LOG.debug("Setting border");
log.debug("Setting border");
pages[page].setStyle(
"-fx-background-color: -fx-inner-border, -fx-background;"+
"-fx-background-insets: 0 0 -1 0, 0, 1, 2;");

View File

@ -7,19 +7,16 @@ import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.StringUtil;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class StatePersistingTableView<T> extends TableView<T> {
private static final Logger LOG = LoggerFactory.getLogger(StatePersistingTableView.class);
private Instant initialized;
private TableViewStateStore stateStore;
@ -135,7 +132,7 @@ public class StatePersistingTableView<T> extends TableView<T> {
try {
r.run();
} catch (Exception e) {
LOG.error("Couldn't safe table view state with prefix {}", stateStore.getName(), e);
log.error("Couldn't safe table view state with prefix {}", stateStore.getName(), e);
}
}
}

View File

@ -2,9 +2,6 @@ package ctbrec.ui.menu;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.Model;
import ctbrec.recorder.Recorder;
import ctbrec.ui.action.AbstractModelAction.Result;
@ -12,11 +9,11 @@ import ctbrec.ui.action.FollowAction;
import ctbrec.ui.action.TriConsumer;
import ctbrec.ui.action.UnfollowAction;
import javafx.scene.Node;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class FollowUnfollowHandler {
private static final Logger LOG = LoggerFactory.getLogger(FollowUnfollowHandler.class);
private Node source;
private Recorder recorder;
private TriConsumer<Model, Boolean, Boolean> callback;
@ -32,7 +29,7 @@ public class FollowUnfollowHandler {
r.stream().filter(rs -> rs.getThrowable() == null).map(Result::getModel).forEach(m -> callback.accept(m, true, true));
r.stream().filter(rs -> rs.getThrowable() != null).map(Result::getModel).forEach(m -> callback.accept(m, true, false));
}).exceptionally(ex -> {
LOG.error("Couldn't follow model", ex);
log.error("Couldn't follow model", ex);
return null;
});
}
@ -42,7 +39,7 @@ public class FollowUnfollowHandler {
r.stream().filter(rs -> rs.getThrowable() == null).map(Result::getModel).forEach(m -> callback.accept(m, false, true));
r.stream().filter(rs -> rs.getThrowable() != null).map(Result::getModel).forEach(m -> callback.accept(m, false, false));
}).exceptionally(ex -> {
LOG.error("Couldn't unfollow model", ex);
log.error("Couldn't unfollow model", ex);
return null;
});
}

View File

@ -2,19 +2,16 @@ package ctbrec.ui.menu;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.Model;
import ctbrec.recorder.Recorder;
import ctbrec.ui.action.ForcePriorityAction;
import ctbrec.ui.action.ResumePriorityAction;
import javafx.scene.Node;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class ForcePriorityHandler {
private static final Logger LOG = LoggerFactory.getLogger(ForcePriorityHandler.class);
private Node source;
private Recorder recorder;
private Runnable callback;
@ -28,7 +25,7 @@ public class ForcePriorityHandler {
protected void forcePriority(List<Model> selectedModels) {
new ForcePriorityAction(source, selectedModels, recorder).execute()
.exceptionally(ex -> {
LOG.error("Error while forcing ignore priority", ex);
log.error("Error while forcing ignore priority", ex);
return null;
}).whenComplete((r, ex) -> executeCallback());
}
@ -36,7 +33,7 @@ public class ForcePriorityHandler {
protected void resumePriority(List<Model> selectedModels) {
new ResumePriorityAction(source, selectedModels, recorder).execute()
.exceptionally(ex -> {
LOG.error("Error while resuming respecting priority", ex);
log.error("Error while resuming respecting priority", ex);
return null;
}).whenComplete((r, ex) -> executeCallback());
}
@ -45,7 +42,7 @@ public class ForcePriorityHandler {
try {
callback.run();
} catch (Exception e) {
LOG.error("Error while executing menu callback", e);
log.error("Error while executing menu callback", e);
}
}
}

View File

@ -18,8 +18,7 @@ import javafx.scene.control.SeparatorMenuItem;
import javafx.scene.control.TabPane;
import javafx.scene.input.Clipboard;
import javafx.scene.input.ClipboardContent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import java.net.URLEncoder;
import java.util.List;
@ -28,10 +27,9 @@ import java.util.function.Consumer;
import static java.nio.charset.StandardCharsets.UTF_8;
@Slf4j
public class ModelMenuContributor {
private static final Logger LOG = LoggerFactory.getLogger(ModelMenuContributor.class);
private final Config config;
private final Recorder recorder;
private final Node source;
@ -430,7 +428,7 @@ public class ModelMenuContributor {
new StartRecordingAction(source, models, recorder).execute()
.whenComplete((r, ex) -> {
if (ex != null) {
LOG.error("Error while starting recordings", ex);
log.error("Error while starting recordings", ex);
}
r.stream().map(Result::getModel).forEach(startStopCallback);
});
@ -442,7 +440,7 @@ public class ModelMenuContributor {
new StopRecordingAction(source, models, recorder).execute()
.whenComplete((r, ex) -> {
if (ex != null) {
LOG.error("Error while stopping recordings", ex);
log.error("Error while stopping recordings", ex);
}
r.stream().map(Result::getModel).forEach(startStopCallback);
});
@ -464,7 +462,7 @@ public class ModelMenuContributor {
try {
callback.run();
} catch (Exception e) {
LOG.error("Error while executing menu callback", e);
log.error("Error while executing menu callback", e);
}
}
}

View File

@ -2,19 +2,16 @@ package ctbrec.ui.menu;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.Model;
import ctbrec.recorder.Recorder;
import ctbrec.ui.action.PauseAction;
import ctbrec.ui.action.ResumeAction;
import javafx.scene.Node;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class PauseResumeHandler {
private static final Logger LOG = LoggerFactory.getLogger(PauseResumeHandler.class);
private Node source;
private Recorder recorder;
private Runnable callback;
@ -28,7 +25,7 @@ public class PauseResumeHandler {
protected void pause(List<Model> selectedModels) {
new PauseAction(source, selectedModels, recorder).execute()
.exceptionally(ex -> {
LOG.error("Error while pausing recordings", ex);
log.error("Error while pausing recordings", ex);
return null;
}).whenComplete((r, ex) -> executeCallback());
}
@ -36,7 +33,7 @@ public class PauseResumeHandler {
protected void resume(List<Model> selectedModels) {
new ResumeAction(source, selectedModels, recorder).execute()
.exceptionally(ex -> {
LOG.error("Error while resuming recordings", ex);
log.error("Error while resuming recordings", ex);
return null;
}).whenComplete((r, ex) -> executeCallback());
}
@ -45,7 +42,7 @@ public class PauseResumeHandler {
try {
callback.run();
} catch (Exception e) {
LOG.error("Error while executing menu callback", e);
log.error("Error while executing menu callback", e);
}
}
}

View File

@ -10,16 +10,14 @@ import javafx.scene.Node;
import javafx.scene.control.*;
import javafx.scene.layout.HBox;
import javafx.util.converter.NumberStringConverter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
@Slf4j
public abstract class AbstractPostProcessingPaneFactory {
private static final Logger LOG = LoggerFactory.getLogger(AbstractPostProcessingPaneFactory.class);
private PostProcessor pp;
Set<Property<?>> properties = new HashSet<>();
@ -36,7 +34,7 @@ public abstract class AbstractPostProcessingPaneFactory {
for (Property<?> property : properties) {
String key = property.getName();
Object value = preferences.getSetting(key).get().getProperty().getValue();
LOG.debug("{}={}", key, value);
log.debug("{}={}", key, value);
pp.getConfig().put(key, value.toString());
}
}

View File

@ -34,9 +34,9 @@ import javafx.scene.layout.Priority;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.Window;
import lombok.extern.slf4j.Slf4j;
import org.mapstruct.factory.Mappers;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
@ -52,8 +52,8 @@ import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@Slf4j
public class ActionSettingsPanel extends GridPane {
private static final Logger LOG = LoggerFactory.getLogger(ActionSettingsPanel.class);
private ListView<EventHandlerConfiguration> actionTable;
private final TextField name = new TextField();
@ -123,7 +123,7 @@ public class ActionSettingsPanel extends GridPane {
try {
Config.getInstance().save();
} catch (IOException e) {
LOG.error("Couldn't save config", e);
log.error("Couldn't save config", e);
}
}
@ -203,7 +203,7 @@ public class ActionSettingsPanel extends GridPane {
EventBusHolder.register(handler);
Config.getInstance().getSettings().eventHandlers.add(config);
actionTable.getItems().add(config);
LOG.debug("Registered event handler for {} {}", config.getEvent(), config.getName());
log.debug("Registered event handler for {} {}", config.getEvent(), config.getName());
}
private void validateSettings() {

View File

@ -6,9 +6,6 @@ import java.util.List;
import java.util.Objects;
import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.Config;
import ctbrec.Settings;
import ctbrec.StringUtil;
@ -42,10 +39,10 @@ import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.HBox;
import javafx.util.converter.NumberStringConverter;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class CtbrecPreferencesStorage implements PreferencesStorage {
private static final Logger LOG = LoggerFactory.getLogger(CtbrecPreferencesStorage.class);
public static final String PATTERN_NOT_A_DIGIT = "[^\\d]";
public static final String COULDNT_SAVE_MSG = "Couldn't save config setting";
@ -135,7 +132,7 @@ public class CtbrecPreferencesStorage implements PreferencesStorage {
try {
r.run();
} catch (RuntimeException e) {
LOG.warn("Error while calling \"restart required\" callback", e);
log.warn("Error while calling \"restart required\" callback", e);
}
});
}
@ -324,7 +321,7 @@ public class CtbrecPreferencesStorage implements PreferencesStorage {
}
}
comboBox.valueProperty().addListener((obs, oldV, newV) -> saveValue(() -> {
LOG.debug("Saving setting {}", setting.getKey());
log.debug("Saving setting {}", setting.getKey());
if (setting.getConverter() != null) {
field.set(settings, setting.getConverter().convertFrom(newV)); // NOSONAR
} else {
@ -345,7 +342,7 @@ public class CtbrecPreferencesStorage implements PreferencesStorage {
try {
exe.run();
} catch (Exception e) {
LOG.error(COULDNT_SAVE_MSG, e);
log.error(COULDNT_SAVE_MSG, e);
}
}

View File

@ -5,9 +5,6 @@ import java.io.IOException;
import java.nio.file.Files;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.Config;
import ctbrec.ui.controls.Dialogs;
import javafx.collections.FXCollections;
@ -17,11 +14,11 @@ import javafx.scene.control.ComboBox;
import javafx.scene.control.ListCell;
import javafx.scene.layout.HBox;
import javafx.scene.text.Font;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class FontSettingsPane extends HBox {
private static final Logger LOG = LoggerFactory.getLogger(FontSettingsPane.class);
private ComboBox<String> fontFaceCombo;
private ComboBox<Integer> fontSizeCombo;
@ -78,7 +75,7 @@ public class FontSettingsPane extends HBox {
Files.writeString(getFontCssFile().toPath(), css);
settingsTab.showRestartRequired();
} catch (IOException e) {
LOG.error("Couldn't write font file", e);
log.error("Couldn't write font file", e);
Dialogs.showError(getScene(), "Error saving configuration", "The font stylesheet file couldn't be written", e);
}
}
@ -94,7 +91,7 @@ public class FontSettingsPane extends HBox {
Files.delete(getFontCssFile().toPath());
settingsTab.showRestartRequired();
} catch (IOException e) {
LOG.error("Couldn't delete font file", e);
log.error("Couldn't delete font file", e);
Dialogs.showError(getScene(), "Error resetting font configuration", "The font stylesheet file couldn't be deleted", e);
}
});

View File

@ -36,8 +36,7 @@ import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.util.Duration;
import lombok.Getter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import java.io.IOException;
import java.util.ArrayList;
@ -49,9 +48,9 @@ import static ctbrec.Settings.ProxyType.*;
import static ctbrec.Settings.SplitStrategy.*;
import static java.util.Optional.ofNullable;
@Slf4j
public class SettingsTab extends Tab implements TabSelectionListener {
private static final Logger LOG = LoggerFactory.getLogger(SettingsTab.class);
public static final int CHECKBOX_MARGIN = 6;
private static final long MiB = 1024 * 1024L; // NOSONAR
private static final long GiB = 1024 * MiB; // NOSONAR
@ -402,7 +401,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
try {
DocServer.start();
} catch (Exception ex) {
LOG.error("Couldn't start documentation server", ex);
log.error("Couldn't start documentation server", ex);
}
}).start();
DesktopIntegration.open(url);
@ -420,7 +419,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
try {
s.getGui().disableProperty().bind(bindTo);
} catch (Exception e) {
LOG.error("Couldn't bind disableProperty of {}", s.getName(), e);
log.error("Couldn't bind disableProperty of {}", s.getName(), e);
}
}
@ -501,7 +500,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
try {
Config.getInstance().save();
} catch (IOException e) {
LOG.error("Couldn't save config", e);
log.error("Couldn't save config", e);
}
});
}

View File

@ -2,20 +2,17 @@ package ctbrec.ui.sites;
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.Config;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public abstract class AbstractConfigUI implements ConfigUI {
private static final Logger LOG = LoggerFactory.getLogger(AbstractConfigUI.class);
protected void save() {
try {
Config.getInstance().save();
} catch (IOException e) {
LOG.error("Couldn't save config");
log.error("Couldn't save config");
}
}
}

View File

@ -3,26 +3,24 @@ package ctbrec.ui.sites.bonga;
import ctbrec.Config;
import ctbrec.sites.bonga.BongaCams;
import ctbrec.ui.ExternalBrowser;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Cookie;
import okhttp3.Cookie.Builder;
import okhttp3.CookieJar;
import okhttp3.HttpUrl;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.MalformedURLException;
// import java.net.URL;
import java.net.URI;
// import java.net.URL;
import java.net.URISyntaxException;
import java.util.Collections;
import java.util.Objects;
import java.util.function.Consumer;
@Slf4j
public class BongaCamsElectronLoginDialog {
private static final Logger LOG = LoggerFactory.getLogger(BongaCamsElectronLoginDialog.class);
public static final String DOMAIN = "bongacams.com";
private BongaCams site;
private CookieJar cookieJar;
@ -50,7 +48,7 @@ public class BongaCamsElectronLoginDialog {
private final Consumer<String> msgHandler = line -> {
if (!line.startsWith("{")) {
LOG.error("Didn't received a JSON object {}", line);
log.error("Didn't received a JSON object {}", line);
} else {
var json = new JSONObject(line);
if (json.has("url")) {
@ -79,9 +77,9 @@ public class BongaCamsElectronLoginDialog {
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
LOG.warn("Couldn't auto fill username and password for BongaCams", e);
log.warn("Couldn't auto fill username and password for BongaCams", e);
} catch (Exception e) {
LOG.warn("Couldn't auto fill username and password for BongaCams", e);
log.warn("Couldn't auto fill username and password for BongaCams", e);
}
}
@ -118,11 +116,11 @@ public class BongaCamsElectronLoginDialog {
browser.close();
}
} catch (MalformedURLException e) {
LOG.error("Couldn't parse new url {}", url, e);
log.error("Couldn't parse new url {}", url, e);
} catch (IOException e) {
LOG.error("Couldn't send shutdown request to external browser", e);
log.error("Couldn't send shutdown request to external browser", e);
} catch (URISyntaxException e) {
LOG.error("Invalid URL: " + url);
log.error("Invalid URL: " + url);
}
}
}

View File

@ -6,14 +6,12 @@ import ctbrec.ui.controls.Dialogs;
import ctbrec.ui.sites.AbstractSiteUi;
import ctbrec.ui.sites.ConfigUI;
import ctbrec.ui.tabs.TabProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import java.io.IOException;
@Slf4j
public class BongaCamsSiteUi extends AbstractSiteUi {
private static final Logger LOG = LoggerFactory.getLogger(BongaCamsSiteUi.class);
private final BongaCams bongaCams;
private BongaCamsTabProvider tabProvider;
private BongaCamsConfigUI configUi;
@ -48,16 +46,16 @@ public class BongaCamsSiteUi extends AbstractSiteUi {
try {
new BongaCamsElectronLoginDialog(bongaCams, bongaCams.getHttpClient().getCookieJar());
} catch (Exception e1) {
LOG.error("Error logging in with external browser", e1);
log.error("Error logging in with external browser", e1);
Dialogs.showError("Login error", "Couldn't login to " + bongaCams.getName(), e1);
}
BongaCamsHttpClient httpClient = (BongaCamsHttpClient) bongaCams.getHttpClient();
boolean loggedIn = httpClient.checkLoginSuccess();
if (loggedIn) {
LOG.info("Logged in. User ID is {}", httpClient.getUserId());
log.info("Logged in. User ID is {}", httpClient.getUserId());
} else {
LOG.info("Login failed");
log.info("Login failed");
}
return loggedIn;
}

View File

@ -8,11 +8,10 @@ import ctbrec.sites.bonga.BongaCamsModel;
import ctbrec.ui.SiteUiFactory;
import ctbrec.ui.tabs.PaginatedScheduledService;
import javafx.concurrent.Task;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Request;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList;
@ -21,10 +20,9 @@ import java.util.Locale;
import static ctbrec.io.HttpConstants.*;
@Slf4j
public class BongaCamsUpdateService extends PaginatedScheduledService {
private static final Logger LOG = LoggerFactory.getLogger(BongaCamsUpdateService.class);
private final BongaCams bongaCams;
private final String url;
private final boolean requiresLogin;
@ -55,7 +53,7 @@ public class BongaCamsUpdateService extends PaginatedScheduledService {
private List<Model> loadModelList() throws IOException {
String pageUrl = url + ((page - 1) * 72);
LOG.debug("Fetching page {}", pageUrl);
log.debug("Fetching page {}", pageUrl);
var request = new Request.Builder()
.url(pageUrl)
.header(USER_AGENT, Config.getInstance().getSettings().httpUserAgent)

View File

@ -6,20 +6,19 @@ import java.util.Optional;
import java.util.function.Consumer;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.Config;
import ctbrec.sites.cam4.Cam4;
import ctbrec.ui.ExternalBrowser;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Cookie;
import okhttp3.Cookie.Builder;
import okhttp3.CookieJar;
import okhttp3.HttpUrl;
@Slf4j
public class Cam4ElectronLoginDialog {
private static final Logger LOG = LoggerFactory.getLogger(Cam4ElectronLoginDialog.class);
public static final String DOMAIN = "cam4.com";
public static final String URL = Cam4.BASE_URI;
private CookieJar cookieJar;
@ -50,7 +49,7 @@ public class Cam4ElectronLoginDialog {
private Consumer<String> msgHandler = line -> {
if(!line.startsWith("{")) {
LOG.error("Didn't received a JSON object {}", line);
log.error("Didn't received a JSON object {}", line);
} else {
var json = new JSONObject(line);
safeCookies(json);
@ -81,12 +80,12 @@ public class Cam4ElectronLoginDialog {
private void checkIfLoggedIn() {
try {
browser.executeJavaScript("document.querySelector('a[id*=\"mainHeader_userMenuContent-logout\"]').text").thenAccept(r -> {
LOG.debug("Result from browser is {}", r);
log.debug("Result from browser is {}", r);
// found the logout button, we can close the browser, the login was successful
closeBrowser();
}).exceptionally(ex -> null);
} catch (IOException e) {
LOG.error("Check, if logged in failed", e);
log.error("Check, if logged in failed", e);
}
}
@ -99,7 +98,7 @@ public class Cam4ElectronLoginDialog {
+ "if (cookieButton) { cookieButton.click(); }");
dialogsClicked = true;
} catch (Exception e) {
LOG.warn("Couldn't click on cookie and age acknowlegde buttons for Cam4", e);
log.warn("Couldn't click on cookie and age acknowlegde buttons for Cam4", e);
}
}
}
@ -132,7 +131,7 @@ public class Cam4ElectronLoginDialog {
+ "if (loginButton) { loginButton.click(); }");
loginDialogOpened = true;
} catch (Exception e) {
LOG.warn("Couldn't open login dialog for Cam4", e);
log.warn("Couldn't open login dialog for Cam4", e);
}
}
}
@ -150,7 +149,7 @@ public class Cam4ElectronLoginDialog {
browser.executeJavaScript("document.querySelector('input[id*=\"loginFrom_passwordInput\"]').value = '" + password + "');");
}
} catch (Exception e) {
LOG.warn("Couldn't auto fill username and password for Cam4", e);
log.warn("Couldn't auto fill username and password for Cam4", e);
}
}
@ -159,7 +158,7 @@ public class Cam4ElectronLoginDialog {
try {
browser.executeJavaScript("document.querySelector('button[id*=\"loginFrom_submitButton\"]').click();");
} catch (Exception e) {
LOG.warn("Couldn't click on login button for Cam4", e);
log.warn("Couldn't click on login button for Cam4", e);
}
}
@ -187,7 +186,7 @@ public class Cam4ElectronLoginDialog {
Optional.ofNullable(loginChecker).ifPresent(Thread::interrupt);
browser.close();
} catch(IOException e) {
LOG.error("Couldn't send close request to browser", e);
log.error("Couldn't send close request to browser", e);
}
}
}

View File

@ -7,10 +7,9 @@ import ctbrec.sites.cam4.Cam4Model;
import ctbrec.ui.SiteUiFactory;
import ctbrec.ui.tabs.PaginatedScheduledService;
import javafx.concurrent.Task;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Request;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList;
@ -19,10 +18,9 @@ import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@Slf4j
public class Cam4FollowedUpdateService extends PaginatedScheduledService {
private static final Logger LOG = LoggerFactory.getLogger(Cam4FollowedUpdateService.class);
private final Cam4 site;
private boolean showOnline = true;
@ -55,7 +53,7 @@ public class Cam4FollowedUpdateService extends PaginatedScheduledService {
// login first
SiteUiFactory.getUi(site).login();
String url = site.getBaseUrl() + "/directoryCams?directoryJson=true&online=" + showOnline + "&url=true&friends=true&favorites=true&resultsPerPage=90";
LOG.debug("Fetching page {}", url);
log.debug("Fetching page {}", url);
Request req = new Request.Builder().url(url).build();
try (var response = site.getHttpClient().execute(req)) {
if (response.isSuccessful()) {

View File

@ -2,19 +2,16 @@ package ctbrec.ui.sites.cam4;
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.sites.cam4.Cam4;
import ctbrec.sites.cam4.Cam4HttpClient;
import ctbrec.ui.controls.Dialogs;
import ctbrec.ui.sites.AbstractSiteUi;
import ctbrec.ui.sites.ConfigUI;
import ctbrec.ui.tabs.TabProvider;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class Cam4SiteUi extends AbstractSiteUi {
private static final Logger LOG = LoggerFactory.getLogger(Cam4SiteUi.class);
private final Cam4 cam4;
private Cam4TabProvider tabProvider;
private Cam4ConfigUI configUi;
@ -49,7 +46,7 @@ public class Cam4SiteUi extends AbstractSiteUi {
try {
new Cam4ElectronLoginDialog(cam4.getHttpClient().getCookieJar());
} catch (Exception e1) {
LOG.error("Error logging in with external browser", e1);
log.error("Error logging in with external browser", e1);
Dialogs.showError("Login error", "Couldn't login to " + cam4.getName(), e1);
}
Cam4HttpClient httpClient = (Cam4HttpClient) cam4.getHttpClient();

View File

@ -9,11 +9,10 @@ import ctbrec.sites.cam4.Cam4Model;
import ctbrec.ui.SiteUiFactory;
import ctbrec.ui.tabs.PaginatedScheduledService;
import javafx.concurrent.Task;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Request;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList;
@ -27,9 +26,9 @@ import static ctbrec.Model.State.ONLINE;
import static ctbrec.io.HttpConstants.ACCEPT_LANGUAGE;
import static ctbrec.io.HttpConstants.USER_AGENT;
@Slf4j
public class Cam4UpdateService extends PaginatedScheduledService {
private static final Logger LOG = LoggerFactory.getLogger(Cam4UpdateService.class);
private String url;
private final Cam4 site;
private final boolean loginRequired;
@ -57,7 +56,7 @@ public class Cam4UpdateService extends PaginatedScheduledService {
return Collections.emptyList();
} else {
String pageUrl = Cam4UpdateService.this.url + "&page=" + page;
LOG.debug("Fetching page {}", pageUrl);
log.debug("Fetching page {}", pageUrl);
if (loginRequired) {
SiteUiFactory.getUi(site).login();
}

View File

@ -3,25 +3,24 @@ package ctbrec.ui.sites.chaturbate;
import ctbrec.Config;
import ctbrec.sites.chaturbate.Chaturbate;
import ctbrec.ui.ExternalBrowser;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Cookie;
import okhttp3.Cookie.Builder;
import okhttp3.CookieJar;
import okhttp3.HttpUrl;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.net.URISyntaxException;
import java.util.Collections;
import java.util.Objects;
import java.util.function.Consumer;
@Slf4j
public class ChaturbateElectronLoginDialog {
private static final Logger LOG = LoggerFactory.getLogger(ChaturbateElectronLoginDialog.class);
public static final String DOMAIN = "chaturbate.com";
private Chaturbate site;
private CookieJar cookieJar;
@ -50,7 +49,7 @@ public class ChaturbateElectronLoginDialog {
private final Consumer<String> msgHandler = line -> {
if (!line.startsWith("{")) {
LOG.error("Didn't received a JSON object {}", line);
log.error("Didn't received a JSON object {}", line);
} else {
var json = new JSONObject(line);
if (json.has("url")) {
@ -77,9 +76,9 @@ public class ChaturbateElectronLoginDialog {
browser.executeJavaScript("document.querySelector('form[action*=login]').submit()");
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
LOG.warn("Couldn't auto fill username and password for Chaturbate", e);
log.warn("Couldn't auto fill username and password for Chaturbate", e);
} catch (Exception e) {
LOG.warn("Couldn't auto fill username and password for Chaturbate", e);
log.warn("Couldn't auto fill username and password for Chaturbate", e);
}
}
@ -110,13 +109,17 @@ public class ChaturbateElectronLoginDialog {
}
try {
if (Objects.equals(new URL(url).getPath(), "/")) {
URI uri = new URI(url);
if (Objects.equals(uri.getPath(), "/")) {
browser.close();
}
} catch (MalformedURLException e) {
LOG.error("Couldn't parse new url {}", url, e);
log.error("Couldn't parse new url {}", url, e);
} catch (IOException e) {
LOG.error("Couldn't send shutdown request to external browser", e);
log.error("Couldn't send shutdown request to external browser", e);
} catch (URISyntaxException e) {
log.error("Invalid URL: " + url);
}
}
}

View File

@ -6,15 +6,13 @@ import ctbrec.ui.controls.Dialogs;
import ctbrec.ui.sites.AbstractSiteUi;
import ctbrec.ui.sites.ConfigUI;
import ctbrec.ui.tabs.TabProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import java.io.IOException;
@Slf4j
public class ChaturbateSiteUi extends AbstractSiteUi {
private static final Logger LOG = LoggerFactory.getLogger(ChaturbateSiteUi.class);
private final Chaturbate chaturbate;
private ChaturbateTabProvider tabProvider;
private ChaturbateConfigUi configUi;
@ -45,7 +43,7 @@ public class ChaturbateSiteUi extends AbstractSiteUi {
try {
automaticLogin = chaturbate.login();
} catch (Exception e) {
LOG.debug("Automatic login failed", e);
log.debug("Automatic login failed", e);
}
if (automaticLogin) {
return true;
@ -54,7 +52,7 @@ public class ChaturbateSiteUi extends AbstractSiteUi {
try {
new ChaturbateElectronLoginDialog(chaturbate, chaturbate.getHttpClient().getCookieJar());
} catch (Exception e1) {
LOG.error("Error logging in with external browser", e1);
log.error("Error logging in with external browser", e1);
Dialogs.showError("Login error", "Couldn't login to " + chaturbate.getName(), e1);
}

View File

@ -13,15 +13,14 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import javafx.concurrent.Task;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Request;
import okhttp3.Response;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Slf4j
public class DreamcamUpdateService extends PaginatedScheduledService {
private static final Logger LOG = LoggerFactory.getLogger(DreamcamUpdateService.class);
private static final String API_URL = "https://api.dreamcam.co.kr/v1/live";
private static final int modelsPerPage = 64;
private Dreamcam site;
@ -46,7 +45,7 @@ public class DreamcamUpdateService extends PaginatedScheduledService {
int offset = (getPage() - 1) * modelsPerPage;
int limit = modelsPerPage;
String paginatedUrl = url + "&offset=" + offset + "&limit=" + limit;
LOG.debug("Fetching page {}", paginatedUrl);
log.debug("Fetching page {}", paginatedUrl);
Request req = new Request.Builder()
.url(paginatedUrl)
.header(USER_AGENT, Config.getInstance().getSettings().httpUserAgent)

View File

@ -2,9 +2,6 @@ package ctbrec.ui.sites.fc2live;
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.GlobalThreadPool;
import ctbrec.Model;
import ctbrec.sites.fc2live.Fc2Live;
@ -15,9 +12,10 @@ import ctbrec.ui.controls.Dialogs;
import ctbrec.ui.sites.AbstractSiteUi;
import ctbrec.ui.sites.ConfigUI;
import ctbrec.ui.tabs.TabProvider;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class Fc2LiveSiteUi extends AbstractSiteUi {
private static final Logger LOG = LoggerFactory.getLogger(Fc2LiveSiteUi.class);
private final Fc2Live fc2live;
private Fc2TabProvider tabProvider;
private Fc2LiveConfigUI configUi;
@ -58,7 +56,7 @@ public class Fc2LiveSiteUi extends AbstractSiteUi {
}
try {
m.openWebsocket();
LOG.debug("Starting player for {}", model);
log.debug("Starting player for {}", model);
Player.play(model, false);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
@ -73,7 +71,7 @@ public class Fc2LiveSiteUi extends AbstractSiteUi {
}
private void handleException(Exception e) {
LOG.error("Error playing the stream", e);
log.error("Error playing the stream", e);
Dialogs.showError("Player", "Error playing the stream", e);
}
}

View File

@ -9,8 +9,6 @@ import java.util.Locale;
import java.util.stream.Collectors;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.Config;
import ctbrec.Model;
@ -19,11 +17,12 @@ import ctbrec.sites.fc2live.Fc2Live;
import ctbrec.sites.fc2live.Fc2Model;
import ctbrec.ui.tabs.PaginatedScheduledService;
import javafx.concurrent.Task;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Request;
import okhttp3.RequestBody;
@Slf4j
public class Fc2UpdateService extends PaginatedScheduledService {
private static final Logger LOG = LoggerFactory.getLogger(Fc2UpdateService.class);
private String url;
private Fc2Live fc2live;
@ -49,7 +48,7 @@ public class Fc2UpdateService extends PaginatedScheduledService {
.header(USER_AGENT, Config.getInstance().getSettings().httpUserAgent)
.header(X_REQUESTED_WITH, XML_HTTP_REQUEST)
.build();
LOG.debug("Fetching page {}", url);
log.debug("Fetching page {}", url);
try (var resp = fc2live.getHttpClient().execute(req)) {
if (resp.isSuccessful()) {
List<Fc2Model> models = new ArrayList<>();

View File

@ -7,11 +7,10 @@ import ctbrec.sites.flirt4free.Flirt4Free;
import ctbrec.sites.flirt4free.Flirt4FreeModel;
import ctbrec.ui.tabs.PaginatedScheduledService;
import javafx.concurrent.Task;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Request;
import org.json.JSONObject;
import org.jsoup.nodes.Entities;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList;
@ -22,9 +21,9 @@ import java.util.regex.Pattern;
import static ctbrec.io.HttpClient.gunzipBody;
import static ctbrec.io.HttpConstants.*;
@Slf4j
public class Flirt4FreeUpdateService extends PaginatedScheduledService {
private static final Logger LOG = LoggerFactory.getLogger(Flirt4FreeUpdateService.class);
private static final int MODELS_PER_PAGE = 50;
private final String url;
private final Flirt4Free flirt4Free;
@ -41,7 +40,7 @@ public class Flirt4FreeUpdateService extends PaginatedScheduledService {
return new Task<>() {
@Override
public List<Model> call() throws IOException {
LOG.debug("Fetching page {}", url);
log.debug("Fetching page {}", url);
var request = new Request.Builder()
.url(url)
.header(USER_AGENT, Config.getInstance().getSettings().httpUserAgent)
@ -65,14 +64,14 @@ public class Flirt4FreeUpdateService extends PaginatedScheduledService {
if (m.find()) {
var data = new JSONObject(m.group(1));
var modelData = data.getJSONArray("models");
LOG.debug("Found {} models", modelData.length());
log.debug("Found {} models", modelData.length());
for (var i = 0; i < modelData.length(); i++) {
var modelJson = modelData.getJSONObject(i);
try {
Flirt4FreeModel model = parseModel(modelJson);
models.add(model);
} catch (Exception e) {
LOG.warn("Couldn't parse model {}", modelJson);
log.warn("Couldn't parse model {}", modelJson);
}
}
return models.stream()

View File

@ -7,11 +7,10 @@ import ctbrec.sites.mfc.*;
import ctbrec.ui.SiteUiFactory;
import ctbrec.ui.tabs.PaginatedScheduledService;
import javafx.concurrent.Task;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Request;
import okhttp3.Response;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList;
@ -21,9 +20,9 @@ import java.util.List;
import static ctbrec.io.HttpConstants.REFERER;
import static ctbrec.io.HttpConstants.USER_AGENT;
@Slf4j
public class FriendsUpdateService extends PaginatedScheduledService {
private static final Logger LOG = LoggerFactory.getLogger(FriendsUpdateService.class);
private final MyFreeCams myFreeCams;
private Mode mode = Mode.ONLINE;
@ -55,7 +54,7 @@ public class FriendsUpdateService extends PaginatedScheduledService {
var body = resp.body().string().substring(4);
parseModels(body, models);
} else {
LOG.error("Couldn't load friends list {} {}", resp.code(), resp.message());
log.error("Couldn't load friends list {} {}", resp.code(), resp.message());
}
}
boolean filterOnline = mode == Mode.ONLINE;
@ -102,7 +101,7 @@ public class FriendsUpdateService extends PaginatedScheduledService {
models.add(model);
}
} catch (Exception e) {
LOG.info("Exception getting friends list. Response was: {}", body, e);
log.info("Exception getting friends list. Response was: {}", body, e);
}
}

View File

@ -5,20 +5,19 @@ import java.util.Collections;
import java.util.function.Consumer;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.Config;
import ctbrec.sites.showup.Showup;
import ctbrec.ui.ExternalBrowser;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Cookie;
import okhttp3.Cookie.Builder;
import okhttp3.CookieJar;
import okhttp3.HttpUrl;
@Slf4j
public class ShowupElectronLoginDialog {
private static final Logger LOG = LoggerFactory.getLogger(ShowupElectronLoginDialog.class);
public static final String DOMAIN = "showup.tv";
public static final String URL = Showup.BASE_URL;
private CookieJar cookieJar;
@ -52,7 +51,7 @@ public class ShowupElectronLoginDialog {
var json = new JSONObject(line);
if(json.has("url")) {
var url = json.getString("url");
LOG.debug(url);
log.debug(url);
if(url.contains("/site/accept_rules")) {
try {
Thread.sleep(500);
@ -62,9 +61,9 @@ public class ShowupElectronLoginDialog {
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
LOG.warn("Couldn't auto fill username and password for Showup", e);
log.warn("Couldn't auto fill username and password for Showup", e);
} catch (Exception e) {
LOG.warn("Couldn't auto fill username and password for Showup", e);
log.warn("Couldn't auto fill username and password for Showup", e);
}
} else if (url.equals(URL + '/') && firstCall) {
firstCall = false;
@ -84,9 +83,9 @@ public class ShowupElectronLoginDialog {
return;
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
LOG.warn("Couldn't auto fill username and password for Showup", e);
log.warn("Couldn't auto fill username and password for Showup", e);
} catch (Exception e) {
LOG.warn("Couldn't auto fill username and password for Showup", e);
log.warn("Couldn't auto fill username and password for Showup", e);
}
}
@ -111,7 +110,7 @@ public class ShowupElectronLoginDialog {
b.secure();
}
Cookie c = b.build();
LOG.debug("Adding cookie {}={}", c.name(), c.value());
log.debug("Adding cookie {}={}", c.name(), c.value());
cookieJar.saveFromResponse(HttpUrl.parse(Showup.BASE_URL), Collections.singletonList(c));
}
}

View File

@ -2,20 +2,17 @@ package ctbrec.ui.sites.showup;
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.sites.showup.Showup;
import ctbrec.sites.showup.ShowupHttpClient;
import ctbrec.ui.controls.Dialogs;
import ctbrec.ui.sites.AbstractSiteUi;
import ctbrec.ui.sites.ConfigUI;
import ctbrec.ui.tabs.TabProvider;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class ShowupSiteUi extends AbstractSiteUi {
private static final Logger LOG = LoggerFactory.getLogger(ShowupSiteUi.class);
private final Showup site;
private ConfigUI configUi;
private TabProvider tabProvider;
@ -50,16 +47,16 @@ public class ShowupSiteUi extends AbstractSiteUi {
try {
new ShowupElectronLoginDialog(site.getHttpClient().getCookieJar());
} catch (Exception e1) {
LOG.error("Error logging in with external browser", e1);
log.error("Error logging in with external browser", e1);
Dialogs.showError("Login error", "Couldn't login to " + site.getName(), e1);
}
ShowupHttpClient httpClient = (ShowupHttpClient) site.getHttpClient();
boolean loggedIn = httpClient.checkLoginSuccess();
if (loggedIn) {
LOG.info("Logged in");
log.info("Logged in");
} else {
LOG.info("Login failed");
log.info("Login failed");
}
return loggedIn;
}

View File

@ -8,10 +8,9 @@ import ctbrec.sites.streamate.StreamateHttpClient;
import ctbrec.sites.streamate.StreamateModel;
import ctbrec.ui.tabs.PaginatedScheduledService;
import javafx.concurrent.Task;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Request;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.*;
@ -22,10 +21,9 @@ import static ctbrec.Model.State.ONLINE;
import static ctbrec.io.HttpConstants.*;
import static ctbrec.sites.streamate.Streamate.NAIAD_URL;
@Slf4j
public class StreamateFollowedService extends PaginatedScheduledService {
private static final Logger LOG = LoggerFactory.getLogger(StreamateFollowedService.class);
private static final int MODELS_PER_PAGE = 48;
private final Streamate streamate;
private final StreamateHttpClient httpClient;
@ -46,12 +44,12 @@ public class StreamateFollowedService extends PaginatedScheduledService {
try {
httpClient.login();
} catch (Exception e) {
LOG.debug("Login was not successful");
log.debug("Login was not successful");
return Collections.emptyList();
}
String saKey = httpClient.getSaKey();
String pageUrl = url + "&from=" + ((page - 1) * MODELS_PER_PAGE) + "&size=" + MODELS_PER_PAGE;
LOG.debug("Fetching page {}", pageUrl);
log.debug("Fetching page {}", pageUrl);
String smxxx = UUID.randomUUID() + "G0211569057409";
String smtid = Optional.ofNullable(httpClient.getCookieValue("smtid")).orElse(smxxx);
String smeid = Optional.ofNullable(httpClient.getCookieValue("smeid")).orElse(smxxx);

View File

@ -7,9 +7,9 @@ import ctbrec.sites.streamate.StreamateHttpClient;
import ctbrec.sites.streamate.StreamateModel;
import ctbrec.ui.tabs.PaginatedScheduledService;
import javafx.concurrent.Task;
import lombok.extern.slf4j.Slf4j;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.*;
@ -18,10 +18,9 @@ import static ctbrec.ErrorMessages.HTTP_RESPONSE_BODY_IS_NULL;
import static ctbrec.Model.State.*;
import static ctbrec.io.HttpConstants.ORIGIN;
@Slf4j
public class StreamateUpdateService extends PaginatedScheduledService {
private static final Logger LOG = LoggerFactory.getLogger(StreamateUpdateService.class);
private static final int MODELS_PER_PAGE = 48;
private final Streamate streamate;
private final StreamateHttpClient httpClient;
@ -41,7 +40,7 @@ public class StreamateUpdateService extends PaginatedScheduledService {
int from = (page - 1) * MODELS_PER_PAGE;
String saKey = httpClient.getSaKey();
String pageUrl = url + "&from=" + from + "&size=" + MODELS_PER_PAGE;
LOG.debug("Fetching page {}", pageUrl);
log.debug("Fetching page {}", pageUrl);
String smxxx = UUID.randomUUID() + "G0211569057409";
String smtid = Optional.ofNullable(httpClient.getCookieValue("smtid")).orElse(smxxx);
String smeid = Optional.ofNullable(httpClient.getCookieValue("smeid")).orElse(smxxx);

View File

@ -3,21 +3,19 @@ package ctbrec.ui.sites.stripchat;
import ctbrec.Config;
import ctbrec.sites.stripchat.Stripchat;
import ctbrec.ui.ExternalBrowser;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Cookie;
import okhttp3.Cookie.Builder;
import okhttp3.CookieJar;
import okhttp3.HttpUrl;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.Collections;
import java.util.function.Consumer;
@Slf4j
public class StripchatElectronLoginDialog {
private static final Logger LOG = LoggerFactory.getLogger(StripchatElectronLoginDialog.class);
public static final String DOMAIN = Stripchat.getDomain();
public static final String URL = Stripchat.getBaseUri();
private CookieJar cookieJar;
@ -67,7 +65,7 @@ public class StripchatElectronLoginDialog {
browser.executeJavaScript("document.querySelector('#recaptcha-checkbox-border').click();");
browser.executeJavaScript("document.querySelector('*[class~=btn-login]').addEventListener('click', function() {window.setTimeout(function() {location.reload()}, 2000)});");
} catch (Exception e) {
LOG.warn("Couldn't auto fill username and password for Stripchat", e);
log.warn("Couldn't auto fill username and password for Stripchat", e);
}
}
@ -95,7 +93,7 @@ public class StripchatElectronLoginDialog {
try {
browser.close();
} catch (IOException e) {
LOG.error("Couldn't send close request to browser", e);
log.error("Couldn't send close request to browser", e);
}
}
}

View File

@ -2,20 +2,17 @@ package ctbrec.ui.sites.stripchat;
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.sites.stripchat.Stripchat;
import ctbrec.sites.stripchat.StripchatHttpClient;
import ctbrec.ui.controls.Dialogs;
import ctbrec.ui.sites.AbstractSiteUi;
import ctbrec.ui.sites.ConfigUI;
import ctbrec.ui.tabs.TabProvider;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class StripchatSiteUi extends AbstractSiteUi {
private static final Logger LOG = LoggerFactory.getLogger(StripchatSiteUi.class);
private StripchatTabProvider tabProvider;
private StripchatConfigUI configUi;
private Stripchat site;
@ -50,7 +47,7 @@ public class StripchatSiteUi extends AbstractSiteUi {
try {
new StripchatElectronLoginDialog(site.getHttpClient().getCookieJar());
} catch (Exception e1) {
LOG.error("Error logging in with external browser", e1);
log.error("Error logging in with external browser", e1);
Dialogs.showError("Login error", "Couldn't login to " + site.getName(), e1);
}

View File

@ -7,10 +7,9 @@ import ctbrec.sites.stripchat.Stripchat;
import ctbrec.sites.stripchat.StripchatModel;
import ctbrec.ui.SiteUiFactory;
import javafx.concurrent.Task;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Request;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList;
@ -20,10 +19,9 @@ import java.util.Locale;
import static ctbrec.io.HttpConstants.*;
@Slf4j
public class StripchatUpdateService extends AbstractStripchatUpdateService {
private static final Logger LOG = LoggerFactory.getLogger(StripchatUpdateService.class);
private final String url;
private final boolean loginRequired;
private final Stripchat stripchat;
@ -46,7 +44,7 @@ public class StripchatUpdateService extends AbstractStripchatUpdateService {
int offset = (getPage() - 1) * modelsPerPage;
int limit = modelsPerPage;
String paginatedUrl = url + "&offset=" + offset + "&limit=" + limit;
LOG.debug("Fetching page {}", paginatedUrl);
log.debug("Fetching page {}", paginatedUrl);
if (loginRequired) {
SiteUiFactory.getUi(stripchat).login();
}
@ -90,12 +88,12 @@ public class StripchatUpdateService extends AbstractStripchatUpdateService {
model.setDescription(description.toString());
models.add(model);
} catch (Exception e) {
LOG.warn("Couldn't parse one of the models: {}", jsonModel, e);
log.warn("Couldn't parse one of the models: {}", jsonModel, e);
}
}
return models;
} else {
LOG.debug("Response was not successful: {}", json);
log.debug("Response was not successful: {}", json);
return Collections.emptyList();
}
}

View File

@ -12,7 +12,7 @@ import javafx.scene.layout.BorderPane;
import javafx.scene.layout.VBox;
import lombok.extern.slf4j.Slf4j;
import java.awt.Desktop;
// import java.awt.Desktop;
import java.io.File;
import java.io.IOException;

View File

@ -43,8 +43,7 @@ import javafx.scene.layout.StackPane;
import javafx.scene.text.Font;
import javafx.stage.FileChooser;
import javafx.util.Duration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import java.io.File;
import java.io.FileNotFoundException;
@ -67,11 +66,10 @@ import static ctbrec.Recording.State.*;
import static javafx.scene.control.ButtonType.NO;
import static javafx.scene.control.ButtonType.YES;
@Slf4j
public class RecordingsTab extends Tab implements TabSelectionListener, ShutdownListener {
private static final String ERROR_WHILE_DOWNLOADING_RECORDING = "Error while downloading recording";
private static final Logger LOG = LoggerFactory.getLogger(RecordingsTab.class);
private ScheduledService<List<JavaFxRecording>> updateService;
private final Config config;
private final ModelNotesService modelNotesService;
@ -169,7 +167,7 @@ public class RecordingsTab extends Tab implements TabSelectionListener, Shutdown
try {
modelNts = modelNotesService.loadModelNotes(cdf.getValue().getModel().getUrl()).orElse("");
} catch (IOException e) {
LOG.warn("Could not load model notes", e);
log.warn("Could not load model notes", e);
modelNts = "";
}
return new SimpleStringProperty(modelNts);
@ -310,7 +308,7 @@ public class RecordingsTab extends Tab implements TabSelectionListener, Shutdown
updateUsedSpaceDisplay();
});
updateService.setOnFailed(event -> {
LOG.info("Couldn't get list of recordings from recorder", event.getSource().getException());
log.info("Couldn't get list of recordings from recorder", event.getSource().getException());
var autosizeAlert = new AutosizeAlert(AlertType.ERROR, getTabPane().getScene());
autosizeAlert.setTitle("Whoopsie!");
autosizeAlert.setHeaderText("Recordings not available");
@ -390,7 +388,7 @@ public class RecordingsTab extends Tab implements TabSelectionListener, Shutdown
// recordings dir does not exist
Platform.runLater(() -> spaceLeft.setTooltip(new Tooltip("Recordings directory does not exist")));
} catch (IOException e) {
LOG.error("Couldn't update free space", e);
log.error("Couldn't update free space", e);
}
}
};
@ -688,7 +686,7 @@ public class RecordingsTab extends Tab implements TabSelectionListener, Shutdown
recorder.rerunPostProcessing(rec.getDelegate());
} catch (IOException | InvalidKeyException | NoSuchAlgorithmException | IllegalStateException e1) {
showErrorDialog("Error while starting post-processing", "The post-processing could not be started", e1);
LOG.error("Error while starting post-processing", e1);
log.error("Error while starting post-processing", e1);
}
}
});
@ -696,7 +694,7 @@ public class RecordingsTab extends Tab implements TabSelectionListener, Shutdown
private void download(Recording recording) {
try {
LOG.debug("Path {}", recording.getAbsoluteFile());
log.debug("Path {}", recording.getAbsoluteFile());
String filename = proposeTargetFilename(recording);
var chooser = new FileChooser();
chooser.setInitialFileName(filename);
@ -743,19 +741,19 @@ public class RecordingsTab extends Tab implements TabSelectionListener, Shutdown
var url = new URL(hlsBase + '/' + recording.getId() + "/playlist.m3u8");
var download = new RecordingDownload(CamrecApplication.httpClient);
download.init(config, recording.getModel(), Instant.now(), Executors.newSingleThreadExecutor());
LOG.info("Downloading {}", url);
log.info("Downloading {}", url);
download.downloadFinishedRecording(url.toString(), target, createDownloadListener(recording), recording.getSizeInByte());
}
} catch (FileNotFoundException e) {
showErrorDialog(ERROR_WHILE_DOWNLOADING_RECORDING, "The target file couldn't be created", e);
LOG.error(ERROR_WHILE_DOWNLOADING_RECORDING, e);
log.error(ERROR_WHILE_DOWNLOADING_RECORDING, e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
showErrorDialog(ERROR_WHILE_DOWNLOADING_RECORDING, "The recording could not be downloaded", e);
LOG.error(ERROR_WHILE_DOWNLOADING_RECORDING, e);
log.error(ERROR_WHILE_DOWNLOADING_RECORDING, e);
} catch (Exception e) {
showErrorDialog(ERROR_WHILE_DOWNLOADING_RECORDING, "The recording could not be downloaded", e);
LOG.error(ERROR_WHILE_DOWNLOADING_RECORDING, e);
log.error(ERROR_WHILE_DOWNLOADING_RECORDING, e);
} finally {
Platform.runLater(() -> {
recording.setStatus(FINISHED);
@ -773,7 +771,7 @@ public class RecordingsTab extends Tab implements TabSelectionListener, Shutdown
return progress -> Platform.runLater(() -> {
if (progress == 100) {
recording.setStatus(FINISHED);
LOG.debug("Download finished for recording {} - {}", recording.getId(), recording.getAbsoluteFile());
log.debug("Download finished for recording {} - {}", recording.getId(), recording.getAbsoluteFile());
} else {
recording.setStatus(DOWNLOADING);
}
@ -847,7 +845,7 @@ public class RecordingsTab extends Tab implements TabSelectionListener, Shutdown
deleted.add(r);
} catch (Exception e1) {
exceptions.add(e1);
LOG.error("Error while deleting recording", e1);
log.error("Error while deleting recording", e1);
}
}
if (!exceptions.isEmpty()) {

View File

@ -47,11 +47,10 @@ import javafx.scene.shape.Shape;
import javafx.scene.text.Text;
import javafx.scene.text.TextAlignment;
import javafx.util.Duration;
import lombok.extern.slf4j.Slf4j;
import javafx.embed.swing.SwingFXUtils;
import okhttp3.Request;
import okhttp3.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
@ -70,10 +69,10 @@ import static ctbrec.Model.State.ONLINE;
import static ctbrec.io.HttpConstants.*;
import static ctbrec.ui.Icon.*;
@Slf4j
public class ThumbCell extends StackPane {
private static final String ERROR = "Error";
private static final Logger LOG = LoggerFactory.getLogger(ThumbCell.class);
private static final Duration ANIMATION_DURATION = new Duration(250);
private static final Image imgRecordIndicator = new Image(MEDIA_RECORD_16.url());
@ -385,7 +384,7 @@ public class ThumbCell extends StackPane {
throw new HttpException(resp.code(), resp.message());
}
} catch (IOException e) {
LOG.warn("Error loading thumbnail: {} {}", url, e.getLocalizedMessage());
log.warn("Error loading thumbnail: {} {}", url, e.getLocalizedMessage());
}
};
}
@ -464,7 +463,7 @@ public class ThumbCell extends StackPane {
}
setRecording(recording);
} catch (Exception e1) {
LOG.error("Couldn't pause/resume recording", e1);
log.error("Couldn't pause/resume recording", e1);
Platform.runLater(() -> {
Alert alert = new AutosizeAlert(Alert.AlertType.ERROR, getScene());
alert.setTitle(ERROR);
@ -503,7 +502,7 @@ public class ThumbCell extends StackPane {
}
}
} catch (Exception e1) {
LOG.error("Couldn't follow/unfollow model {}", model.getName(), e1);
log.error("Couldn't follow/unfollow model {}", model.getName(), e1);
String msg = "I/O error while following/unfollowing model " + model.getName() + ": ";
Dialogs.showError(getScene(), "Couldn't follow/unfollow model", msg, e1);
return false;
@ -622,7 +621,7 @@ public class ThumbCell extends StackPane {
try {
return model.getStreamResolution(false);
} catch (ExecutionException e) {
LOG.trace("Error loading stream resolution for model {}: {}", model, e.getLocalizedMessage());
log.trace("Error loading stream resolution for model {}: {}", model, e.getLocalizedMessage());
return new int[2];
}
}

View File

@ -36,8 +36,7 @@ import javafx.scene.image.ImageView;
import javafx.scene.input.*;
import javafx.scene.layout.*;
import javafx.util.Duration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import java.io.IOException;
import java.net.SocketTimeoutException;
@ -46,9 +45,8 @@ import java.util.concurrent.*;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
@Slf4j
public class ThumbOverviewTab extends Tab implements TabSelectionListener {
private static final Logger LOG = LoggerFactory.getLogger(ThumbOverviewTab.class);
protected static BlockingQueue<Runnable> queue = new LinkedBlockingQueue<>();
static ExecutorService threadPool = new ThreadPoolExecutor(2, 2, 10, TimeUnit.MINUTES, queue, createThreadFactory());
@ -617,14 +615,14 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
protected void onFail(WorkerStateEvent event) {
if (event.getSource().getException() != null) {
if (event.getSource().getException() instanceof SocketTimeoutException) {
LOG.debug("Fetching model list timed out");
log.debug("Fetching model list timed out");
errorLabel.setText("Timeout while updating");
} else {
LOG.error("Couldn't update model list", event.getSource().getException());
log.error("Couldn't update model list", event.getSource().getException());
errorLabel.setText("Error while updating " + event.getSource().getException().getLocalizedMessage());
}
} else {
LOG.error("Couldn't update model list {}", event.getEventType());
log.error("Couldn't update model list {}", event.getEventType());
errorLabel.setText("Couldn't update model list " + event.getEventType());
}
grid.getChildren().removeAll(progressIndicator, noResultsFound, errorLabel);
@ -718,7 +716,7 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
}
return !tokensMissing;
} catch (NumberFormatException | ExecutionException | IOException e) {
LOG.error("Error while filtering model list", e);
log.error("Error while filtering model list", e);
return false;
}
}

View File

@ -5,9 +5,6 @@ import static ctbrec.ui.controls.Dialogs.*;
import java.io.IOException;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.Model;
import ctbrec.sites.Site;
import ctbrec.ui.SiteUiFactory;
@ -15,11 +12,10 @@ import ctbrec.ui.controls.SearchPopover;
import ctbrec.ui.controls.SearchPopoverTreeList;
import javafx.application.Platform;
import javafx.concurrent.Task;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class ThumbOverviewTabSearchTask extends Task<List<Model>> {
private static final Logger LOG = LoggerFactory.getLogger(ThumbOverviewTabSearchTask.class);
private final Site site;
private final SearchPopover popover;
private final SearchPopoverTreeList popoverTreeList;
@ -50,14 +46,14 @@ public class ThumbOverviewTabSearchTask extends Task<List<Model>> {
@Override
protected void failed() {
LOG.error("Search failed", getException());
log.error("Search failed", getException());
}
@Override
protected void succeeded() {
Platform.runLater(() -> {
List<Model> models = getValue();
LOG.debug("Search result {} {}", isCancelled(), models);
log.debug("Search result {} {}", isCancelled(), models);
if(models.isEmpty()) {
popover.hide();
} else {

View File

@ -17,8 +17,7 @@ import javafx.concurrent.WorkerStateEvent;
import javafx.geometry.Insets;
import javafx.scene.layout.BorderPane;
import javafx.util.Duration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import java.util.List;
import java.util.concurrent.ExecutorService;
@ -26,9 +25,8 @@ import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;
@Slf4j
public class RecordLaterTab extends AbstractRecordedModelsTab implements TabSelectionListener {
private static final Logger LOG = LoggerFactory.getLogger(RecordLaterTab.class);
private ScheduledService<List<JavaFxModel>> updateService;
public RecordLaterTab(String title, Recorder recorder, List<Site> sites) {
@ -72,7 +70,7 @@ public class RecordLaterTab extends AbstractRecordedModelsTab implements TabSele
updateService = createUpdateService();
updateService.setPeriod(new Duration(TimeUnit.SECONDS.toMillis(2)));
updateService.setOnSucceeded(this::onUpdateSuccess);
updateService.setOnFailed(event -> LOG.info("Couldn't get list of models from recorder", event.getSource().getException()));
updateService.setOnFailed(event -> log.info("Couldn't get list of models from recorder", event.getSource().getException()));
}
private void onUpdateSuccess(WorkerStateEvent event) {
@ -121,7 +119,7 @@ public class RecordLaterTab extends AbstractRecordedModelsTab implements TabSele
return new Task<>() {
@Override
public List<JavaFxModel> call() {
LOG.trace("Updating bookmarked models");
log.trace("Updating bookmarked models");
return recorder.getModels().stream().filter(Model::isMarkedForLaterRecording).map(JavaFxModel::new).toList();
}
};

View File

@ -30,8 +30,7 @@ import javafx.scene.layout.HBox;
import javafx.util.Callback;
import javafx.util.Duration;
import javafx.util.converter.NumberStringConverter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import java.io.IOException;
import java.security.InvalidKeyException;
@ -48,9 +47,8 @@ import java.util.function.Predicate;
import static ctbrec.Recording.State.RECORDING;
@Slf4j
public class RecordedModelsTab extends AbstractRecordedModelsTab implements TabSelectionListener {
private static final Logger LOG = LoggerFactory.getLogger(RecordedModelsTab.class);
private ScheduledService<List<JavaFxModel>> updateService;
private volatile boolean cellEditing = false;
@ -221,7 +219,7 @@ public class RecordedModelsTab extends AbstractRecordedModelsTab implements TabS
updateService = createUpdateService();
updateService.setPeriod(new Duration(TimeUnit.SECONDS.toMillis(2)));
updateService.setOnSucceeded(this::onUpdateSuccess);
updateService.setOnFailed(event -> LOG.info("Couldn't get list of models from recorder", event.getSource().getException()));
updateService.setOnFailed(event -> log.info("Couldn't get list of models from recorder", event.getSource().getException()));
}
private void onUpdateSuccess(WorkerStateEvent event) {
@ -307,7 +305,7 @@ public class RecordedModelsTab extends AbstractRecordedModelsTab implements TabS
return new Task<>() {
@Override
public List<JavaFxModel> call() throws InvalidKeyException, NoSuchAlgorithmException, IOException {
LOG.trace("Updating recorded models");
log.trace("Updating recorded models");
List<Recording> recordings = recorder.getRecordings();
List<Model> onlineModels = recorder.getOnlineModels();
return recorder.getModels().stream().filter(Predicate.not(Model::isMarkedForLaterRecording)).map(JavaFxModel::new).peek(fxm -> { // NOSONAR

View File

@ -1,10 +1,10 @@
package ctbrec;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import lombok.extern.slf4j.Slf4j;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
@ -12,15 +12,14 @@ import java.util.Base64;
import static java.nio.charset.StandardCharsets.UTF_8;
@Slf4j
public class Hmac {
private Hmac() {
}
private static final Logger LOG = LoggerFactory.getLogger(Hmac.class);
public static byte[] generateKey() {
LOG.debug("Generating HMAC key");
log.debug("Generating HMAC key");
SecureRandom random = new SecureRandom();
byte[] key = new byte[32];
random.nextBytes(key);

View File

@ -1,34 +1,32 @@
package ctbrec;
import kotlin.Pair;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
@Slf4j
public class LoggingInterceptor implements Interceptor {
private static final Logger LOG = LoggerFactory.getLogger(LoggingInterceptor.class);
@Override
public Response intercept(Chain chain) throws IOException {
long t1 = System.nanoTime();
Request request = chain.request();
LOG.debug("OkHttp Sending request {} on {}", request.url(), chain.connection());
log.debug("OkHttp Sending request {} on {}", request.url(), chain.connection());
for (Pair<?, ?> header : request.headers()) {
LOG.debug("{}: {}", header.getFirst(), header.getSecond());
log.debug("{}: {}", header.getFirst(), header.getSecond());
}
if (request.method().equalsIgnoreCase("POST")) {
LOG.debug("Body: {}", request.body());
log.debug("Body: {}", request.body());
}
Response response = chain.proceed(request);
long t2 = System.nanoTime();
LOG.debug("OkHttp Received {} response for {} in {}ms", response.code(), response.request().url(), (t2 - t1) / 1e6d);
log.debug("OkHttp Received {} response for {} in {}ms", response.code(), response.request().url(), (t2 - t1) / 1e6d);
for (Pair<?, ?> header : response.headers()) {
LOG.debug("{}: {}", header.getFirst(), header.getSecond());
log.debug("{}: {}", header.getFirst(), header.getSecond());
}
return response;
}

View File

@ -8,13 +8,11 @@ import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Map.Entry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class OS {
private static final Logger LOG = LoggerFactory.getLogger(OS.class);
private static final String USER_HOME = "user.home";
private static final String OS_NAME = "os.name";
private static final String CTBREC = "ctbrec";
@ -100,7 +98,7 @@ public class OS {
default:
throw new UnsupportedOperatingSystemException(System.getProperty(OS_NAME));
}
LOG.debug("Browser command: {}", Arrays.toString(cmd));
log.debug("Browser command: {}", Arrays.toString(cmd));
return cmd;
} catch (URISyntaxException e) {
throw new ForkProcessException(e);
@ -135,7 +133,7 @@ public class OS {
default:
throw new UnsupportedOperatingSystemException(System.getProperty(OS_NAME));
}
LOG.debug("FFmpeg command: {}", Arrays.toString(cmd));
log.debug("FFmpeg command: {}", Arrays.toString(cmd));
return cmd;
} catch (URISyntaxException e) {
throw new ForkProcessException(e);

View File

@ -5,14 +5,13 @@ import java.util.Map;
import java.util.UUID;
import java.util.concurrent.Executors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.eventbus.AsyncEventBus;
import com.google.common.eventbus.EventBus;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class EventBusHolder {
private static final Logger LOG = LoggerFactory.getLogger(EventBusHolder.class);
private static Map<String, EventHandler> handlers = new HashMap<>();
private EventBusHolder() {}
@ -27,11 +26,11 @@ public class EventBusHolder {
public static void register(EventHandler handler) {
if(handlers.containsKey(handler.getId())) {
LOG.warn("EventHandler with ID {} is already registered", handler.getId());
log.warn("EventHandler with ID {} is already registered", handler.getId());
} else {
BUS.register(handler);
handlers.put(handler.getId(), handler);
LOG.debug("EventHandler with ID {} has been added", handler.getId());
log.debug("EventHandler with ID {} has been added", handler.getId());
}
}
@ -40,7 +39,7 @@ public class EventBusHolder {
if(handler != null) {
BUS.unregister(handler);
handlers.remove(id);
LOG.debug("EventHandler with ID {} has been removed", id);
log.debug("EventHandler with ID {} has been removed", id);
}
}
}

View File

@ -6,8 +6,7 @@ import ctbrec.event.Event.Type;
import ctbrec.event.EventHandlerConfiguration.ActionConfiguration;
import ctbrec.event.EventHandlerConfiguration.PredicateConfiguration;
import lombok.EqualsAndHashCode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
@ -16,10 +15,9 @@ import java.util.List;
import java.util.function.Consumer;
import java.util.function.Predicate;
@Slf4j
@EqualsAndHashCode(of = "id")
public class EventHandler {
private static final Logger LOG = LoggerFactory.getLogger(EventHandler.class);
private List<EventPredicate> predicates = new ArrayList<>();
private final List<Action> actions;
private String id;
@ -48,7 +46,7 @@ public class EventHandler {
@Subscribe
public void reactToEvent(Event evt) {
if (Config.getInstance().getSettings().eventsSuspended) {
LOG.debug("Events are suspended. Ignoring {}", evt);
log.debug("Events are suspended. Ignoring {}", evt);
return;
}
@ -65,7 +63,7 @@ public class EventHandler {
}
}
} catch (Exception e) {
LOG.error("Error while processing event", e);
log.error("Error while processing event", e);
}
}
@ -77,7 +75,7 @@ public class EventHandler {
@SuppressWarnings("unchecked")
Class<EventPredicate> cls = (Class<EventPredicate>) Class.forName(pc.getType());
if (cls == null) {
LOG.warn("Ignoring unknown action {}", cls);
log.warn("Ignoring unknown action {}", cls);
continue;
}
EventPredicate predicate = cls.getDeclaredConstructor().newInstance();
@ -85,7 +83,7 @@ public class EventHandler {
predicateList.add(predicate);
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException | IllegalArgumentException | InvocationTargetException |
NoSuchMethodException | SecurityException e) {
LOG.warn("Error while creating action {} {}", pc.getType(), pc.getConfiguration(), e);
log.warn("Error while creating action {} {}", pc.getType(), pc.getConfiguration(), e);
}
}
return predicateList;
@ -98,14 +96,14 @@ public class EventHandler {
@SuppressWarnings("unchecked")
Class<Action> cls = (Class<Action>) Class.forName(ac.getType());
if (cls == null) {
LOG.warn("Ignoring unknown action {}", cls);
log.warn("Ignoring unknown action {}", cls);
continue;
}
Action action = cls.getDeclaredConstructor().newInstance();
action.configure(ac);
actionList.add(action);
} catch (Exception e) {
LOG.warn("Error while creating action {} {}", ac.getType(), ac.getConfiguration(), e);
log.warn("Error while creating action {} {}", ac.getType(), ac.getConfiguration(), e);
}
}
return actionList;

View File

@ -2,17 +2,14 @@ package ctbrec.event;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.OS;
import ctbrec.event.EventHandlerConfiguration.ActionConfiguration;
import ctbrec.io.StreamRedirector;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class ExecuteProgram extends Action {
private static final transient Logger LOG = LoggerFactory.getLogger(ExecuteProgram.class);
private String executable;
public ExecuteProgram() {
@ -33,7 +30,7 @@ public class ExecuteProgram extends Action {
String[] cmd = new String[args.length+1];
cmd[0] = executable;
System.arraycopy(args, 0, cmd, 1, args.length);
LOG.debug("Executing {}", Arrays.toString(cmd));
log.debug("Executing {}", Arrays.toString(cmd));
process = rt.exec(cmd, OS.getEnvironment());
// create threads, which read stdout and stderr of the player process. these are needed,
@ -48,9 +45,9 @@ public class ExecuteProgram extends Action {
err.start();
process.waitFor();
LOG.debug("Executing {} finished", executable);
log.debug("Executing {} finished", executable);
} catch (Exception e) {
LOG.error("Error while executing {}", executable, e);
log.error("Error while executing {}", executable, e);
}
}

View File

@ -11,17 +11,14 @@ import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Cookie;
import okhttp3.CookieJar;
import okhttp3.HttpUrl;
@Slf4j
public class CookieJarImpl implements CookieJar {
private static final Logger LOG = LoggerFactory.getLogger(CookieJarImpl.class);
private final HashMap<String, List<Cookie>> cookieStore = new HashMap<>();
@Override
@ -35,7 +32,7 @@ public class CookieJarImpl implements CookieJar {
String name = oldCookie.name();
for (Cookie newCookie : cookies) {
if(newCookie.name().equalsIgnoreCase(name)) {
LOG.trace("Replacing cookie {} {} -> {} [{}]", oldCookie.name(), oldCookie.value(), newCookie.value(), oldCookie.domain());
log.trace("Replacing cookie {} {} -> {} [{}]", oldCookie.name(), oldCookie.value(), newCookie.value(), oldCookie.domain());
iterator.remove();
break;
}
@ -43,17 +40,17 @@ public class CookieJarImpl implements CookieJar {
}
cookiesForUrl.addAll(cookies);
cookieStore.put(host, cookiesForUrl);
LOG.trace("Adding cookie: {} for {}", cookiesForUrl, host);
log.trace("Adding cookie: {} for {}", cookiesForUrl, host);
}
else {
cookieStore.put(host, cookies);
LOG.trace("Storing cookie: {} for {}", cookies, host);
log.trace("Storing cookie: {} for {}", cookies, host);
}
}
@Override
public List<Cookie> loadForRequest(HttpUrl url) {
LOG.debug("Loading cookies for {}", url);
log.debug("Loading cookies for {}", url);
String host = getDomain(url);
List<Cookie> cookies = cookieStore.get(host);
List<Cookie> result = new ArrayList<>();
@ -62,8 +59,8 @@ public class CookieJarImpl implements CookieJar {
addCookieToResult(url, result, cookie);
}
}
LOG.trace("Cookies for {}", url);
Optional.ofNullable(result).ifPresent(cookiez -> cookiez.forEach(c -> LOG.trace("Cookies for {}: {}", url, c)));
log.trace("Cookies for {}", url);
Optional.ofNullable(result).ifPresent(cookiez -> cookiez.forEach(c -> log.trace("Cookies for {}: {}", url, c)));
return result;
}
@ -107,7 +104,7 @@ public class CookieJarImpl implements CookieJar {
Cookie cookie = iterator.next();
if(Objects.equals(cookie.name(), name)) {
iterator.remove();
LOG.debug("Removed cookie \"{}\" for {}", name, url);
log.debug("Removed cookie \"{}\" for {}", name, url);
return;
}
}

View File

@ -1,8 +1,7 @@
package ctbrec.io;
import ctbrec.Config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import java.io.File;
import java.io.IOException;
@ -11,10 +10,9 @@ import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.EnumSet;
@Slf4j
public class IoUtils {
private static final Logger LOG = LoggerFactory.getLogger(IoUtils.class);
private IoUtils() {
}
@ -25,7 +23,7 @@ public class IoUtils {
return;
}
if (parent.exists()) {
LOG.debug("Deleting empty directory {}", parent.getAbsolutePath());
log.debug("Deleting empty directory {}", parent.getAbsolutePath());
Files.delete(parent.toPath());
}
parent = parent.getParentFile();
@ -44,11 +42,11 @@ public class IoUtils {
deleteDirectory(file);
} else {
try {
LOG.trace("Deleting {}", file.getAbsolutePath());
log.trace("Deleting {}", file.getAbsolutePath());
Files.delete(file.toPath());
} catch (Exception e) {
deletedAllFiles = false;
LOG.debug("Couldn't delete {}", file, e);
log.debug("Couldn't delete {}", file, e);
}
}
}
@ -78,7 +76,7 @@ public class IoUtils {
}
});
} catch (IOException e) {
LOG.error("Couldn't determine size of directory {}", dir, e);
log.error("Couldn't determine size of directory {}", dir, e);
}
return size[0];
}
@ -88,7 +86,7 @@ public class IoUtils {
try {
outputStream.close();
} catch (IOException e) {
LOG.error(errorMsg, e);
log.error(errorMsg, e);
}
}
}

View File

@ -7,11 +7,10 @@ import java.io.OutputStream;
import java.util.Objects;
import java.util.concurrent.ScheduledExecutorService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class ProcessStreamRedirector implements Runnable {
private static final Logger LOG = LoggerFactory.getLogger(ProcessStreamRedirector.class);
private InputStream in;
private OutputStream out;
@ -39,7 +38,7 @@ public class ProcessStreamRedirector implements Runnable {
}
} catch (Exception e) {
if (!Objects.equals(e.getMessage(), "Stream Closed")) {
LOG.debug("Error while reading from process output stream: {}", e.getLocalizedMessage(), e);
log.debug("Error while reading from process output stream: {}", e.getLocalizedMessage(), e);
}
keepGoing = false;
}

View File

@ -3,11 +3,10 @@ package ctbrec.io;
import java.io.InputStream;
import java.io.OutputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class StreamRedirector implements Runnable {
private static final Logger LOG = LoggerFactory.getLogger(StreamRedirector.class);
private InputStream in;
private OutputStream out;
@ -26,9 +25,9 @@ public class StreamRedirector implements Runnable {
while(in != null && (length = in.read(buffer)) >= 0) {
out.write(buffer, 0, length);
}
LOG.trace("Stream redirect thread ended");
log.trace("Stream redirect thread ended");
} catch(Exception e) {
LOG.warn("Couldn't redirect stream: {}", e.getLocalizedMessage());
log.warn("Couldn't redirect stream: {}", e.getLocalizedMessage());
}
}
}

View File

@ -11,17 +11,14 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
import java.util.function.Consumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.io.DevNull;
import ctbrec.io.ProcessStreamRedirector;
import ctbrec.recorder.download.ProcessExitedUncleanException;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class FFmpeg {
private static final Logger LOG = LoggerFactory.getLogger(FFmpeg.class);
private static ScheduledExecutorService processOutputReader = Executors.newScheduledThreadPool(2, createThreadFactory("FFmpeg output stream reader"));
private Process process;
@ -46,7 +43,7 @@ public class FFmpeg {
}
public void exec(String[] cmdline, String[] env, File executionDir) throws IOException {
LOG.trace("FFmpeg command line: {}", Arrays.toString(cmdline));
log.trace("FFmpeg command line: {}", Arrays.toString(cmdline));
process = Runtime.getRuntime().exec(cmdline, env, executionDir);
afterStart();
}
@ -57,7 +54,7 @@ public class FFmpeg {
}
public void shutdown(int exitCode) throws IOException {
LOG.trace("FFmpeg exit code was {}", exitCode);
log.trace("FFmpeg exit code was {}", exitCode);
ffmpegLogStream.flush();
ffmpegLogStream.close();
stdoutRedirector.setKeepGoing(false);
@ -77,7 +74,7 @@ public class FFmpeg {
if (ffmpegLog == null) {
ffmpegLog = File.createTempFile("ffmpeg_", ".log");
}
LOG.trace("Logging FFmpeg output to {}", ffmpegLog);
log.trace("Logging FFmpeg output to {}", ffmpegLog);
ffmpegLog.deleteOnExit();
ffmpegLogStream = new FileOutputStream(ffmpegLog);
} else {
@ -93,7 +90,7 @@ public class FFmpeg {
try {
startCallback.accept(process);
} catch(Exception e) {
LOG.error("Exception in onStart callback", e);
log.error("Exception in onStart callback", e);
}
}
@ -101,7 +98,7 @@ public class FFmpeg {
try {
exitCallback.accept(exitCode);
} catch(Exception e) {
LOG.error("Exception in onExit callback", e);
log.error("Exception in onExit callback", e);
}
}
@ -110,7 +107,7 @@ public class FFmpeg {
try {
shutdown(exitCode);
} catch (IOException e) {
LOG.error("Error while shutting down FFmpeg process", e);
log.error("Error while shutting down FFmpeg process", e);
}
return exitCode;
}

View File

@ -7,8 +7,7 @@ import ctbrec.event.ModelIsOnlineEvent;
import ctbrec.event.ModelStateChangedEvent;
import ctbrec.io.HttpException;
import ctbrec.sites.chaturbate.ChaturbateModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import java.io.InterruptedIOException;
import java.net.SocketTimeoutException;
@ -23,8 +22,8 @@ import java.util.concurrent.*;
import static ctbrec.Model.State.OFFLINE;
import static ctbrec.Model.State.UNKNOWN;
@Slf4j
public class OnlineMonitor extends Thread {
private static final Logger LOG = LoggerFactory.getLogger(OnlineMonitor.class);
private static final boolean IGNORE_CACHE = true;
private volatile boolean running = false;
@ -59,7 +58,7 @@ public class OnlineMonitor extends Thread {
Duration timeCheckTook = Duration.between(begin, end);
suspendUntilNextIteration(models, timeCheckTook);
}
LOG.debug("{} terminated", getName());
log.debug("{} terminated", getName());
}
private void removeDeletedModels(List<Model> models) {
@ -88,12 +87,12 @@ public class OnlineMonitor extends Thread {
try {
future.get(timeout.toMillis(), TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
LOG.debug("Online check interrupted for model {}", future.getModel(), e);
log.debug("Online check interrupted for model {}", future.getModel(), e);
Thread.currentThread().interrupt();
} catch (ExecutionException e) {
LOG.info("Error while checking online state for model {}", future.getModel(), e);
log.info("Error while checking online state for model {}", future.getModel(), e);
} catch (TimeoutException e) {
LOG.debug("Online check didn't finish after {}ms for model {}", timeout.toMillis(), future.getModel());
log.debug("Online check didn't finish after {}ms for model {}", timeout.toMillis(), future.getModel());
}
}
}
@ -120,23 +119,23 @@ public class OnlineMonitor extends Thread {
} else {
state = model.getOnlineState(false);
}
LOG.debug("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) {
EventBusHolder.BUS.post(new ModelStateChangedEvent(model, oldState, state));
}
} catch (HttpException e) {
LOG.error("Couldn't check if model {} is online. HTTP Response: {} - {}", model.getName(), e.getResponseCode(), e.getResponseMessage());
log.error("Couldn't check if model {} is online. HTTP Response: {} - {}", model.getName(), e.getResponseCode(), e.getResponseMessage());
} catch (SocketTimeoutException e) {
LOG.error("Couldn't check if model {} is online. Request timed out", model.getName());
log.error("Couldn't check if model {} is online. Request timed out", model.getName());
} catch (InterruptedException | InterruptedIOException e) {
Thread.currentThread().interrupt();
if (running) {
LOG.error("Couldn't check if model {} is online", model.getName(), e);
log.error("Couldn't check if model {} is online", model.getName(), e);
}
} catch (Exception e) {
LOG.error("Couldn't check if model {} is online", model.getName(), e);
log.error("Couldn't check if model {} is online", model.getName(), e);
}
return model;
});
@ -144,18 +143,18 @@ public class OnlineMonitor extends Thread {
}
private void suspendUntilNextIteration(List<Model> models, Duration timeCheckTook) {
LOG.debug("Online check for {} models took {} seconds", models.size(), timeCheckTook.getSeconds());
log.debug("Online check for {} models took {} seconds", models.size(), timeCheckTook.getSeconds());
long sleepTime = config.getSettings().onlineCheckIntervalInSecs;
if (timeCheckTook.getSeconds() < sleepTime) {
try {
if (running) {
long millis = TimeUnit.SECONDS.toMillis(sleepTime - timeCheckTook.getSeconds());
LOG.trace("Sleeping {}ms", millis);
log.trace("Sleeping {}ms", millis);
Thread.sleep(millis);
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
LOG.trace("Sleep interrupted");
log.trace("Sleep interrupted");
}
}
}

View File

@ -5,8 +5,7 @@ import ctbrec.Model;
import ctbrec.ModelGroup;
import ctbrec.Recording;
import ctbrec.recorder.download.RecordingProcess;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import java.io.IOException;
import java.security.InvalidKeyException;
@ -18,9 +17,9 @@ import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
@Slf4j
public class RecordingPreconditions {
private static final Logger LOG = LoggerFactory.getLogger(RecordingPreconditions.class);
public static final boolean IGNORE_CACHE = true;
private final Config config;
@ -34,7 +33,7 @@ public class RecordingPreconditions {
}
void check(Model model) throws IOException, InvalidKeyException, NoSuchAlgorithmException {
LOG.debug("Checking preconditions for model {}", model);
log.debug("Checking preconditions for model {}", model);
ensureRecorderIsActive();
ensureNotInTimeoutPeriod();
ensureModelIsNotSuspended(model);
@ -94,7 +93,7 @@ public class RecordingPreconditions {
if (!downloadSlotAvailable()) {
long now = System.currentTimeMillis();
if ((now - lastPreconditionMessage) > TimeUnit.MINUTES.toMillis(1)) {
LOG.info("The number of downloads is maxed out");
log.info("The number of downloads is maxed out");
lastPreconditionMessage = now;
}
// check, if we can stop a recording for a model with lower priority
@ -102,7 +101,7 @@ public class RecordingPreconditions {
if (lowerPrioRecordingProcess.isPresent()) {
RecordingProcess download = lowerPrioRecordingProcess.get().getRecordingProcess();
Model lowerPrioModel = download.getModel();
LOG.info("Stopping recording for {}. Prio {} < {}", lowerPrioModel.getName(), lowerPrioModel.getPriority(), model.getPriority());
log.info("Stopping recording for {}. Prio {} < {}", lowerPrioModel.getName(), lowerPrioModel.getPriority(), model.getPriority());
recorder.stopRecordingProcess(lowerPrioRecordingProcess.get());
} else {
throw new PreconditionNotMetException("Other models have higher prio, not starting recording for " + model.getName());
@ -190,7 +189,7 @@ public class RecordingPreconditions {
throw new PreconditionNotMetException(otherModel.get() + " from the same group can be recorded");
}
} else {
LOG.warn("Couldn't check if model from same group has higer prio for {}", modelUrl);
log.warn("Couldn't check if model from same group has higer prio for {}", modelUrl);
}
}
}
@ -228,7 +227,7 @@ public class RecordingPreconditions {
} catch (PreconditionNotMetException e) {
// precondition for other model not met
} catch (IOException e) {
LOG.warn("Couldn't check if preconditions of other model from group are met. Assuming she's offline", e);
log.warn("Couldn't check if preconditions of other model from group are met. Assuming she's offline", e);
}
return false;
}

View File

@ -17,6 +17,7 @@ import ctbrec.io.json.mapper.RecordingMapper;
import ctbrec.sites.Site;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import okhttp3.MediaType;
import okhttp3.Request;
import okhttp3.Request.Builder;
@ -24,8 +25,6 @@ import okhttp3.RequestBody;
import okhttp3.Response;
import org.json.JSONObject;
import org.mapstruct.factory.Mappers;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
@ -37,13 +36,12 @@ import java.util.*;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
@Slf4j
public class RemoteRecorder implements Recorder {
private static final String SUCCESS = "success";
private static final String COULDNT_SEND_REQUEST_SERVER_HTTP_STATUS = "Couldn't send request to server. Response {} - {}";
private static final Logger LOG = LoggerFactory.getLogger(RemoteRecorder.class);
public static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
private static final String LOG_MSG_SENDING_REQUERST = "Sending request to recording server: {}";
@ -79,10 +77,10 @@ public class RemoteRecorder implements Recorder {
@Override
public void addModel(Model model) throws IOException, InvalidKeyException, NoSuchAlgorithmException {
LOG.trace("Model marked: {}", model.isMarkedForLaterRecording());
LOG.trace("Model paused: {}", model.isSuspended());
LOG.trace("Model until: {}", model.getRecordUntil().equals(Instant.ofEpochMilli(Model.RECORD_INDEFINITELY)) ? "no limit" : model.getRecordUntil());
LOG.trace("Model after: {}", model.getRecordUntilSubsequentAction());
log.trace("Model marked: {}", model.isMarkedForLaterRecording());
log.trace("Model paused: {}", model.isSuspended());
log.trace("Model until: {}", model.getRecordUntil().equals(Instant.ofEpochMilli(Model.RECORD_INDEFINITELY)) ? "no limit" : model.getRecordUntil());
log.trace("Model after: {}", model.getRecordUntilSubsequentAction());
sendRequest("start", model);
findModel(model).ifPresent(cachedModel -> {
cachedModel.setSuspended(model.isSuspended());
@ -107,7 +105,7 @@ public class RemoteRecorder implements Recorder {
private Optional<String> sendRequest(String action) throws IOException, InvalidKeyException, NoSuchAlgorithmException {
String msg = "{\"action\": \"" + action + "\"}";
LOG.trace(LOG_MSG_SENDING_REQUERST, msg);
log.trace(LOG_MSG_SENDING_REQUERST, msg);
RequestBody requestBody = RequestBody.Companion.create(msg, JSON);
Request.Builder builder = new Request.Builder().url(getRecordingEndpoint()).post(requestBody);
addHmacIfNeeded(msg, builder);
@ -117,7 +115,7 @@ public class RemoteRecorder implements Recorder {
if (response.isSuccessful()) {
return Optional.of(responseBody);
} else {
LOG.error(COULDNT_SEND_REQUEST_SERVER_HTTP_STATUS, response.code(), responseBody);
log.error(COULDNT_SEND_REQUEST_SERVER_HTTP_STATUS, response.code(), responseBody);
return Optional.empty();
}
}
@ -125,7 +123,7 @@ public class RemoteRecorder implements Recorder {
private void sendRequest(String action, Model model) throws IOException, InvalidKeyException, NoSuchAlgorithmException {
String payload = mapper.writeValueAsString(new ModelRequest(action, model));
LOG.trace(LOG_MSG_SENDING_REQUERST, payload);
log.trace(LOG_MSG_SENDING_REQUERST, payload);
RequestBody body = RequestBody.Companion.create(payload, JSON);
Request.Builder builder = new Request.Builder().url(getRecordingEndpoint()).post(body);
addHmacIfNeeded(payload, builder);
@ -148,7 +146,7 @@ public class RemoteRecorder implements Recorder {
String msg = mapper.writeValueAsString(recReq);
RequestBody body = RequestBody.Companion.create(msg, JSON);
Request.Builder builder = new Request.Builder().url(getRecordingEndpoint()).post(body);
LOG.trace(LOG_MSG_SENDING_REQUERST, msg);
log.trace(LOG_MSG_SENDING_REQUERST, msg);
addHmacIfNeeded(msg, builder);
Request request = builder.build();
try (Response response = client.execute(request)) {
@ -170,7 +168,7 @@ public class RemoteRecorder implements Recorder {
private void sendRequest(String action, ModelGroup modelGroup) throws IOException, InvalidKeyException, NoSuchAlgorithmException {
String payload = mapper.writeValueAsString(new ModelGroupRequest(action, modelGroup));
LOG.trace(LOG_MSG_SENDING_REQUERST, payload);
log.trace(LOG_MSG_SENDING_REQUERST, payload);
RequestBody body = RequestBody.Companion.create(payload, JSON);
Request.Builder builder = new Request.Builder().url(getRecordingEndpoint()).post(body);
addHmacIfNeeded(payload, builder);
@ -283,11 +281,11 @@ public class RemoteRecorder implements Recorder {
try {
updateModelGroups(body);
} catch (IOException e) {
LOG.error("Error while loading model groups from server", e);
log.error("Error while loading model groups from server", e);
}
});
} catch (IOException | InvalidKeyException | NoSuchAlgorithmException e) {
LOG.error("Error while loading model groups from server", e);
log.error("Error while loading model groups from server", e);
}
}
@ -318,11 +316,11 @@ public class RemoteRecorder implements Recorder {
noSpaceLeftDetected = false;
}
} else {
LOG.error(COULDNT_SYNCHRONIZE_WITH_SERVER_HTTP_STATUS, response.code(), json);
log.error(COULDNT_SYNCHRONIZE_WITH_SERVER_HTTP_STATUS, response.code(), json);
}
}
} catch (IOException | InvalidKeyException | NoSuchAlgorithmException | IllegalStateException e) {
LOG.error(COULDNT_SYNCHRONIZE_WITH_SERVER, e);
log.error(COULDNT_SYNCHRONIZE_WITH_SERVER, e);
}
}
@ -348,14 +346,14 @@ public class RemoteRecorder implements Recorder {
}
lastSync = Instant.now();
} else {
LOG.error(SERVER_RETURNED_ERROR, resp.status, resp.msg);
log.error(SERVER_RETURNED_ERROR, resp.status, resp.msg);
}
} else {
LOG.error(COULDNT_SYNCHRONIZE_WITH_SERVER_HTTP_STATUS, response.code(), json);
log.error(COULDNT_SYNCHRONIZE_WITH_SERVER_HTTP_STATUS, response.code(), json);
}
}
} catch (IOException | InvalidKeyException | NoSuchAlgorithmException | IllegalStateException e) {
LOG.error(COULDNT_SYNCHRONIZE_WITH_SERVER, e);
log.error(COULDNT_SYNCHRONIZE_WITH_SERVER, e);
}
}
@ -380,14 +378,14 @@ public class RemoteRecorder implements Recorder {
}
}
} else {
LOG.error(SERVER_RETURNED_ERROR, resp.status, resp.msg);
log.error(SERVER_RETURNED_ERROR, resp.status, resp.msg);
}
} else {
LOG.error(COULDNT_SYNCHRONIZE_WITH_SERVER_HTTP_STATUS, response.code(), json);
log.error(COULDNT_SYNCHRONIZE_WITH_SERVER_HTTP_STATUS, response.code(), json);
}
}
} catch (IOException | InvalidKeyException | NoSuchAlgorithmException | IllegalStateException e) {
LOG.error(COULDNT_SYNCHRONIZE_WITH_SERVER, e);
log.error(COULDNT_SYNCHRONIZE_WITH_SERVER, e);
}
}
@ -448,14 +446,14 @@ public class RemoteRecorder implements Recorder {
}
}
} else {
LOG.error(SERVER_RETURNED_ERROR, resp.status, resp.msg);
log.error(SERVER_RETURNED_ERROR, resp.status, resp.msg);
}
} else {
LOG.error(COULDNT_SYNCHRONIZE_WITH_SERVER_HTTP_STATUS, response.code(), json);
log.error(COULDNT_SYNCHRONIZE_WITH_SERVER_HTTP_STATUS, response.code(), json);
}
}
} catch (IOException | InvalidKeyException | NoSuchAlgorithmException | IllegalStateException e) {
LOG.error(COULDNT_SYNCHRONIZE_WITH_SERVER, e);
log.error(COULDNT_SYNCHRONIZE_WITH_SERVER, e);
}
}
@ -629,7 +627,7 @@ public class RemoteRecorder implements Recorder {
public void rerunPostProcessing(Recording recording) throws IOException, InvalidKeyException, NoSuchAlgorithmException {
RecordingRequest recReq = new RecordingRequest("rerunPostProcessing", recording);
String msg = mapper.writeValueAsString(recReq);
LOG.debug(msg);
log.debug(msg);
RequestBody body = RequestBody.Companion.create(msg, JSON);
Request.Builder builder = new Request.Builder().url(getRecordingEndpoint()).post(body);
addHmacIfNeeded(msg, builder);
@ -695,7 +693,7 @@ public class RemoteRecorder implements Recorder {
@Override
public void markForLaterRecording(Model model, boolean mark) throws InvalidKeyException, NoSuchAlgorithmException, IOException {
model.setMarkedForLaterRecording(mark);
LOG.info("Marking model {} {}", model, mark);
log.info("Marking model {} {}", model, mark);
if (mark) {
sendRequest("markForLater", model);
} else {

View File

@ -3,8 +3,7 @@ package ctbrec.recorder.download;
import ctbrec.OS;
import ctbrec.io.DevNull;
import ctbrec.io.StreamRedirector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import java.io.ByteArrayOutputStream;
import java.io.File;
@ -14,8 +13,8 @@ import java.util.Arrays;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Slf4j
public class VideoLengthDetector {
private static final Logger LOG = LoggerFactory.getLogger(VideoLengthDetector.class);
private VideoLengthDetector() {
}
@ -37,7 +36,7 @@ public class VideoLengthDetector {
"-"
};
String[] cmdline = OS.getFFmpegCommand(args);
LOG.debug("Command line: {}", Arrays.toString(cmdline));
log.debug("Command line: {}", Arrays.toString(cmdline));
Process ffmpeg = Runtime.getRuntime().exec(cmdline, new String[0], videoFile.getParentFile());
int exitCode;
ByteArrayOutputStream stdErrBuffer = new ByteArrayOutputStream();
@ -46,16 +45,16 @@ public class VideoLengthDetector {
stdout.start();
stderr.start();
exitCode = ffmpeg.waitFor();
LOG.debug("FFmpeg exited with code {}", exitCode);
log.debug("FFmpeg exited with code {}", exitCode);
stdout.join();
stderr.join();
String ffmpegStderr = stdErrBuffer.toString();
return parseDuration(ffmpegStderr);
} catch (IOException | ProcessExitedUncleanException e) {
LOG.error("Error in FFMpeg thread", e);
log.error("Error in FFMpeg thread", e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
LOG.info("Interrupted while waiting for ffmpeg", e);
log.info("Interrupted while waiting for ffmpeg", e);
}
return Duration.ZERO.minusSeconds(1);
}

View File

@ -11,10 +11,9 @@ import ctbrec.recorder.download.AbstractDownload;
import ctbrec.recorder.download.dash.SegmentTimelineType.S;
import ctbrec.recorder.download.hls.NoStreamFoundException;
import ctbrec.recorder.download.hls.PostProcessingException;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Request;
import okhttp3.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
@ -38,11 +37,10 @@ import java.util.regex.Pattern;
import static ctbrec.Recording.State.POST_PROCESSING;
import static ctbrec.io.HttpConstants.*;
@Slf4j
public class DashDownload extends AbstractDownload {
private static final String CONTENT_LENGTH = "Content-Length";
private static final Logger LOG = LoggerFactory.getLogger(DashDownload.class);
private int audioCounter = 0;
private int videoCounter = 0;
private DecimalFormat df = new DecimalFormat("00000");
@ -74,7 +72,7 @@ public class DashDownload extends AbstractDownload {
.header(REFERER, model.getSite().getBaseUrl())
.header(CONNECTION, KEEP_ALIVE)
.build(); // @formatter:on
LOG.trace("Loading manifest {}", url);
log.trace("Loading manifest {}", url);
for (int tries = 1; tries <= 10; tries++) {
try (Response response = httpClient.execute(request)) {
if (response.isSuccessful()) {
@ -85,7 +83,7 @@ public class DashDownload extends AbstractDownload {
if (tries == 10) {
throw httpException;
} else {
LOG.debug("Couldn't load manifest", httpException);
log.debug("Couldn't load manifest", httpException);
waitSomeTime(100l * tries);
}
} else {
@ -165,12 +163,12 @@ public class DashDownload extends AbstractDownload {
private void setInitState(boolean isVideo, File file) {
if (isVideo) {
if (file.exists() && file.length() > 0) {
LOG.debug("Video init chunk loaded");
log.debug("Video init chunk loaded");
videoInitLoaded = true;
}
} else {
if (file.exists() && file.length() > 0) {
LOG.debug("Audio init chunk loaded");
log.debug("Audio init chunk loaded");
audioInitLoaded = true;
}
}
@ -191,7 +189,7 @@ public class DashDownload extends AbstractDownload {
for (tries = 1; tries <= 10; tries++) {
try (Response response = httpClient.execute(request)) {
if (!response.isSuccessful()) {
LOG.trace("Loading segment failed, try {}, {} size:{} {}", tries, response.code(), response.headers().values(CONTENT_LENGTH), url);
log.trace("Loading segment failed, try {}, {} size:{} {}", tries, response.code(), response.headers().values(CONTENT_LENGTH), url);
waitSomeTime(tries * 80l);
} else {
InputStream in = response.body().byteStream();
@ -214,7 +212,7 @@ public class DashDownload extends AbstractDownload {
}
}
}
LOG.warn("Loading segment finally failed after {} tries {}", --tries, url);
log.warn("Loading segment finally failed after {} tries {}", --tries, url);
return null;
}
@ -246,19 +244,19 @@ public class DashDownload extends AbstractDownload {
}
} catch (HttpException e) {
if (e.getResponseCode() == 404) {
LOG.debug("Manifest not found (404). Model {} probably went offline", model);
log.debug("Manifest not found (404). Model {} probably went offline", model);
waitSomeTime(10_000);
} else if (e.getResponseCode() == 403) {
LOG.debug("Manifest access forbidden (403). Model {} probably went private or offline", model);
log.debug("Manifest access forbidden (403). Model {} probably went private or offline", model);
waitSomeTime(10_000);
} else {
throw e;
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
LOG.error("Error while downloading dash stream", e);
log.error("Error while downloading dash stream", e);
} catch (Exception e) {
LOG.error("Error while downloading dash stream", e);
log.error("Error while downloading dash stream", e);
} finally {
running = false;
downloadFinished.set(true);
@ -280,7 +278,7 @@ public class DashDownload extends AbstractDownload {
private void downloadManifestAndItsSegments(Unmarshaller u) throws IOException, JAXBException, ExecutionException, InterruptedException {
String manifest = getManifest(manifestUrl);
LOG.trace("Manifest: {}", manifest);
log.trace("Manifest: {}", manifest);
@SuppressWarnings("unchecked")
JAXBElement<MPDtype> root = (JAXBElement<MPDtype>) u.unmarshal(new ByteArrayInputStream(manifest.getBytes()));
MPDtype mpd = root.getValue();
@ -302,7 +300,7 @@ public class DashDownload extends AbstractDownload {
downloaded += downloadSegments(mpd, audio, false);
if (downloaded == 0) {
LOG.trace("No new segments - Sleeping a bit");
log.trace("No new segments - Sleeping a bit");
waitSomeTime(1000);
}
}
@ -346,7 +344,7 @@ public class DashDownload extends AbstractDownload {
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
LOG.error("Couldn't wait for download to finish", e);
log.error("Couldn't wait for download to finish", e);
}
}
}

View File

@ -8,15 +8,13 @@ import java.nio.file.Files;
import java.util.Arrays;
import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.OS;
import ctbrec.io.StreamRedirector;
import ctbrec.recorder.download.ProcessExitedUncleanException;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class FfmpegMuxer {
private static final Logger LOG = LoggerFactory.getLogger(FfmpegMuxer.class);
private static final int ALL_GOOD = 0;
File segmentDir;
@ -42,11 +40,11 @@ public class FfmpegMuxer {
int exitCode = mergeTracks(mp4VideoTrack, mp4AudioTrack, targetFile);
if (exitCode == ALL_GOOD) {
LOG.debug("Deleting merged video and audio tracks");
log.debug("Deleting merged video and audio tracks");
Files.delete(mp4VideoTrack.toPath());
Files.delete(mp4AudioTrack.toPath());
Files.deleteIfExists(new File(segmentDir, "merge.log").toPath());
LOG.debug("Deleting segments");
log.debug("Deleting segments");
deleteFiles(segmentDir, videoSegments);
deleteFiles(segmentDir, audioSegments);
if (segmentDir.list().length == 0) {
@ -63,7 +61,7 @@ public class FfmpegMuxer {
try {
Files.delete(absFile.toPath());
} catch(IOException e) {
LOG.info("Couldn't delete segment {}", absFile, e);
log.info("Couldn't delete segment {}", absFile, e);
}
}
}
@ -97,7 +95,7 @@ public class FfmpegMuxer {
output.getCanonicalPath()
);
// @formatter:on
LOG.debug("Command line: {}", Arrays.toString(cmdline));
log.debug("Command line: {}", Arrays.toString(cmdline));
Process ffmpeg = Runtime.getRuntime().exec(cmdline);
Thread stdout = new Thread(new StreamRedirector(ffmpeg.getInputStream(), muxLogStream));
Thread stderr = new Thread(new StreamRedirector(ffmpeg.getErrorStream(), muxLogStream));
@ -109,7 +107,7 @@ public class FfmpegMuxer {
return exitCode;
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
LOG.error("Interrupted while waiting for FFMPEG", e);
log.error("Interrupted while waiting for FFMPEG", e);
return 1;
}
}

View File

@ -19,11 +19,10 @@ import ctbrec.recorder.download.HttpHeaderFactory;
import ctbrec.recorder.download.StreamSource;
import ctbrec.recorder.download.hls.SegmentPlaylist.Segment;
import ctbrec.sites.Site;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Request;
import okhttp3.Request.Builder;
import okhttp3.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.xml.bind.JAXBException;
import java.io.*;
@ -50,9 +49,9 @@ import static ctbrec.io.HttpConstants.*;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.nio.file.StandardOpenOption.*;
@Slf4j
public abstract class AbstractHlsDownload extends AbstractDownload {
private static final Logger LOG = LoggerFactory.getLogger(AbstractHlsDownload.class);
private static final int A_FEW_SECONDS = 10_000;
private static final int MAX_SECONDS_WITHOUT_TRANSFER = 30;
@ -100,7 +99,7 @@ public abstract class AbstractHlsDownload extends AbstractDownload {
}
protected void segmentDownloadFailed(SegmentDownload segmentDownload) {
LOG.info("Segment download failed with", segmentDownload.getException());
log.info("Segment download failed with", segmentDownload.getException());
stopRecordingOnHighSegmentErrorCount();
}
@ -135,16 +134,16 @@ public abstract class AbstractHlsDownload extends AbstractDownload {
}
if (Duration.between(lastSegmentDownload, Instant.now()).getSeconds() > MAX_SECONDS_WITHOUT_TRANSFER) {
LOG.info("No video data received for {} seconds. Stopping recording for model {}", MAX_SECONDS_WITHOUT_TRANSFER, model);
log.info("No video data received for {} seconds. Stopping recording for model {}", MAX_SECONDS_WITHOUT_TRANSFER, model);
stop();
return this;
}
} catch (ParseException e) {
LOG.error("Couldn't parse HLS playlist for model {}\n{}", model, e.getInput(), e);
log.error("Couldn't parse HLS playlist for model {}\n{}", model, e.getInput(), e);
model.delay();
stop();
} catch (PlaylistException e) {
LOG.error("Couldn't parse HLS playlist for model {}", model, e);
log.error("Couldn't parse HLS playlist for model {}", model, e);
model.delay();
stop();
} catch (PlaylistTimeoutException e) {
@ -156,18 +155,18 @@ public abstract class AbstractHlsDownload extends AbstractDownload {
}
} catch (EOFException e) {
// end of playlist reached
LOG.debug("Reached end of playlist for model {}", model);
log.debug("Reached end of playlist for model {}", model);
stop();
} catch (HttpException e) {
consecutivePlaylistErrors++;
handleHttpException(e);
} catch (Exception e) {
LOG.error("Couldn't download segment for model {}", model, e);
log.error("Couldn't download segment for model {}", model, e);
model.delay();
stop();
} finally {
if (consecutivePlaylistErrors > 0) {
LOG.debug("Consecutive playlist errors: {}", consecutivePlaylistErrors);
log.debug("Consecutive playlist errors: {}", consecutivePlaylistErrors);
}
}
return this;
@ -186,7 +185,7 @@ public abstract class AbstractHlsDownload extends AbstractDownload {
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
LOG.error("Thread interrupted during segment download", e);
log.error("Thread interrupted during segment download", e);
} catch (ExecutionException e) {
// Something unexpected went wrong during the segment download.
// At this point we have taken care of that, but we take note of the error and if a certain threshold of errors is exceeded in a certain
@ -211,9 +210,9 @@ public abstract class AbstractHlsDownload extends AbstractDownload {
iterator.remove();
}
}
LOG.debug("Segment errors in last {} secs for {}: {}", measurePeriodInSecs, getModel(), errorsInMeasurePeriod);
log.debug("Segment errors in last {} secs for {}: {}", measurePeriodInSecs, getModel(), errorsInMeasurePeriod);
if (errorsInMeasurePeriod > config.getSettings().segmentErrorThresholdToStopRecording) {
LOG.info("Too many ({}) segment errors for {} - stopping recording", errorsInMeasurePeriod, getModel());
log.info("Too many ({}) segment errors for {} - stopping recording", errorsInMeasurePeriod, getModel());
stop();
}
}
@ -227,11 +226,11 @@ public abstract class AbstractHlsDownload extends AbstractDownload {
checkIfModelIsStillOnline("Playlist access forbidden (403). Model {} probably went private or offline. Model state: {}");
}
if (consecutivePlaylistErrors >= 3) {
LOG.info("Playlist could not be downloaded for model {} {} times. Stopping recording", model, consecutivePlaylistErrors, e);
log.info("Playlist could not be downloaded for model {} {} times. Stopping recording", model, consecutivePlaylistErrors, e);
model.delay();
stop();
} else {
LOG.info("Playlist could not be downloaded for model {} {} times: {}", model, consecutivePlaylistErrors, e.getLocalizedMessage());
log.info("Playlist could not be downloaded for model {} {} times: {}", model, consecutivePlaylistErrors, e.getLocalizedMessage());
}
}
@ -242,31 +241,31 @@ public abstract class AbstractHlsDownload extends AbstractDownload {
} catch (Exception e1) {
modelState = State.UNKNOWN;
}
LOG.info(errorMsg, model, modelState);
log.info(errorMsg, model, modelState);
if (modelState != State.ONLINE) {
stop();
return;
}
try {
LOG.debug("Waiting {}ms before trying to update the playlist URL", A_FEW_SECONDS);
log.debug("Waiting {}ms before trying to update the playlist URL", A_FEW_SECONDS);
waitSomeTime();
segmentPlaylistUrl = getSegmentPlaylistUrl(model);
} catch (Exception e) {
LOG.error("Playlist URL couldn't be updated after waiting for {}ms", A_FEW_SECONDS, e);
log.error("Playlist URL couldn't be updated after waiting for {}ms", A_FEW_SECONDS, e);
}
}
protected String getSegmentPlaylistUrl(Model model) throws IOException, ExecutionException, ParseException, PlaylistException, JAXBException {
LOG.debug("{}:{} stream idx: {}", model.getSite().getName(), model.getName(), model.getStreamUrlIndex());
log.debug("{}:{} stream idx: {}", model.getSite().getName(), model.getName(), model.getStreamUrlIndex());
List<StreamSource> streamSources = model.getStreamSources();
Collections.sort(streamSources);
for (StreamSource streamSource : streamSources) {
LOG.debug("{}:{} src {}", model.getSite().getName(), model.getName(), streamSource);
log.debug("{}:{} src {}", model.getSite().getName(), model.getName(), streamSource);
}
StreamSource selectedStreamSource = selectStreamSource(streamSources);
String url = selectedStreamSource.getMediaPlaylistUrl();
selectedResolution = selectedStreamSource.getHeight();
LOG.debug("Segment playlist url {}", url);
log.debug("Segment playlist url {}", url);
return url;
}
@ -300,7 +299,7 @@ public abstract class AbstractHlsDownload extends AbstractDownload {
throw new HttpException(response.code(), response.message());
}
} catch (SocketTimeoutException e) {
LOG.debug("Playlist request timed out ({}ms) for model {} {} time{}", config.getSettings().playlistRequestTimeout, model,
log.debug("Playlist request timed out ({}ms) for model {} {} time{}", config.getSettings().playlistRequestTimeout, model,
++consecutivePlaylistTimeouts, (consecutivePlaylistTimeouts > 1) ? 's' : "");
// times out, return an empty playlist, so that the process can continue without wasting much more time
recordingEvents.add(RecordingEvent.of("Playlist request timed out " + consecutivePlaylistTimeouts));
@ -366,7 +365,7 @@ public abstract class AbstractHlsDownload extends AbstractDownload {
playlistEmptyCount = 0;
}
if (playlistEmptyCount == 10) {
LOG.info("Last 10 playlists were empty for {}. Stopping recording!", getModel());
log.info("Last 10 playlists were empty for {}. Stopping recording!", getModel());
model.delay();
internalStop();
}
@ -387,7 +386,7 @@ public abstract class AbstractHlsDownload extends AbstractDownload {
}
br.flush();
} catch (IOException e) {
LOG.error("Couldn't write log file for missed segments", e);
log.error("Couldn't write log file for missed segments", e);
}
}
}
@ -434,7 +433,7 @@ public abstract class AbstractHlsDownload extends AbstractDownload {
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
if (running) {
LOG.error("Couldn't sleep. This might mess up the download!");
log.error("Couldn't sleep. This might mess up the download!");
}
}
}

View File

@ -17,10 +17,9 @@ import ctbrec.recorder.download.AbstractDownload;
import ctbrec.recorder.download.ProcessExitedUncleanException;
import ctbrec.recorder.download.RecordingProcess;
import ctbrec.recorder.download.StreamSource;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Request;
import okhttp3.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.xml.bind.JAXBException;
import java.io.File;
@ -44,9 +43,9 @@ import java.util.regex.Pattern;
import static ctbrec.io.HttpConstants.*;
@Slf4j
public class FfmpegHlsDownload extends AbstractDownload {
private static final Logger LOG = LoggerFactory.getLogger(FfmpegHlsDownload.class);
private static final int MAX_SECONDS_WITHOUT_TRANSFER = 20;
private final HttpClient httpClient;
@ -94,7 +93,7 @@ public class FfmpegHlsDownload extends AbstractDownload {
try {
ffmpegStdIn.close();
} catch (IOException e) {
LOG.error("Couldn't terminate FFmpeg by closing stdin", e);
log.error("Couldn't terminate FFmpeg by closing stdin", e);
}
}
if (ffmpegProcess != null) {
@ -103,13 +102,13 @@ public class FfmpegHlsDownload extends AbstractDownload {
if (!waitFor && ffmpegProcess.isAlive()) {
ffmpegProcess.destroy();
if (ffmpegProcess.isAlive()) {
LOG.info("FFmpeg didn't terminate. Destroying the process with force!");
log.info("FFmpeg didn't terminate. Destroying the process with force!");
ffmpegProcess.destroyForcibly();
ffmpegProcess = null;
}
}
} catch (InterruptedException e) {
LOG.error("Interrupted while waiting for FFmpeg to terminate");
log.error("Interrupted while waiting for FFmpeg to terminate");
Thread.currentThread().interrupt();
}
}
@ -127,7 +126,7 @@ public class FfmpegHlsDownload extends AbstractDownload {
.build();
ffmpeg.exec(cmdline, new String[0], target.getParentFile());
} catch (IOException | ProcessExitedUncleanException e) {
LOG.error("Error in FFmpeg thread", e);
log.error("Error in FFmpeg thread", e);
}
}
@ -189,7 +188,7 @@ public class FfmpegHlsDownload extends AbstractDownload {
ffmpeg.shutdown(exitValue);
}
} catch (ProcessExitedUncleanException e) {
LOG.error("FFmpeg exited unclean", e);
log.error("FFmpeg exited unclean", e);
internalStop();
}
try {
@ -198,21 +197,21 @@ public class FfmpegHlsDownload extends AbstractDownload {
startDownload();
}
} catch (Exception e) {
LOG.error("Error while downloading MP4", e);
log.error("Error while downloading MP4", e);
stop();
}
if (!model.isOnline()) {
LOG.debug("Model {} not online. Stop recording.", model);
log.debug("Model {} not online. Stop recording.", model);
stop();
}
if (splittingStrategy.splitNecessary(this)) {
LOG.debug("Split necessary for model {}. Stop recording.", model);
log.debug("Split necessary for model {}. Stop recording.", model);
internalStop();
} else {
rescheduleTime = Instant.now().plusSeconds(5);
}
if (Duration.between(timeOfLastTransfer, Instant.now()).getSeconds() > MAX_SECONDS_WITHOUT_TRANSFER) {
LOG.debug("No video data received for {} seconds. Stopping recording for model {}", MAX_SECONDS_WITHOUT_TRANSFER, model);
log.debug("No video data received for {} seconds. Stopping recording for model {}", MAX_SECONDS_WITHOUT_TRANSFER, model);
stop();
}
return this;
@ -222,7 +221,7 @@ public class FfmpegHlsDownload extends AbstractDownload {
List<StreamSource> streamSources = model.getStreamSources();
Collections.sort(streamSources);
for (StreamSource streamSource : streamSources) {
LOG.debug("{}:{} src {}", model.getSite().getName(), model.getName(), streamSource);
log.debug("{}:{} src {}", model.getSite().getName(), model.getName(), streamSource);
}
StreamSource selectedStreamSource = selectStreamSource(streamSources);
String playlistUrl = selectedStreamSource.getMediaPlaylistUrl();
@ -245,14 +244,14 @@ public class FfmpegHlsDownload extends AbstractDownload {
if (media.hasTracks()) {
TrackData firstTrack = media.getTracks().get(0);
if (firstTrack.isEncrypted()) {
LOG.warn("Video track is encrypted. Playlist URL: {}", playlistUrl);
log.warn("Video track is encrypted. Playlist URL: {}", playlistUrl);
}
String uri = firstTrack.getUri();
if (!uri.startsWith("http")) {
URI context = URI.create(playlistUrl);
uri = context.resolve(uri).toURL().toExternalForm();
}
LOG.debug("Media url {}", uri);
log.debug("Media url {}", uri);
return uri;
} else {
throw new InvalidPlaylistException("Playlist has no media");
@ -281,7 +280,7 @@ public class FfmpegHlsDownload extends AbstractDownload {
.build();
try (Response resp = httpClient.execute(request)) {
if (resp.isSuccessful()) {
LOG.debug("Recording video stream to {}", targetFile);
log.debug("Recording video stream to {}", targetFile);
InputStream in = Objects.requireNonNull(resp.body()).byteStream();
byte[] b = new byte[1024 * 4];
int len;
@ -295,20 +294,20 @@ public class FfmpegHlsDownload extends AbstractDownload {
}
}
} catch (SocketTimeoutException e) {
LOG.debug("Socket timeout while downloading MP4 for {}. Stop recording.", model.getName());
log.debug("Socket timeout while downloading MP4 for {}. Stop recording.", model.getName());
model.delay();
stop();
} catch (IOException e) {
LOG.debug("IO error while downloading MP4 for {}. Stop recording.", model.getName());
log.debug("IO error while downloading MP4 for {}. Stop recording.", model.getName());
model.delay();
stop();
} catch (Exception e) {
LOG.error("Error while downloading MP4", e);
log.error("Error while downloading MP4", e);
stop();
} finally {
ffmpegStreamLock.unlock();
}
LOG.debug("Record finished for model {}", model);
log.debug("Record finished for model {}", model);
running = false;
});
}

View File

@ -8,8 +8,7 @@ import ctbrec.Recording;
import ctbrec.io.HttpClient;
import ctbrec.io.IoUtils;
import ctbrec.recorder.download.hls.SegmentPlaylist.Segment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import java.io.*;
import java.net.MalformedURLException;
@ -30,10 +29,9 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.regex.Pattern;
@Slf4j
public class HlsDownload extends AbstractHlsDownload {
private static final Logger LOG = LoggerFactory.getLogger(HlsDownload.class);
protected Path downloadDir;
private final Queue<Future<SegmentDownload>> segmentDownloads = new LinkedList<>();
@ -103,16 +101,16 @@ public class HlsDownload extends AbstractHlsDownload {
writer.write(master);
}
} catch (PlaylistException e) {
LOG.error("Updating segment playlist failed", e);
log.error("Updating segment playlist failed", e);
if (e.getErrors() != null) {
for (PlaylistError error : e.getErrors()) {
LOG.error("Playlist Error: {}", error);
log.error("Playlist Error: {}", error);
}
}
} catch (IOException | ParseException e) {
LOG.error("Updating segment playlist failed", e);
log.error("Updating segment playlist failed", e);
}
LOG.trace("Segment queue size for {}: {}", model, segmentDownloads.size());
log.trace("Segment queue size for {}: {}", model, segmentDownloads.size());
});
}
@ -131,7 +129,7 @@ public class HlsDownload extends AbstractHlsDownload {
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} catch (Exception e) {
LOG.info("Segment download failed for model {} - skipping adding segment to playlist", model);
log.info("Segment download failed for model {} - skipping adding segment to playlist", model);
}
}
}
@ -153,7 +151,7 @@ public class HlsDownload extends AbstractHlsDownload {
@Override
public void finalizeDownload() {
updatePlaylist(false);
LOG.debug("Download for {} terminated", model);
log.debug("Download for {} terminated", model);
}
@Override
@ -163,7 +161,7 @@ public class HlsDownload extends AbstractHlsDownload {
@Override
public void stop() {
LOG.debug("Recording stopped");
log.debug("Recording stopped");
internalStop();
}

View File

@ -11,17 +11,14 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
import java.util.function.Consumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.io.DevNull;
import ctbrec.io.ProcessStreamRedirector;
import ctbrec.recorder.download.ProcessExitedUncleanException;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class Hlsdl {
private static final Logger LOG = LoggerFactory.getLogger(Hlsdl.class);
private static ScheduledExecutorService processOutputReader = Executors.newScheduledThreadPool(2, createThreadFactory("hlsdl output stream reader"));
private Process process;
@ -46,7 +43,7 @@ public class Hlsdl {
}
public void exec(String[] cmdline, String[] env, File executionDir) throws IOException {
LOG.debug("hlsdl command line: {}", Arrays.toString(cmdline));
log.debug("hlsdl command line: {}", Arrays.toString(cmdline));
process = Runtime.getRuntime().exec(cmdline, env, executionDir);
afterStart();
}
@ -57,7 +54,7 @@ public class Hlsdl {
}
public void shutdown(int exitCode) throws IOException {
LOG.debug("hlsdl exit code was {}", exitCode);
log.debug("hlsdl exit code was {}", exitCode);
processLogStream.flush();
processLogStream.close();
stdoutRedirector.setKeepGoing(false);
@ -77,7 +74,7 @@ public class Hlsdl {
if (processLog == null) {
processLog = File.createTempFile("hlsdl_", ".log");
}
LOG.debug("Logging hlsdl output to {}", processLog);
log.debug("Logging hlsdl output to {}", processLog);
processLog.deleteOnExit();
processLogStream = new FileOutputStream(processLog);
} else {
@ -93,7 +90,7 @@ public class Hlsdl {
try {
startCallback.accept(process);
} catch(Exception e) {
LOG.error("Exception in onStart callback", e);
log.error("Exception in onStart callback", e);
}
}
@ -101,7 +98,7 @@ public class Hlsdl {
try {
exitCallback.accept(exitCode);
} catch(Exception e) {
LOG.error("Exception in onExit callback", e);
log.error("Exception in onExit callback", e);
}
}
@ -110,7 +107,7 @@ public class Hlsdl {
try {
shutdown(exitCode);
} catch (IOException e) {
LOG.error("Error while shutting down hlsdl process", e);
log.error("Error while shutting down hlsdl process", e);
}
return exitCode;
}

View File

@ -9,8 +9,7 @@ import ctbrec.Recording;
import ctbrec.recorder.download.AbstractDownload;
import ctbrec.recorder.download.ProcessExitedUncleanException;
import ctbrec.recorder.download.StreamSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import javax.xml.bind.JAXBException;
import java.io.File;
@ -29,10 +28,9 @@ import java.util.regex.Pattern;
import static ctbrec.recorder.download.StreamSource.UNKNOWN;
import static java.util.concurrent.TimeUnit.SECONDS;
@Slf4j
public class HlsdlDownload extends AbstractDownload {
private static final Logger LOG = LoggerFactory.getLogger(HlsdlDownload.class);
protected File targetFile;
private transient Hlsdl hlsdl;
@ -79,12 +77,12 @@ public class HlsdlDownload extends AbstractDownload {
} else {
int seconds = 90;
if (Duration.between(lastSizeChange, Instant.now()).toMillis() > SECONDS.toMillis(seconds)) {
LOG.info("Recording size didn't change for {} secs. Stopping recording for {}", seconds, model);
log.info("Recording size didn't change for {} secs. Stopping recording for {}", seconds, model);
stop();
}
}
} catch (ProcessExitedUncleanException e) {
LOG.error("hlsdl exited unclean", e);
log.error("hlsdl exited unclean", e);
}
return this;
}
@ -98,7 +96,7 @@ public class HlsdlDownload extends AbstractDownload {
.build();
hlsdl.exec(cmdline, OS.getEnvironment(), targetFile.getParentFile());
} catch (Exception e) {
LOG.error("Error starting hlsdl", e);
log.error("Error starting hlsdl", e);
}
}
@ -124,16 +122,16 @@ public class HlsdlDownload extends AbstractDownload {
}
protected String getSegmentPlaylistUrl(Model model) throws IOException, ExecutionException, ParseException, PlaylistException, JAXBException {
LOG.debug("{} stream idx: {}", model.getName(), model.getStreamUrlIndex());
log.debug("{} stream idx: {}", model.getName(), model.getStreamUrlIndex());
List<StreamSource> streamSources = model.getStreamSources();
Collections.sort(streamSources);
for (StreamSource streamSource : streamSources) {
LOG.debug("{} src {}", model.getName(), streamSource);
log.debug("{} src {}", model.getName(), streamSource);
}
String url = null;
if (model.getStreamUrlIndex() >= 0 && model.getStreamUrlIndex() < streamSources.size()) {
// TODO don't use the index, but the bandwidth. if the bandwidth does not match, take the closest one
LOG.debug("{} selected {}", model.getName(), streamSources.get(model.getStreamUrlIndex()));
log.debug("{} selected {}", model.getName(), streamSources.get(model.getStreamUrlIndex()));
url = streamSources.get(model.getStreamUrlIndex()).getMediaPlaylistUrl();
} else {
// filter out stream resolutions, which are out of range of the configured min and max
@ -147,11 +145,11 @@ public class HlsdlDownload extends AbstractDownload {
if (filteredStreamSources.isEmpty()) {
throw new ExecutionException(new NoStreamFoundException("No stream left in playlist"));
} else {
LOG.debug("{} selected {}", model.getName(), filteredStreamSources.get(filteredStreamSources.size() - 1));
log.debug("{} selected {}", model.getName(), filteredStreamSources.get(filteredStreamSources.size() - 1));
url = filteredStreamSources.get(filteredStreamSources.size() - 1).getMediaPlaylistUrl();
}
}
LOG.debug("Segment playlist url {}", url);
log.debug("Segment playlist url {}", url);
return url;
}
@ -162,7 +160,7 @@ public class HlsdlDownload extends AbstractDownload {
if (hlsdlProcess != null) {
hlsdlProcess.destroy();
if (hlsdlProcess.isAlive()) {
LOG.info("hlsdl didn't terminate. Destroying the process with force!");
log.info("hlsdl didn't terminate. Destroying the process with force!");
hlsdlProcess.destroyForcibly();
hlsdlProcess = null;
}

View File

@ -8,8 +8,7 @@ import ctbrec.io.HttpClient;
import ctbrec.recorder.FFmpeg;
import ctbrec.recorder.download.ProcessExitedUncleanException;
import ctbrec.recorder.download.hls.SegmentPlaylist.Segment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import java.io.ByteArrayOutputStream;
import java.io.File;
@ -22,10 +21,9 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.regex.Pattern;
@Slf4j
public class MergedFfmpegHlsDownload extends AbstractHlsDownload {
private static final Logger LOG = LoggerFactory.getLogger(MergedFfmpegHlsDownload.class);
protected File targetFile;
protected FFmpeg ffmpeg;
protected Process ffmpegProcess;
@ -39,7 +37,7 @@ public class MergedFfmpegHlsDownload extends AbstractHlsDownload {
@Override
public void init(Config config, Model model, Instant startTime, ExecutorService executorService) throws IOException {
LOG.debug("init start");
log.debug("init start");
super.init(config, model, startTime, executorService);
String fileSuffix = config.getSettings().ffmpegFileSuffix;
targetFile = config.getFileForRecording(model, fileSuffix, startTime);
@ -61,7 +59,7 @@ public class MergedFfmpegHlsDownload extends AbstractHlsDownload {
ffmpeg.shutdown(exitValue);
}
} catch (ProcessExitedUncleanException e) {
LOG.error("FFmpeg exited unclean", e);
log.error("FFmpeg exited unclean", e);
}
streamSegmentDataToFfmpeg();
@ -89,7 +87,7 @@ public class MergedFfmpegHlsDownload extends AbstractHlsDownload {
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} catch (Exception e) {
LOG.error("Segment download failed for model {}", model, e);
log.error("Segment download failed for model {}", model, e);
}
}
} finally {
@ -120,7 +118,7 @@ public class MergedFfmpegHlsDownload extends AbstractHlsDownload {
.build();
ffmpeg.exec(cmdline, new String[0], target.getParentFile());
} catch (IOException | ProcessExitedUncleanException e) {
LOG.error("Error in FFmpeg thread", e);
log.error("Error in FFmpeg thread", e);
}
}
@ -159,7 +157,7 @@ public class MergedFfmpegHlsDownload extends AbstractHlsDownload {
try {
ffmpegStdIn.close();
} catch (IOException e) {
LOG.error("Couldn't terminate FFmpeg by closing stdin", e);
log.error("Couldn't terminate FFmpeg by closing stdin", e);
}
}
@ -169,13 +167,13 @@ public class MergedFfmpegHlsDownload extends AbstractHlsDownload {
if (!waitFor && ffmpegProcess.isAlive()) {
ffmpegProcess.destroy();
if (ffmpegProcess.isAlive()) {
LOG.info("FFmpeg didn't terminate. Destroying the process with force!");
log.info("FFmpeg didn't terminate. Destroying the process with force!");
ffmpegProcess.destroyForcibly();
ffmpegProcess = null;
}
}
} catch (InterruptedException e) {
LOG.error("Interrupted while waiting for FFmpeg to terminate");
log.error("Interrupted while waiting for FFmpeg to terminate");
Thread.currentThread().interrupt();
}
}

View File

@ -6,11 +6,10 @@ import ctbrec.io.HttpClient;
import ctbrec.io.HttpException;
import ctbrec.recorder.download.HttpHeaderFactory;
import ctbrec.recorder.download.hls.SegmentPlaylist.Segment;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Request;
import okhttp3.Request.Builder;
import okhttp3.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.crypto.NoSuchPaddingException;
import java.io.*;
@ -29,8 +28,8 @@ import java.util.concurrent.Callable;
import static ctbrec.ErrorMessages.HTTP_RESPONSE_BODY_IS_NULL;
import static ctbrec.recorder.download.hls.AbstractHlsDownload.addHeaders;
@Slf4j
public class SegmentDownload implements Callable<SegmentDownload> {
private static final Logger LOG = LoggerFactory.getLogger(SegmentDownload.class);
protected final URL url;
protected final HttpClient client;
@ -67,7 +66,7 @@ public class SegmentDownload implements Callable<SegmentDownload> {
handleResponse(response);
break;
} catch (FileNotFoundException e) {
LOG.debug("Segment does not exist {}", url.getFile());
log.debug("Segment does not exist {}", url.getFile());
failed = true;
exception = e;
break;
@ -77,11 +76,11 @@ public class SegmentDownload implements Callable<SegmentDownload> {
break;
} catch (Exception e) {
if (tries == 3) {
LOG.warn("Error while downloading segment for {}. Segment {} finally failed: {}", model, url.getFile(), e.getMessage());
log.warn("Error while downloading segment for {}. Segment {} finally failed: {}", model, url.getFile(), e.getMessage());
failed = true;
exception = e;
} else {
LOG.debug("Error while downloading segment {} for {} on try {} - {}", url.getFile(), model, tries, e.getMessage());
log.debug("Error while downloading segment {} for {} on try {} - {}", url.getFile(), model, tries, e.getMessage());
}
}
}

View File

@ -5,15 +5,13 @@ import java.io.IOException;
import java.nio.file.Files;
import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.Recording;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class Copy extends AbstractPostProcessor {
private static final transient Logger LOG = LoggerFactory.getLogger(Copy.class);
@Override
public String getName() {
return "create a copy";
@ -25,7 +23,7 @@ public class Copy extends AbstractPostProcessor {
File orig = rec.getPostProcessedFile();
String copyFilename = getFilenameForCopy(orig);
File copy = new File(orig.getParentFile(), copyFilename);
LOG.info("Creating a copy {}", copy);
log.info("Creating a copy {}", copy);
if (orig.isFile()) {
Files.copy(rec.getPostProcessedFile().toPath(), copy.toPath());
} else {

View File

@ -12,20 +12,17 @@ import java.text.NumberFormat;
import java.util.Arrays;
import java.util.Locale;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.Config;
import ctbrec.OS;
import ctbrec.Recording;
import ctbrec.io.IoUtils;
import ctbrec.recorder.FFmpeg;
import ctbrec.recorder.download.ProcessExitedUncleanException;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class CreateContactSheet extends AbstractPlaceholderAwarePostProcessor {
private static final Logger LOG = LoggerFactory.getLogger(CreateContactSheet.class);
public static final String TOTAL_SIZE = "total_size";
public static final String PADDING = "padding";
public static final String COLS = "columns";
@ -79,7 +76,7 @@ public class CreateContactSheet extends AbstractPlaceholderAwarePostProcessor {
output.getCanonicalPath()
};
String[] cmdline = OS.getFFmpegCommand(args);
LOG.trace("Executing {} in working directory {}", Arrays.toString(cmdline), executionDir);
log.trace("Executing {} in working directory {}", Arrays.toString(cmdline), executionDir);
File ffmpegLog = new File(System.getProperty("java.io.tmpdir"), "create_contact_sheet_" + rec.getId() + ".log");
FFmpeg ffmpeg = new FFmpeg.Builder()
.logOutput(config.getSettings().logFFmpegOutput)
@ -147,7 +144,7 @@ public class CreateContactSheet extends AbstractPlaceholderAwarePostProcessor {
output.getCanonicalPath()
};
String[] cmdline = OS.getFFmpegCommand(args);
LOG.trace("Executing {} in working directory {}", Arrays.toString(cmdline), executionDir);
log.trace("Executing {} in working directory {}", Arrays.toString(cmdline), executionDir);
FFmpeg ffmpeg = new FFmpeg.Builder()
.logOutput(config.getSettings().logFFmpegOutput)

View File

@ -1,9 +1,9 @@
package ctbrec.recorder.postprocessing;
import ctbrec.Recording;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
@ -12,9 +12,9 @@ import java.util.Objects;
import static ctbrec.io.IoUtils.deleteEmptyParents;
@Slf4j
public class Move extends AbstractPlaceholderAwarePostProcessor {
private static final Logger LOG = LoggerFactory.getLogger(Move.class);
public static final String PATH_TEMPLATE = "path.template";
public static final String DEFAULT = "$sanitize(${modelName})" + File.separatorChar + "$format(${localDateTime})";
@ -34,7 +34,7 @@ public class Move extends AbstractPlaceholderAwarePostProcessor {
if (Objects.equals(src, target)) {
return true;
}
LOG.info("Moving {} to {}", src.getName(), target.getParentFile().getCanonicalPath());
log.info("Moving {} to {}", src.getName(), target.getParentFile().getCanonicalPath());
Files.createDirectories(target.getParentFile().toPath());
if (rec.getPostProcessedFile().isDirectory()) {
FileUtils.moveDirectory(rec.getPostProcessedFile(), target);

View File

@ -6,18 +6,15 @@ import java.nio.file.Files;
import java.util.Arrays;
import java.util.Objects;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.OS;
import ctbrec.Recording;
import ctbrec.io.IoUtils;
import ctbrec.recorder.FFmpeg;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class Remux extends AbstractPostProcessor {
private static final Logger LOG = LoggerFactory.getLogger(Remux.class);
public static final String PRE_FFMPEG_ARGS = "preffmpeg.args";
public static final String FFMPEG_ARGS = "ffmpeg.args";
public static final String FILE_EXT = "file.ext";
@ -40,7 +37,7 @@ public class Remux extends AbstractPostProcessor {
File remuxedFile = new File(rec.getPostProcessedFile().getAbsolutePath() + '.' + fileExt);
String[] cmdline = prepareCommandline(inputFile, remuxedFile);
File executionDir = rec.getPostProcessedFile().isDirectory() ? rec.getPostProcessedFile() : rec.getPostProcessedFile().getParentFile();
LOG.info("Executing {} in working directory {}", Arrays.toString(cmdline), executionDir);
log.info("Executing {} in working directory {}", Arrays.toString(cmdline), executionDir);
File ffmpegLog = new File(System.getProperty("java.io.tmpdir"), "remux_" + rec.getId() + ".log");
FFmpeg ffmpeg = new FFmpeg.Builder()
@ -74,7 +71,7 @@ public class Remux extends AbstractPostProcessor {
rec.getAssociatedFiles().remove(inputFile.getCanonicalPath());
rec.getAssociatedFiles().add(remuxedFile.getCanonicalPath());
} catch (IOException e) {
LOG.error("Couldn't finalize remux post-processing step", e);
log.error("Couldn't finalize remux post-processing step", e);
}
}
}

View File

@ -1,17 +1,15 @@
package ctbrec.recorder.postprocessing;
import ctbrec.Recording;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.Objects;
@Slf4j
public class Rename extends AbstractPlaceholderAwarePostProcessor {
private static final Logger LOG = LoggerFactory.getLogger(Rename.class);
public static final String FILE_NAME_TEMPLATE = "filename.template";
public static final String DEFAULT = "$sanitize(${modelName})_$format(${localDateTime}).${fileSuffix}";
public static final String DEFAULT_DIR = "$sanitize(${modelName})_$format(${localDateTime})";
@ -32,7 +30,7 @@ public class Rename extends AbstractPlaceholderAwarePostProcessor {
if (Objects.equals(src, target)) {
return true;
}
LOG.info("Renaming {} to {}", src.getName(), target.getName());
log.info("Renaming {} to {}", src.getName(), target.getName());
Files.move(rec.getPostProcessedFile().toPath(), target.toPath());
rec.setPostProcessedFile(target);
if (Objects.equals(src, rec.getAbsoluteFile())) {

View File

@ -7,17 +7,15 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.OS;
import ctbrec.Recording;
import ctbrec.io.StreamRedirector;
import ctbrec.recorder.download.ProcessExitedUncleanException;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class Script extends AbstractPlaceholderAwarePostProcessor {
private static final Logger LOG = LoggerFactory.getLogger(Script.class);
public static final String SCRIPT_EXECUTABLE = "script.executable";
public static final String SCRIPT_PARAMS = "script.params";
@ -32,8 +30,8 @@ public class Script extends AbstractPlaceholderAwarePostProcessor {
List<String> cmdline = buildCommandLine(ctx);
Runtime rt = Runtime.getRuntime();
String[] args = cmdline.toArray(new String[0]);
if (LOG.isDebugEnabled()) {
LOG.debug("Running {}", Arrays.toString(args));
if (log.isDebugEnabled()) {
log.debug("Running {}", Arrays.toString(args));
}
Process process = rt.exec(args, OS.getEnvironment());
File logFile = File.createTempFile("execute_script_" + rec.getId() + "_", ".log");
@ -41,7 +39,7 @@ public class Script extends AbstractPlaceholderAwarePostProcessor {
try (FileOutputStream logStream = new FileOutputStream(logFile)) {
startLogging(process, logStream);
int exitCode = process.waitFor();
LOG.debug("Process finished with exit code {}", exitCode);
log.debug("Process finished with exit code {}", exitCode);
if (exitCode != 0) {
throw new ProcessExitedUncleanException("Script finished with exit code " + exitCode);
}

View File

@ -1,8 +1,8 @@
package ctbrec.servlet;
import org.json.JSONArray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -12,8 +12,8 @@ import java.util.List;
import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
@Slf4j
public class SearchServlet extends AbstractDocServlet {
private static final Logger LOG = LoggerFactory.getLogger(SearchServlet.class);
private static final String Q = "term";
@Override
@ -37,7 +37,7 @@ public class SearchServlet extends AbstractDocServlet {
try {
resp.sendError(SC_INTERNAL_SERVER_ERROR, "Internal Server Error");
} catch (IOException ioe) {
LOG.error("Error while sending error response", ioe);
log.error("Error while sending error response", ioe);
}
}
}

View File

@ -5,14 +5,13 @@ import ctbrec.StringUtil;
import ctbrec.io.HttpClient;
import ctbrec.io.HttpException;
import ctbrec.sites.AbstractSite;
import lombok.extern.slf4j.Slf4j;
import okhttp3.FormBody;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.URLEncoder;
@ -23,10 +22,9 @@ import java.util.regex.Pattern;
import static ctbrec.ErrorMessages.HTTP_RESPONSE_BODY_IS_NULL;
import static ctbrec.io.HttpConstants.*;
@Slf4j
public class BongaCams extends AbstractSite {
private static final Logger LOG = LoggerFactory.getLogger(BongaCams.class);
private String baseUrl = "https://bongacams.com";
private BongaCamsHttpClient httpClient;
@ -157,7 +155,7 @@ public class BongaCams extends AbstractSite {
parseModelList(models, json);
return models;
} else {
LOG.warn("Search result: {}", json.toString(2));
log.warn("Search result: {}", json.toString(2));
return Collections.emptyList();
}
} else {

View File

@ -3,11 +3,10 @@ package ctbrec.sites.bonga;
import ctbrec.Config;
import ctbrec.io.HttpClient;
import ctbrec.io.HttpException;
import lombok.extern.slf4j.Slf4j;
import okhttp3.*;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.List;
@ -19,9 +18,8 @@ import java.util.Objects;
import static ctbrec.ErrorMessages.HTTP_RESPONSE_BODY_IS_NULL;
import static ctbrec.io.HttpConstants.*;
@Slf4j
public class BongaCamsHttpClient extends HttpClient {
private static final Logger LOG = LoggerFactory.getLogger(BongaCamsHttpClient.class);
private static final String SORT_COOKIE = "ls01";
private final BongaCams site;
private int userId = 0;
@ -59,7 +57,7 @@ public class BongaCamsHttpClient extends HttpClient {
boolean cookiesWorked = checkLoginSuccess();
if (cookiesWorked) {
loggedIn = true;
LOG.debug("Logged in with cookies");
log.debug("Logged in with cookies");
return true;
}

View File

@ -7,20 +7,18 @@ import java.io.IOException;
import java.util.Locale;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.Config;
import ctbrec.io.HttpClient;
import lombok.extern.slf4j.Slf4j;
import okhttp3.MediaType;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
@Slf4j
public class Cam4HttpClient extends HttpClient {
private static final Logger LOG = LoggerFactory.getLogger(Cam4HttpClient.class);
public Cam4HttpClient(Config config) {
super("cam4", config);
}
@ -34,12 +32,12 @@ public class Cam4HttpClient extends HttpClient {
boolean cookiesWorked = checkLoginSuccess();
if (cookiesWorked) {
loggedIn = true;
LOG.debug("Logged in with cookies");
log.debug("Logged in with cookies");
return true;
}
String url = Cam4.BASE_URI + "/rest/v2.0/login";
LOG.debug("Logging in {}", url);
log.debug("Logging in {}", url);
JSONObject bodyJson = new JSONObject();
bodyJson.put("username", config.getSettings().cam4Username);
bodyJson.put("password", config.getSettings().cam4Password);
@ -55,7 +53,7 @@ public class Cam4HttpClient extends HttpClient {
.build();
try (Response response = execute(req)) {
String body = response.body().string();
LOG.debug("Response: {} {}", response.code(), body);
log.debug("Response: {} {}", response.code(), body);
if (response.isSuccessful()) {
JSONObject json = new JSONObject(body);
return json.optInt("userId") != 0;
@ -72,7 +70,7 @@ public class Cam4HttpClient extends HttpClient {
public boolean checkLoginSuccess() throws IOException {
String url = Cam4.BASE_URI + "/rest/v2.0/login/user";
//String url = "http://login.cam4.com:1234/rest/v2.0/login/user";
LOG.debug("Checkin login success by calling {}", url);
log.debug("Checkin login success by calling {}", url);
Request req = new Request.Builder()
.url(url)
.header(USER_AGENT, config.getSettings().httpUserAgent)
@ -83,7 +81,7 @@ public class Cam4HttpClient extends HttpClient {
.build();
try (Response response = execute(req)) {
String body = response.body().string();
LOG.debug("Response: {} {}", response.code(), body);
log.debug("Response: {} {}", response.code(), body);
if (response.isSuccessful()) {
JSONObject json = new JSONObject(body);
return json.optInt("userId") != 0;

View File

@ -12,22 +12,20 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.Config;
import ctbrec.io.HttpException;
import ctbrec.sites.ModelOfflineException;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.WebSocket;
import okhttp3.WebSocketListener;
import okio.ByteString;
@Slf4j
public class Cam4WsClient {
private static final Logger LOG = LoggerFactory.getLogger(Cam4WsClient.class);
private Cam4 site;
private Cam4Model model;
private Config config;
@ -82,7 +80,7 @@ public class Cam4WsClient {
private CompletableFuture<String> send(String p, String msg) {
CompletableFuture<String> future = new CompletableFuture<>();
LOG.trace("--> {}", msg);
log.trace("--> {}", msg);
boolean sent = websocket.send(msg);
if (!sent) {
future.completeExceptionally(new IOException("send() returned false"));
@ -126,7 +124,7 @@ public class Cam4WsClient {
CompletableFuture<Boolean> connectedAndAuthorized = new CompletableFuture<>();
String url = shard + ".ws?v=5";
LOG.trace("Opening websocket {}", url);
log.trace("Opening websocket {}", url);
Request req = new Request.Builder() // @formatter:off
.url(url)
.header(USER_AGENT, config.getSettings().httpUserAgent)
@ -140,9 +138,9 @@ public class Cam4WsClient {
public void onOpen(WebSocket webSocket, Response response) {
super.onOpen(webSocket, response);
try {
LOG.trace("open: {}", response.body().string());
log.trace("open: {}", response.body().string());
} catch (IOException e) {
LOG.error("Connection open, but couldn't get the response body", e);
log.error("Connection open, but couldn't get the response body", e);
}
send("", "{\"t\":\"d\",\"d\":{\"r\":" + (r++) + ",\"a\":\"s\",\"b\":{\"c\":{\"sdk.js.2-3-1\":1}}}}");
send("", "{\"t\":\"d\",\"d\":{\"r\":" + (r++) + ",\"a\":\"auth\",\"b\":{\"cred\":\"" + token + "\"}}}");
@ -151,7 +149,7 @@ public class Cam4WsClient {
@Override
public void onClosed(WebSocket webSocket, int code, String reason) {
super.onClosed(webSocket, code, reason);
LOG.trace("closed: {} {}", code, reason);
log.trace("closed: {} {}", code, reason);
connectedAndAuthorized.complete(false);
}
@ -163,12 +161,12 @@ public class Cam4WsClient {
return;
}
if(response != null) {
LOG.error("failure {}: {}", model, response.body().string(), t);
log.error("failure {}: {}", model, response.body().string(), t);
} else {
LOG.error("failure {}:", model, t);
log.error("failure {}:", model, t);
}
} catch (IOException e) {
LOG.error("Connection failure and couldn't get the response body", e);
log.error("Connection failure and couldn't get the response body", e);
} finally {
connectedAndAuthorized.completeExceptionally(t);
}
@ -177,7 +175,7 @@ public class Cam4WsClient {
@Override
public void onMessage(WebSocket webSocket, String text) {
super.onMessage(webSocket, text);
LOG.trace("msgt: {}", text);
log.trace("msgt: {}", text);
JSONObject response = new JSONObject(text);
if (response.has("d")) {
JSONObject d = response.getJSONObject("d");
@ -207,7 +205,7 @@ public class Cam4WsClient {
@Override
public void onMessage(WebSocket webSocket, ByteString bytes) {
super.onMessage(webSocket, bytes);
LOG.trace("msgb: {}", bytes.hex());
log.trace("msgb: {}", bytes.hex());
}
});
return connectedAndAuthorized;

View File

@ -4,12 +4,11 @@ import ctbrec.Model;
import ctbrec.io.HttpClient;
import ctbrec.io.HttpException;
import ctbrec.sites.AbstractSite;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Request;
import okhttp3.Response;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.URLEncoder;
@ -22,9 +21,9 @@ import java.util.regex.Pattern;
import static ctbrec.io.HttpConstants.USER_AGENT;
import static java.nio.charset.StandardCharsets.UTF_8;
@Slf4j
public class Camsoda extends AbstractSite {
private static final Logger LOG = LoggerFactory.getLogger(Camsoda.class);
public static final String BASE_URI = "https://www.camsoda.com";
private HttpClient httpClient;
@ -153,7 +152,7 @@ public class Camsoda extends AbstractSite {
}
return models;
} else {
LOG.warn("Search result: {}", json.toString(2));
log.warn("Search result: {}", json.toString(2));
return Collections.emptyList();
}
} else {

View File

@ -8,19 +8,18 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.Config;
import ctbrec.io.HttpClient;
import ctbrec.io.HttpException;
import lombok.extern.slf4j.Slf4j;
import okhttp3.FormBody;
import okhttp3.Request;
import okhttp3.Response;
@Slf4j
public class CamsodaHttpClient extends HttpClient {
private static final Logger LOG = LoggerFactory.getLogger(CamsodaHttpClient.class);
private static final Pattern CSRF_PATTERN = Pattern.compile("\"csrf\"\\s*:\\s*\"(.*?)\"", MULTILINE | DOTALL);
private String csrfToken = null;
@ -37,7 +36,7 @@ public class CamsodaHttpClient extends HttpClient {
// persisted cookies might let us log in
if (checkLoginSuccess()) {
loggedIn = true;
LOG.debug("Logged in with cookies");
log.debug("Logged in with cookies");
return true;
}

View File

@ -7,14 +7,13 @@ import ctbrec.recorder.FFmpeg;
import ctbrec.recorder.download.AbstractDownload;
import ctbrec.recorder.download.ProcessExitedUncleanException;
import ctbrec.recorder.download.RecordingProcess;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.WebSocket;
import okhttp3.WebSocketListener;
import okio.ByteString;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
@ -30,9 +29,9 @@ import java.util.regex.Pattern;
import static ctbrec.io.HttpConstants.*;
@Slf4j
public class DreamcamDownload extends AbstractDownload {
private static final Logger LOG = LoggerFactory.getLogger(DreamcamDownload.class);
private static final int MAX_SECONDS_WITHOUT_TRANSFER = 30;
private final HttpClient httpClient;
@ -91,7 +90,7 @@ public class DreamcamDownload extends AbstractDownload {
try {
ffmpegStdIn.close();
} catch (IOException e) {
LOG.error("Couldn't terminate FFmpeg by closing stdin", e);
log.error("Couldn't terminate FFmpeg by closing stdin", e);
}
}
if (ffmpegProcess != null) {
@ -100,13 +99,13 @@ public class DreamcamDownload extends AbstractDownload {
if (!waitFor && ffmpegProcess.isAlive()) {
ffmpegProcess.destroy();
if (ffmpegProcess.isAlive()) {
LOG.info("FFmpeg didn't terminate. Destroying the process with force!");
log.info("FFmpeg didn't terminate. Destroying the process with force!");
ffmpegProcess.destroyForcibly();
ffmpegProcess = null;
}
}
} catch (InterruptedException e) {
LOG.error("Interrupted while waiting for FFmpeg to terminate");
log.error("Interrupted while waiting for FFmpeg to terminate");
Thread.currentThread().interrupt();
}
}
@ -124,7 +123,7 @@ public class DreamcamDownload extends AbstractDownload {
.build();
ffmpeg.exec(cmdline, new String[0], target.getParentFile());
} catch (IOException | ProcessExitedUncleanException e) {
LOG.error("Error in FFmpeg thread", e);
log.error("Error in FFmpeg thread", e);
}
}
@ -186,7 +185,7 @@ public class DreamcamDownload extends AbstractDownload {
ffmpeg.shutdown(exitValue);
}
} catch (ProcessExitedUncleanException e) {
LOG.error("FFmpeg exited unclean", e);
log.error("FFmpeg exited unclean", e);
internalStop();
}
try {
@ -195,22 +194,22 @@ public class DreamcamDownload extends AbstractDownload {
startDownload();
}
} catch (Exception e) {
LOG.error("Error while downloading", e);
log.error("Error while downloading", e);
stop();
}
if (!model.isOnline()) {
LOG.debug("Model {} not online. Stop recording.", model);
log.debug("Model {} not online. Stop recording.", model);
stop();
}
if (splittingStrategy.splitNecessary(this)) {
LOG.debug("Split necessary for model {}. Stop recording.", model);
log.debug("Split necessary for model {}. Stop recording.", model);
internalStop();
rescheduleTime = Instant.now();
} else {
rescheduleTime = Instant.now().plusSeconds(5);
}
if (Duration.between(timeOfLastTransfer, Instant.now()).getSeconds() > MAX_SECONDS_WITHOUT_TRANSFER) {
LOG.debug("No video data received for {} seconds. Stopping recording for model {}", MAX_SECONDS_WITHOUT_TRANSFER, model);
log.debug("No video data received for {} seconds. Stopping recording for model {}", MAX_SECONDS_WITHOUT_TRANSFER, model);
stop();
}
return this;
@ -222,9 +221,9 @@ public class DreamcamDownload extends AbstractDownload {
ffmpegStreamLock.lock();
try {
wsUrl = model.getWsUrl();
LOG.debug("{} ws url: {}", model.getName(), wsUrl);
log.debug("{} ws url: {}", model.getName(), wsUrl);
if (StringUtil.isBlank(wsUrl)) {
LOG.error("{}: Stream URL not found", model);
log.error("{}: Stream URL not found", model);
stop();
return;
}
@ -241,7 +240,7 @@ public class DreamcamDownload extends AbstractDownload {
@Override
public void onOpen(WebSocket webSocket, Response response) {
super.onOpen(webSocket, response);
LOG.debug("{}: Websocket open", model);
log.debug("{}: Websocket open", model);
if (response != null) {
response.close();
}
@ -254,7 +253,7 @@ public class DreamcamDownload extends AbstractDownload {
@Override
public void onClosed(WebSocket webSocket, int code, String reason) {
super.onClosed(webSocket, code, reason);
LOG.trace("{}: Websocket closed", model);
log.trace("{}: Websocket closed", model);
stop();
synchronized (monitor) {
monitor.notifyAll();
@ -264,7 +263,7 @@ public class DreamcamDownload extends AbstractDownload {
@Override
public void onFailure(WebSocket webSocket, Throwable t, Response response) {
super.onFailure(webSocket, t, response);
LOG.debug("{}: Websocket failed: {}", model, t.getMessage());
log.debug("{}: Websocket failed: {}", model, t.getMessage());
if (response != null) {
response.close();
}
@ -277,7 +276,7 @@ public class DreamcamDownload extends AbstractDownload {
@Override
public void onMessage(WebSocket webSocket, String text) {
super.onMessage(webSocket, text);
LOG.trace("{} ws message: {}", model, text);
log.trace("{} ws message: {}", model, text);
JSONObject message = new JSONObject(text);
if (message.optString("url").equals("stream/qual")) {
JSONObject msg = new JSONObject();
@ -300,7 +299,7 @@ public class DreamcamDownload extends AbstractDownload {
}
} catch (IOException e) {
if (running) {
LOG.error("Couldn't write video stream to file", e);
log.error("Couldn't write video stream to file", e);
stop();
}
}
@ -313,12 +312,12 @@ public class DreamcamDownload extends AbstractDownload {
monitor.wait();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
LOG.warn("Interrupted while waiting for the download to terminate");
log.warn("Interrupted while waiting for the download to terminate");
}
}
} catch (IOException ex) {
if (running) {
LOG.error("Error while downloading: {}", ex.getMessage());
log.error("Error while downloading: {}", ex.getMessage());
stop();
}
} finally {

Some files were not shown because too many files have changed in this diff Show More