mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-08-09 23:36:51 +02:00
@@ -11,15 +11,17 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
implementation("com.lmax:disruptor:3.4.2")
|
||||||
implementation("org.java-websocket:Java-WebSocket:1.5.1")
|
implementation("org.java-websocket:Java-WebSocket:1.5.1")
|
||||||
implementation("org.jsoup:jsoup:1.8.1")
|
implementation("org.jsoup:jsoup:1.8.1")
|
||||||
implementation("org.json:json:20190722")
|
implementation("org.json:json:20190722")
|
||||||
implementation("commons-configuration:commons-configuration:1.7")
|
implementation("commons-configuration:commons-configuration:1.7")
|
||||||
implementation("log4j:log4j:1.2.17")
|
|
||||||
implementation("commons-cli:commons-cli:1.2")
|
implementation("commons-cli:commons-cli:1.2")
|
||||||
implementation("commons-io:commons-io:1.3.2")
|
implementation("commons-io:commons-io:1.3.2")
|
||||||
implementation("org.apache.httpcomponents:httpclient:4.3.6")
|
implementation("org.apache.httpcomponents:httpclient:4.3.6")
|
||||||
implementation("org.apache.httpcomponents:httpmime:4.3.3")
|
implementation("org.apache.httpcomponents:httpmime:4.3.3")
|
||||||
|
implementation("org.apache.logging.log4j:log4j-api:2.14.1")
|
||||||
|
implementation("org.apache.logging.log4j:log4j-core:2.14.1")
|
||||||
implementation("org.graalvm.js:js:20.1.0")
|
implementation("org.graalvm.js:js:20.1.0")
|
||||||
testImplementation(enforcedPlatform("org.junit:junit-bom:5.6.2"))
|
testImplementation(enforcedPlatform("org.junit:junit-bom:5.6.2"))
|
||||||
testImplementation("org.junit.jupiter:junit-jupiter")
|
testImplementation("org.junit.jupiter:junit-jupiter")
|
||||||
|
11
pom.xml
11
pom.xml
@@ -59,9 +59,14 @@
|
|||||||
<version>1.7</version>
|
<version>1.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>log4j-api</artifactId>
|
||||||
<version>1.2.17</version>
|
<version>2.14.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-core</artifactId>
|
||||||
|
<version>2.14.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-cli</groupId>
|
<groupId>commons-cli</groupId>
|
||||||
|
@@ -24,7 +24,6 @@ import org.apache.commons.cli.HelpFormatter;
|
|||||||
import org.apache.commons.cli.Options;
|
import org.apache.commons.cli.Options;
|
||||||
import org.apache.commons.cli.ParseException;
|
import org.apache.commons.cli.ParseException;
|
||||||
import org.apache.commons.lang.SystemUtils;
|
import org.apache.commons.lang.SystemUtils;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
import com.rarchives.ripme.ripper.AbstractRipper;
|
import com.rarchives.ripme.ripper.AbstractRipper;
|
||||||
import com.rarchives.ripme.ui.History;
|
import com.rarchives.ripme.ui.History;
|
||||||
@@ -34,6 +33,8 @@ import com.rarchives.ripme.ui.UpdateUtils;
|
|||||||
import com.rarchives.ripme.utils.Proxy;
|
import com.rarchives.ripme.utils.Proxy;
|
||||||
import com.rarchives.ripme.utils.RipUtils;
|
import com.rarchives.ripme.utils.RipUtils;
|
||||||
import com.rarchives.ripme.utils.Utils;
|
import com.rarchives.ripme.utils.Utils;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entry point to application.
|
* Entry point to application.
|
||||||
@@ -44,7 +45,7 @@ import com.rarchives.ripme.utils.Utils;
|
|||||||
*/
|
*/
|
||||||
public class App {
|
public class App {
|
||||||
|
|
||||||
public static final Logger logger = Logger.getLogger(App.class);
|
public static final Logger logger = LogManager.getLogger(App.class);
|
||||||
public static String stringToAppendToFoldername = null;
|
public static String stringToAppendToFoldername = null;
|
||||||
private static final History HISTORY = new History();
|
private static final History HISTORY = new History();
|
||||||
|
|
||||||
|
@@ -14,8 +14,9 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Observable;
|
import java.util.Observable;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
import org.apache.log4j.FileAppender;
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.jsoup.HttpStatusException;
|
import org.jsoup.HttpStatusException;
|
||||||
import com.rarchives.ripme.App;
|
import com.rarchives.ripme.App;
|
||||||
import com.rarchives.ripme.ui.RipStatusComplete;
|
import com.rarchives.ripme.ui.RipStatusComplete;
|
||||||
@@ -28,7 +29,7 @@ public abstract class AbstractRipper
|
|||||||
extends Observable
|
extends Observable
|
||||||
implements RipperInterface, Runnable {
|
implements RipperInterface, Runnable {
|
||||||
|
|
||||||
protected static final Logger LOGGER = Logger.getLogger(AbstractRipper.class);
|
protected static final Logger LOGGER = LogManager.getLogger(AbstractRipper.class);
|
||||||
private final String URLHistoryFile = Utils.getURLHistoryFile();
|
private final String URLHistoryFile = Utils.getURLHistoryFile();
|
||||||
|
|
||||||
public static final String USER_AGENT =
|
public static final String USER_AGENT =
|
||||||
@@ -177,12 +178,15 @@ public abstract class AbstractRipper
|
|||||||
*/
|
*/
|
||||||
public void setup() throws IOException {
|
public void setup() throws IOException {
|
||||||
setWorkingDir(this.url);
|
setWorkingDir(this.url);
|
||||||
Logger rootLogger = Logger.getRootLogger();
|
// we do not care if the rollingfileappender is active, just change the logfile in case
|
||||||
FileAppender fa = (FileAppender) rootLogger.getAppender("FILE");
|
// TODO this does not work - not even with
|
||||||
if (fa != null) {
|
// .withFileName("${sys:logFilename}")
|
||||||
fa.setFile(this.workingDir + File.separator + "log.txt");
|
// in Utils.java, RollingFileAppender.
|
||||||
fa.activateOptions();
|
// System.setProperty("logFilename", this.workingDir + "/log.txt");
|
||||||
}
|
// LOGGER.debug("Changing log file to '{}/log.txt'", this.workingDir);
|
||||||
|
// LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
|
||||||
|
// ctx.reconfigure();
|
||||||
|
// ctx.updateLoggers();
|
||||||
|
|
||||||
this.threadPool = new DownloadThreadPool();
|
this.threadPool = new DownloadThreadPool();
|
||||||
}
|
}
|
||||||
@@ -482,13 +486,13 @@ public abstract class AbstractRipper
|
|||||||
RipStatusMessage msg = new RipStatusMessage(STATUS.RIP_COMPLETE, rsc);
|
RipStatusMessage msg = new RipStatusMessage(STATUS.RIP_COMPLETE, rsc);
|
||||||
observer.update(this, msg);
|
observer.update(this, msg);
|
||||||
|
|
||||||
Logger rootLogger = Logger.getRootLogger();
|
// we do not care if the rollingfileappender is active, just change the logfile in case
|
||||||
FileAppender fa = (FileAppender) rootLogger.getAppender("FILE");
|
// TODO - does not work.
|
||||||
if (fa != null) {
|
// System.setProperty("logFilename", "ripme.log");
|
||||||
LOGGER.debug("Changing log file back to 'ripme.log'");
|
// LOGGER.debug("Changing log file back to 'ripme.log'");
|
||||||
fa.setFile("ripme.log");
|
// LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
|
||||||
fa.activateOptions();
|
// ctx.reconfigure();
|
||||||
}
|
|
||||||
if (Utils.getConfigBoolean("urls_only.save", false)) {
|
if (Utils.getConfigBoolean("urls_only.save", false)) {
|
||||||
String urlFile = this.workingDir + File.separator + "urls.txt";
|
String urlFile = this.workingDir + File.separator + "urls.txt";
|
||||||
try {
|
try {
|
||||||
|
@@ -13,7 +13,8 @@ import java.util.ResourceBundle;
|
|||||||
import javax.net.ssl.HttpsURLConnection;
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
|
|
||||||
import com.rarchives.ripme.ui.MainWindow;
|
import com.rarchives.ripme.ui.MainWindow;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.jsoup.HttpStatusException;
|
import org.jsoup.HttpStatusException;
|
||||||
|
|
||||||
import com.rarchives.ripme.ui.RipStatusMessage.STATUS;
|
import com.rarchives.ripme.ui.RipStatusMessage.STATUS;
|
||||||
@@ -24,7 +25,7 @@ import com.rarchives.ripme.utils.Utils;
|
|||||||
* and other goodies.
|
* and other goodies.
|
||||||
*/
|
*/
|
||||||
class DownloadFileThread extends Thread {
|
class DownloadFileThread extends Thread {
|
||||||
private static final Logger logger = Logger.getLogger(DownloadFileThread.class);
|
private static final Logger logger = LogManager.getLogger(DownloadFileThread.class);
|
||||||
|
|
||||||
private String referrer = "";
|
private String referrer = "";
|
||||||
private Map<String, String> cookies = new HashMap<>();
|
private Map<String, String> cookies = new HashMap<>();
|
||||||
|
@@ -4,16 +4,16 @@ import java.util.concurrent.Executors;
|
|||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
import com.rarchives.ripme.utils.Utils;
|
import com.rarchives.ripme.utils.Utils;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple wrapper around a FixedThreadPool.
|
* Simple wrapper around a FixedThreadPool.
|
||||||
*/
|
*/
|
||||||
public class DownloadThreadPool {
|
public class DownloadThreadPool {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(DownloadThreadPool.class);
|
private static final Logger logger = LogManager.getLogger(DownloadThreadPool.class);
|
||||||
private ThreadPoolExecutor threadPool = null;
|
private ThreadPoolExecutor threadPool = null;
|
||||||
|
|
||||||
public DownloadThreadPool() {
|
public DownloadThreadPool() {
|
||||||
|
@@ -11,10 +11,10 @@ import java.net.URL;
|
|||||||
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
import com.rarchives.ripme.ui.RipStatusMessage.STATUS;
|
import com.rarchives.ripme.ui.RipStatusMessage.STATUS;
|
||||||
import com.rarchives.ripme.utils.Utils;
|
import com.rarchives.ripme.utils.Utils;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thread for downloading files.
|
* Thread for downloading files.
|
||||||
@@ -22,7 +22,7 @@ import com.rarchives.ripme.utils.Utils;
|
|||||||
*/
|
*/
|
||||||
class DownloadVideoThread extends Thread {
|
class DownloadVideoThread extends Thread {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(DownloadVideoThread.class);
|
private static final Logger logger = LogManager.getLogger(DownloadVideoThread.class);
|
||||||
|
|
||||||
private URL url;
|
private URL url;
|
||||||
private File saveAs;
|
private File saveAs;
|
||||||
|
@@ -12,12 +12,14 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Document;
|
||||||
import org.jsoup.nodes.Element;
|
import org.jsoup.nodes.Element;
|
||||||
|
|
||||||
public class BooruRipper extends AbstractHTMLRipper {
|
public class BooruRipper extends AbstractHTMLRipper {
|
||||||
private static final Logger logger = Logger.getLogger(BooruRipper.class);
|
private static final Logger logger = LogManager.getLogger(BooruRipper.class);
|
||||||
|
|
||||||
private static Pattern gidPattern = null;
|
private static Pattern gidPattern = null;
|
||||||
|
|
||||||
|
@@ -17,7 +17,9 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Document;
|
||||||
import org.jsoup.nodes.Element;
|
import org.jsoup.nodes.Element;
|
||||||
import org.jsoup.select.Elements;
|
import org.jsoup.select.Elements;
|
||||||
@@ -25,7 +27,7 @@ import org.jsoup.select.Elements;
|
|||||||
|
|
||||||
|
|
||||||
public class E621Ripper extends AbstractHTMLRipper {
|
public class E621Ripper extends AbstractHTMLRipper {
|
||||||
private static final Logger logger = Logger.getLogger(E621Ripper.class);
|
private static final Logger logger = LogManager.getLogger(E621Ripper.class);
|
||||||
|
|
||||||
private static Pattern gidPattern = null;
|
private static Pattern gidPattern = null;
|
||||||
private static Pattern gidPattern2 = null;
|
private static Pattern gidPattern2 = null;
|
||||||
|
@@ -5,7 +5,6 @@ import com.rarchives.ripme.ui.History;
|
|||||||
import com.rarchives.ripme.ui.RipStatusMessage;
|
import com.rarchives.ripme.ui.RipStatusMessage;
|
||||||
import com.rarchives.ripme.utils.Http;
|
import com.rarchives.ripme.utils.Http;
|
||||||
import com.rarchives.ripme.utils.Utils;
|
import com.rarchives.ripme.utils.Utils;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.jsoup.Connection;
|
import org.jsoup.Connection;
|
||||||
|
@@ -15,13 +15,15 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Document;
|
||||||
import org.jsoup.nodes.Element;
|
import org.jsoup.nodes.Element;
|
||||||
import org.jsoup.select.Elements;
|
import org.jsoup.select.Elements;
|
||||||
|
|
||||||
public class PahealRipper extends AbstractHTMLRipper {
|
public class PahealRipper extends AbstractHTMLRipper {
|
||||||
private static final Logger logger = Logger.getLogger(PahealRipper.class);
|
private static final Logger logger = LogManager.getLogger(PahealRipper.class);
|
||||||
|
|
||||||
private static Map<String, String> cookies = null;
|
private static Map<String, String> cookies = null;
|
||||||
private static Pattern gidPattern = null;
|
private static Pattern gidPattern = null;
|
||||||
|
@@ -49,14 +49,15 @@ import javax.swing.text.SimpleAttributeSet;
|
|||||||
import javax.swing.text.StyleConstants;
|
import javax.swing.text.StyleConstants;
|
||||||
import javax.swing.text.StyledDocument;
|
import javax.swing.text.StyledDocument;
|
||||||
|
|
||||||
import org.apache.log4j.ConsoleAppender;
|
|
||||||
import org.apache.log4j.FileAppender;
|
|
||||||
import org.apache.log4j.Level;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
import com.rarchives.ripme.ripper.AbstractRipper;
|
import com.rarchives.ripme.ripper.AbstractRipper;
|
||||||
import com.rarchives.ripme.utils.RipUtils;
|
import com.rarchives.ripme.utils.RipUtils;
|
||||||
import com.rarchives.ripme.utils.Utils;
|
import com.rarchives.ripme.utils.Utils;
|
||||||
|
import org.apache.logging.log4j.Level;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.apache.logging.log4j.core.LoggerContext;
|
||||||
|
import org.apache.logging.log4j.core.config.Configuration;
|
||||||
|
import org.apache.logging.log4j.core.config.LoggerConfig;
|
||||||
|
|
||||||
import javax.swing.UnsupportedLookAndFeelException;
|
import javax.swing.UnsupportedLookAndFeelException;
|
||||||
|
|
||||||
@@ -65,7 +66,7 @@ import javax.swing.UnsupportedLookAndFeelException;
|
|||||||
*/
|
*/
|
||||||
public final class MainWindow implements Runnable, RipStatusHandler {
|
public final class MainWindow implements Runnable, RipStatusHandler {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(MainWindow.class);
|
private static final Logger LOGGER = LogManager.getLogger(MainWindow.class);
|
||||||
|
|
||||||
private boolean isRipping = false; // Flag to indicate if we're ripping something
|
private boolean isRipping = false; // Flag to indicate if we're ripping something
|
||||||
|
|
||||||
@@ -993,16 +994,11 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
newLevel = Level.ERROR;
|
newLevel = Level.ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Logger.getRootLogger().setLevel(newLevel);
|
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
|
||||||
LOGGER.setLevel(newLevel);
|
Configuration config = ctx.getConfiguration();
|
||||||
ConsoleAppender ca = (ConsoleAppender) Logger.getRootLogger().getAppender("stdout");
|
LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
|
||||||
if (ca != null) {
|
loggerConfig.setLevel(newLevel);
|
||||||
ca.setThreshold(newLevel);
|
ctx.updateLoggers(); // This causes all Loggers to refetch information from their LoggerConfig.
|
||||||
}
|
|
||||||
FileAppender fa = (FileAppender) Logger.getRootLogger().getAppender("FILE");
|
|
||||||
if (fa != null) {
|
|
||||||
fa.setThreshold(newLevel);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupTrayIcon() {
|
private void setupTrayIcon() {
|
||||||
@@ -1382,34 +1378,34 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
switch (msg.getStatus()) {
|
switch (msg.getStatus()) {
|
||||||
case LOADING_RESOURCE:
|
case LOADING_RESOURCE:
|
||||||
case DOWNLOAD_STARTED:
|
case DOWNLOAD_STARTED:
|
||||||
if (LOGGER.isEnabledFor(Level.INFO)) {
|
if (LOGGER.isEnabled(Level.INFO)) {
|
||||||
appendLog("Downloading " + msg.getObject(), Color.BLACK);
|
appendLog("Downloading " + msg.getObject(), Color.BLACK);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DOWNLOAD_COMPLETE:
|
case DOWNLOAD_COMPLETE:
|
||||||
if (LOGGER.isEnabledFor(Level.INFO)) {
|
if (LOGGER.isEnabled(Level.INFO)) {
|
||||||
appendLog("Downloaded " + msg.getObject(), Color.GREEN);
|
appendLog("Downloaded " + msg.getObject(), Color.GREEN);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DOWNLOAD_COMPLETE_HISTORY:
|
case DOWNLOAD_COMPLETE_HISTORY:
|
||||||
if (LOGGER.isEnabledFor(Level.INFO)) {
|
if (LOGGER.isEnabled(Level.INFO)) {
|
||||||
appendLog("" + msg.getObject(), Color.GREEN);
|
appendLog("" + msg.getObject(), Color.GREEN);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DOWNLOAD_ERRORED:
|
case DOWNLOAD_ERRORED:
|
||||||
if (LOGGER.isEnabledFor(Level.ERROR)) {
|
if (LOGGER.isEnabled(Level.ERROR)) {
|
||||||
appendLog((String) msg.getObject(), Color.RED);
|
appendLog((String) msg.getObject(), Color.RED);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DOWNLOAD_WARN:
|
case DOWNLOAD_WARN:
|
||||||
if (LOGGER.isEnabledFor(Level.WARN)) {
|
if (LOGGER.isEnabled(Level.WARN)) {
|
||||||
appendLog((String) msg.getObject(), Color.ORANGE);
|
appendLog((String) msg.getObject(), Color.ORANGE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIP_ERRORED:
|
case RIP_ERRORED:
|
||||||
if (LOGGER.isEnabledFor(Level.ERROR)) {
|
if (LOGGER.isEnabled(Level.ERROR)) {
|
||||||
appendLog((String) msg.getObject(), Color.RED);
|
appendLog((String) msg.getObject(), Color.RED);
|
||||||
}
|
}
|
||||||
stopButton.setEnabled(false);
|
stopButton.setEnabled(false);
|
||||||
@@ -1511,7 +1507,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
// Update total bytes
|
// Update total bytes
|
||||||
break;
|
break;
|
||||||
case NO_ALBUM_OR_USER:
|
case NO_ALBUM_OR_USER:
|
||||||
if (LOGGER.isEnabledFor(Level.ERROR)) {
|
if (LOGGER.isEnabled(Level.ERROR)) {
|
||||||
appendLog((String) msg.getObject(), Color.RED);
|
appendLog((String) msg.getObject(), Color.RED);
|
||||||
}
|
}
|
||||||
stopButton.setEnabled(false);
|
stopButton.setEnabled(false);
|
||||||
|
@@ -11,7 +11,8 @@ import javax.swing.JLabel;
|
|||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.jsoup.Connection.Response;
|
import org.jsoup.Connection.Response;
|
||||||
@@ -22,7 +23,7 @@ import com.rarchives.ripme.utils.Utils;
|
|||||||
|
|
||||||
public class UpdateUtils {
|
public class UpdateUtils {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(UpdateUtils.class);
|
private static final Logger logger = LogManager.getLogger(UpdateUtils.class);
|
||||||
// do not update the default version without adjusting the unit test. the real version comes from METAINF.MF
|
// do not update the default version without adjusting the unit test. the real version comes from METAINF.MF
|
||||||
private static final String DEFAULT_VERSION = "1.7.94-10-b6345398";
|
private static final String DEFAULT_VERSION = "1.7.94-10-b6345398";
|
||||||
private static final String REPO_NAME = "ripmeapp/ripme";
|
private static final String REPO_NAME = "ripmeapp/ripme";
|
||||||
|
@@ -8,7 +8,8 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.apache.commons.lang.ArrayUtils;
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.jsoup.Connection;
|
import org.jsoup.Connection;
|
||||||
import org.jsoup.Connection.Method;
|
import org.jsoup.Connection.Method;
|
||||||
@@ -28,7 +29,7 @@ import com.rarchives.ripme.ripper.AbstractRipper;
|
|||||||
public class Http {
|
public class Http {
|
||||||
|
|
||||||
private static final int TIMEOUT = Utils.getConfigInteger("page.timeout", 5 * 1000);
|
private static final int TIMEOUT = Utils.getConfigInteger("page.timeout", 5 * 1000);
|
||||||
private static final Logger logger = Logger.getLogger(Http.class);
|
private static final Logger logger = LogManager.getLogger(Http.class);
|
||||||
|
|
||||||
private int retries;
|
private int retries;
|
||||||
private String url;
|
private String url;
|
||||||
|
@@ -16,14 +16,15 @@ import com.rarchives.ripme.ripper.rippers.VidbleRipper;
|
|||||||
import com.rarchives.ripme.ripper.rippers.GfycatRipper;
|
import com.rarchives.ripme.ripper.rippers.GfycatRipper;
|
||||||
import com.rarchives.ripme.ripper.rippers.SoundgasmRipper;
|
import com.rarchives.ripme.ripper.rippers.SoundgasmRipper;
|
||||||
import org.apache.commons.lang.math.NumberUtils;
|
import org.apache.commons.lang.math.NumberUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Document;
|
||||||
import org.jsoup.nodes.Element;
|
import org.jsoup.nodes.Element;
|
||||||
|
|
||||||
|
|
||||||
public class RipUtils {
|
public class RipUtils {
|
||||||
private static final Logger logger = Logger.getLogger(RipUtils.class);
|
private static final Logger logger = LogManager.getLogger(RipUtils.class);
|
||||||
|
|
||||||
public static List<URL> getFilesFromURL(URL url) {
|
public static List<URL> getFilesFromURL(URL url) {
|
||||||
List<URL> result = new ArrayList<>();
|
List<URL> result = new ArrayList<>();
|
||||||
|
@@ -3,7 +3,6 @@ package com.rarchives.ripme.utils;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
@@ -40,9 +39,15 @@ import com.rarchives.ripme.ripper.AbstractRipper;
|
|||||||
|
|
||||||
import org.apache.commons.configuration.ConfigurationException;
|
import org.apache.commons.configuration.ConfigurationException;
|
||||||
import org.apache.commons.configuration.PropertiesConfiguration;
|
import org.apache.commons.configuration.PropertiesConfiguration;
|
||||||
import org.apache.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.apache.log4j.PropertyConfigurator;
|
import org.apache.logging.log4j.core.LoggerContext;
|
||||||
|
import org.apache.logging.log4j.core.appender.RollingFileAppender;
|
||||||
|
import org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy;
|
||||||
|
import org.apache.logging.log4j.core.appender.rolling.SizeBasedTriggeringPolicy;
|
||||||
|
import org.apache.logging.log4j.core.appender.rolling.TriggeringPolicy;
|
||||||
|
import org.apache.logging.log4j.core.config.Configuration;
|
||||||
|
import org.apache.logging.log4j.core.config.LoggerConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common utility functions used in various places throughout the project.
|
* Common utility functions used in various places throughout the project.
|
||||||
@@ -54,7 +59,7 @@ public class Utils {
|
|||||||
private static final String RIP_DIRECTORY = "rips";
|
private static final String RIP_DIRECTORY = "rips";
|
||||||
private static final String CONFIG_FILE = "rip.properties";
|
private static final String CONFIG_FILE = "rip.properties";
|
||||||
private static final String OS = System.getProperty("os.name").toLowerCase();
|
private static final String OS = System.getProperty("os.name").toLowerCase();
|
||||||
private static final Logger LOGGER = Logger.getLogger(Utils.class);
|
private static final Logger LOGGER = LogManager.getLogger(Utils.class);
|
||||||
private static final int SHORTENED_PATH_LENGTH = 12;
|
private static final int SHORTENED_PATH_LENGTH = 12;
|
||||||
|
|
||||||
private static PropertiesConfiguration config;
|
private static PropertiesConfiguration config;
|
||||||
@@ -602,20 +607,32 @@ public class Utils {
|
|||||||
* Configures root logger, either for FILE output or just console.
|
* Configures root logger, either for FILE output or just console.
|
||||||
*/
|
*/
|
||||||
public static void configureLogger() {
|
public static void configureLogger() {
|
||||||
LogManager.shutdown();
|
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
|
||||||
String logFile = getConfigBoolean("log.save", false) ? "log4j.file.properties" : "log4j.properties";
|
Configuration config = ctx.getConfiguration();
|
||||||
try (InputStream stream = Utils.class.getClassLoader().getResourceAsStream(logFile)) {
|
LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
|
||||||
if (stream == null) {
|
|
||||||
PropertyConfigurator.configure("src/main/resources/" + logFile);
|
// write to ripme.log file if checked in GUI
|
||||||
|
boolean logSave = getConfigBoolean("log.save", false);
|
||||||
|
if (logSave) {
|
||||||
|
LOGGER.debug("add rolling appender ripmelog");
|
||||||
|
TriggeringPolicy tp = SizeBasedTriggeringPolicy.createPolicy("20M");
|
||||||
|
DefaultRolloverStrategy rs = DefaultRolloverStrategy.newBuilder().withMax("2").build();
|
||||||
|
RollingFileAppender rolling = RollingFileAppender.newBuilder()
|
||||||
|
.setName("ripmelog")
|
||||||
|
.withFileName("ripme.log")
|
||||||
|
.withFilePattern("%d{yyyy-MM-dd HH:mm:ss} %p %m%n")
|
||||||
|
.withPolicy(tp)
|
||||||
|
.withStrategy(rs)
|
||||||
|
.build();
|
||||||
|
loggerConfig.addAppender(rolling, null, null);
|
||||||
} else {
|
} else {
|
||||||
PropertyConfigurator.configure(stream);
|
LOGGER.debug("remove rolling appender ripmelog");
|
||||||
|
if (config.getAppender("ripmelog") != null) {
|
||||||
|
config.getAppender("ripmelog").stop();
|
||||||
}
|
}
|
||||||
|
loggerConfig.removeAppender("ripmelog");
|
||||||
LOGGER.info("Loaded " + logFile);
|
|
||||||
} catch (IOException e) {
|
|
||||||
LOGGER.error(e.getMessage(), e);
|
|
||||||
}
|
}
|
||||||
|
ctx.updateLoggers(); // This causes all Loggers to refetch information from their LoggerConfig.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,10 +0,0 @@
|
|||||||
|
|
||||||
# define the console appender
|
|
||||||
log4j.appender.stdout = org.apache.log4j.ConsoleAppender
|
|
||||||
log4j.appender.stdout.Target = System.out
|
|
||||||
log4j.appender.stdout.Threshold = info
|
|
||||||
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
|
|
||||||
log4j.appender.stdout.layout.ConversionPattern = %m%n
|
|
||||||
|
|
||||||
# now map our console appender as a root logger, means all log messages will go to this appender
|
|
||||||
log4j.rootLogger = debug, stdout
|
|
30
src/main/resources/log4j2-example.xml
Normal file
30
src/main/resources/log4j2-example.xml
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Configuration status="INFO">
|
||||||
|
<Appenders>
|
||||||
|
# Console appender
|
||||||
|
<Console name="stdout" target="SYSTEM_OUT">
|
||||||
|
# Pattern of log message for console appender
|
||||||
|
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} %p %m%n"/>
|
||||||
|
</Console>
|
||||||
|
|
||||||
|
# Rolling appender
|
||||||
|
<RollingFile name="ripmelog"
|
||||||
|
fileName="ripme.log" filePattern="ripme.%i.log.gz"
|
||||||
|
ignoreExceptions="false">
|
||||||
|
<PatternLayout>
|
||||||
|
<Pattern>%d{yyyy-MM-dd HH:mm:ss} %p %m%n</Pattern>
|
||||||
|
</PatternLayout>
|
||||||
|
<Policies>
|
||||||
|
<OnStartupTriggeringPolicy/>
|
||||||
|
<SizeBasedTriggeringPolicy size="20 MB"/>
|
||||||
|
</Policies>
|
||||||
|
</RollingFile>
|
||||||
|
</Appenders>
|
||||||
|
|
||||||
|
<Loggers>
|
||||||
|
<AsyncRoot level="INFO">
|
||||||
|
<AppenderRef ref="ripmelog"/>
|
||||||
|
<AppenderRef ref="stdout"/>
|
||||||
|
</AsyncRoot>
|
||||||
|
</Loggers>
|
||||||
|
</Configuration>
|
@@ -6,11 +6,21 @@ import java.util.Arrays;
|
|||||||
|
|
||||||
import com.rarchives.ripme.utils.Utils;
|
import com.rarchives.ripme.utils.Utils;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class UtilsTest {
|
public class UtilsTest {
|
||||||
|
|
||||||
|
private final Logger LOGGER = LogManager.getLogger(UtilsTest.class);
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConfigureLogger() {
|
||||||
|
Utils.configureLogger();
|
||||||
|
LOGGER.warn("this is a warning messaage.");
|
||||||
|
}
|
||||||
|
|
||||||
public void testGetEXTFromMagic()
|
public void testGetEXTFromMagic()
|
||||||
{
|
{
|
||||||
Assertions.assertEquals("jpeg", Utils.getEXTFromMagic(new byte[] { -1, -40, -1, -37, 0, 0, 0, 0 }));
|
Assertions.assertEquals("jpeg", Utils.getEXTFromMagic(new byte[] { -1, -40, -1, -37, 0, 0, 0, 0 }));
|
||||||
|
@@ -6,9 +6,12 @@ import java.util.List;
|
|||||||
|
|
||||||
import com.rarchives.ripme.ripper.rippers.ChanRipper;
|
import com.rarchives.ripme.ripper.rippers.ChanRipper;
|
||||||
|
|
||||||
import org.apache.log4j.ConsoleAppender;
|
import org.apache.logging.log4j.Level;
|
||||||
import org.apache.log4j.Level;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.apache.logging.log4j.core.LoggerContext;
|
||||||
|
import org.apache.logging.log4j.core.config.Configuration;
|
||||||
|
import org.apache.logging.log4j.core.config.LoggerConfig;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
|
||||||
import com.rarchives.ripme.ripper.AbstractRipper;
|
import com.rarchives.ripme.ripper.AbstractRipper;
|
||||||
@@ -19,12 +22,16 @@ import com.rarchives.ripme.utils.Utils;
|
|||||||
*/
|
*/
|
||||||
public class RippersTest {
|
public class RippersTest {
|
||||||
|
|
||||||
private final Logger logger = Logger.getLogger(RippersTest.class);
|
private final Logger logger = LogManager.getLogger(RippersTest.class);
|
||||||
|
|
||||||
void testRipper(AbstractRipper ripper) {
|
void testRipper(AbstractRipper ripper) {
|
||||||
try {
|
try {
|
||||||
// Turn on Debug logging
|
// Turn on Debug logging
|
||||||
((ConsoleAppender) Logger.getRootLogger().getAppender("stdout")).setThreshold(Level.DEBUG);
|
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
|
||||||
|
Configuration config = ctx.getConfiguration();
|
||||||
|
LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
|
||||||
|
loggerConfig.setLevel(Level.DEBUG);
|
||||||
|
ctx.updateLoggers(); // This causes all Loggers to refetch information from their LoggerConfig.
|
||||||
|
|
||||||
// Decrease timeout
|
// Decrease timeout
|
||||||
Utils.setConfigInteger("page.timeout", 20 * 1000);
|
Utils.setConfigInteger("page.timeout", 20 * 1000);
|
||||||
@@ -56,9 +63,6 @@ public class RippersTest {
|
|||||||
// that we found links to it
|
// that we found links to it
|
||||||
void testChanRipper(ChanRipper ripper) {
|
void testChanRipper(ChanRipper ripper) {
|
||||||
try {
|
try {
|
||||||
// Turn on Debug logging
|
|
||||||
((ConsoleAppender) Logger.getRootLogger().getAppender("stdout")).setThreshold(Level.DEBUG);
|
|
||||||
|
|
||||||
// Decrease timeout
|
// Decrease timeout
|
||||||
Utils.setConfigInteger("page.timeout", 20 * 1000);
|
Utils.setConfigInteger("page.timeout", 20 * 1000);
|
||||||
|
|
||||||
|
@@ -10,11 +10,12 @@ import java.util.Set;
|
|||||||
|
|
||||||
import com.rarchives.ripme.utils.Utils;
|
import com.rarchives.ripme.utils.Utils;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class LabelsBundlesTest {
|
public class LabelsBundlesTest {
|
||||||
private Logger logger = Logger.getLogger(Utils.class);
|
private Logger logger = LogManager.getLogger(Utils.class);
|
||||||
private static final String DEFAULT_LANG = "en_US";
|
private static final String DEFAULT_LANG = "en_US";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Reference in New Issue
Block a user