forked from j62/ctbrec
Store minimal browser config in ctbrec's config dir
This commit is contained in:
parent
793f6d371f
commit
281d70d29b
|
@ -7,6 +7,7 @@
|
||||||
* Renamed settings for Chaturbate's user name and password
|
* Renamed settings for Chaturbate's user name and password
|
||||||
* Add setting to split recordings by size
|
* Add setting to split recordings by size
|
||||||
* Fixed moving of segment recordings on the server (post-processing)
|
* Fixed moving of segment recordings on the server (post-processing)
|
||||||
|
* Minimal browser config is now stored in ctbrec's config directory
|
||||||
|
|
||||||
3.10.6
|
3.10.6
|
||||||
========================
|
========================
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
package ctbrec.ui;
|
package ctbrec.ui;
|
||||||
|
|
||||||
|
import static java.nio.charset.StandardCharsets.*;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.concurrent.locks.Lock;
|
import java.util.concurrent.locks.Lock;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
@ -47,7 +51,9 @@ public class ExternalBrowser implements AutoCloseable {
|
||||||
|
|
||||||
addProxyConfig(jsonConfig.getJSONObject("config"));
|
addProxyConfig(jsonConfig.getJSONObject("config"));
|
||||||
|
|
||||||
p = new ProcessBuilder(OS.getBrowserCommand()).start();
|
File configDir = new File(Config.getInstance().getConfigDir(), "ctbrec-minimal-browser");
|
||||||
|
String[] cmdline = OS.getBrowserCommand(configDir.getCanonicalPath());
|
||||||
|
p = new ProcessBuilder(cmdline).start();
|
||||||
if (LOG.isTraceEnabled()) {
|
if (LOG.isTraceEnabled()) {
|
||||||
new Thread(new StreamRedirector(p.getInputStream(), System.out)).start();
|
new Thread(new StreamRedirector(p.getInputStream(), System.out)).start();
|
||||||
new Thread(new StreamRedirector(p.getErrorStream(), System.err)).start();
|
new Thread(new StreamRedirector(p.getErrorStream(), System.err)).start();
|
||||||
|
@ -55,7 +61,7 @@ public class ExternalBrowser implements AutoCloseable {
|
||||||
new Thread(new StreamRedirector(p.getInputStream(), OutputStream.nullOutputStream())).start();
|
new Thread(new StreamRedirector(p.getInputStream(), OutputStream.nullOutputStream())).start();
|
||||||
new Thread(new StreamRedirector(p.getErrorStream(), OutputStream.nullOutputStream())).start();
|
new Thread(new StreamRedirector(p.getErrorStream(), OutputStream.nullOutputStream())).start();
|
||||||
}
|
}
|
||||||
LOG.debug("Browser started");
|
LOG.debug("Browser started: {}", Arrays.toString(cmdline));
|
||||||
|
|
||||||
connectToRemoteControlSocket();
|
connectToRemoteControlSocket();
|
||||||
while (!browserReady) {
|
while (!browserReady) {
|
||||||
|
@ -68,7 +74,7 @@ public class ExternalBrowser implements AutoCloseable {
|
||||||
} else {
|
} else {
|
||||||
LOG.debug("Connected to remote control server. Sending config");
|
LOG.debug("Connected to remote control server. Sending config");
|
||||||
}
|
}
|
||||||
out.write(jsonConfig.toString().getBytes("utf-8"));
|
out.write(jsonConfig.toString().getBytes(UTF_8));
|
||||||
out.write('\n');
|
out.write('\n');
|
||||||
out.flush();
|
out.flush();
|
||||||
|
|
||||||
|
@ -116,7 +122,7 @@ public class ExternalBrowser implements AutoCloseable {
|
||||||
//LOG.debug("Executing JS {}", javaScript);
|
//LOG.debug("Executing JS {}", javaScript);
|
||||||
JSONObject script = new JSONObject();
|
JSONObject script = new JSONObject();
|
||||||
script.put("execute", javaScript);
|
script.put("execute", javaScript);
|
||||||
out.write(script.toString().getBytes("utf-8"));
|
out.write(script.toString().getBytes(UTF_8));
|
||||||
out.write('\n');
|
out.write('\n');
|
||||||
out.flush();
|
out.flush();
|
||||||
if(javaScript.equals("quit")) {
|
if(javaScript.equals("quit")) {
|
||||||
|
|
|
@ -17,6 +17,7 @@ import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -145,6 +146,17 @@ public class Config {
|
||||||
settings.splitRecordingsAfterSecs = settings.splitRecordings;
|
settings.splitRecordingsAfterSecs = settings.splitRecordings;
|
||||||
settings.splitRecordings = 0;
|
settings.splitRecordings = 0;
|
||||||
}
|
}
|
||||||
|
// migrate old config from ctbrec-minimal browser
|
||||||
|
File oldLocation = new File(OS.getConfigDir().getParentFile(), "ctbrec-minimal-browser");
|
||||||
|
if (oldLocation.exists()) {
|
||||||
|
File newLocation = new File(getConfigDir(), oldLocation.getName());
|
||||||
|
try {
|
||||||
|
LOG.debug("Moving minimal browser config {} --> {}", oldLocation, newLocation);
|
||||||
|
FileUtils.moveDirectory(oldLocation, newLocation);
|
||||||
|
} catch (IOException e) {
|
||||||
|
LOG.error("Couldn't migrate minimal browser config location", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void makeBackup(File source) {
|
private void makeBackup(File source) {
|
||||||
|
|
Loading…
Reference in New Issue