parent
e4c2b2e3fb
commit
700440d033
2
pom.xml
2
pom.xml
@ -4,7 +4,7 @@
|
|||||||
<groupId>com.rarchives.ripme</groupId>
|
<groupId>com.rarchives.ripme</groupId>
|
||||||
<artifactId>ripme</artifactId>
|
<artifactId>ripme</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<version>1.0.60</version>
|
<version>1.0.61</version>
|
||||||
<name>ripme</name>
|
<name>ripme</name>
|
||||||
<url>http://rip.rarchives.com</url>
|
<url>http://rip.rarchives.com</url>
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -24,11 +24,13 @@ import com.rarchives.ripme.utils.Utils;
|
|||||||
*/
|
*/
|
||||||
public class App {
|
public class App {
|
||||||
|
|
||||||
public static final Logger logger = Logger.getLogger(App.class);
|
public static Logger logger;
|
||||||
|
|
||||||
public static void main(String[] args) throws MalformedURLException {
|
public static void main(String[] args) throws MalformedURLException {
|
||||||
|
Utils.configureLogger();
|
||||||
System.setProperty("apple.laf.useScreenMenuBar", "true");
|
System.setProperty("apple.laf.useScreenMenuBar", "true");
|
||||||
System.setProperty("com.apple.mrj.application.apple.menu.about.name", "RipMe");
|
System.setProperty("com.apple.mrj.application.apple.menu.about.name", "RipMe");
|
||||||
|
logger = Logger.getLogger(App.class);
|
||||||
logger.info("Initialized ripme v" + UpdateUtils.getThisJarVersion());
|
logger.info("Initialized ripme v" + UpdateUtils.getThisJarVersion());
|
||||||
|
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
|
@ -74,8 +74,10 @@ public abstract class AbstractRipper
|
|||||||
setWorkingDir(this.url);
|
setWorkingDir(this.url);
|
||||||
Logger rootLogger = Logger.getRootLogger();
|
Logger rootLogger = Logger.getRootLogger();
|
||||||
FileAppender fa = (FileAppender) rootLogger.getAppender("FILE");
|
FileAppender fa = (FileAppender) rootLogger.getAppender("FILE");
|
||||||
fa.setFile(this.workingDir + File.separator + "log.txt");
|
if (fa != null) {
|
||||||
fa.activateOptions();
|
fa.setFile(this.workingDir + File.separator + "log.txt");
|
||||||
|
fa.activateOptions();
|
||||||
|
}
|
||||||
|
|
||||||
this.threadPool = new DownloadThreadPool();
|
this.threadPool = new DownloadThreadPool();
|
||||||
}
|
}
|
||||||
|
@ -109,6 +109,7 @@ public class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
private static JCheckBox configPlaySound;
|
private static JCheckBox configPlaySound;
|
||||||
private static JCheckBox configSaveOrderCheckbox;
|
private static JCheckBox configSaveOrderCheckbox;
|
||||||
private static JCheckBox configShowPopup;
|
private static JCheckBox configShowPopup;
|
||||||
|
private static JCheckBox configSaveLogs;
|
||||||
|
|
||||||
private static TrayIcon trayIcon;
|
private static TrayIcon trayIcon;
|
||||||
private static MenuItem trayMenuMain;
|
private static MenuItem trayMenuMain;
|
||||||
@ -174,6 +175,7 @@ public class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
Utils.setConfigBoolean("play.sound", configPlaySound.isSelected());
|
Utils.setConfigBoolean("play.sound", configPlaySound.isSelected());
|
||||||
Utils.setConfigBoolean("download.save_order", configSaveOrderCheckbox.isSelected());
|
Utils.setConfigBoolean("download.save_order", configSaveOrderCheckbox.isSelected());
|
||||||
Utils.setConfigBoolean("download.show_popup", configShowPopup.isSelected());
|
Utils.setConfigBoolean("download.show_popup", configShowPopup.isSelected());
|
||||||
|
Utils.setConfigBoolean("log.save", configSaveLogs.isSelected());
|
||||||
saveHistory();
|
saveHistory();
|
||||||
Utils.saveConfig();
|
Utils.saveConfig();
|
||||||
}
|
}
|
||||||
@ -317,12 +319,15 @@ public class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
configPlaySound = new JCheckBox("Sound when rip completes", Utils.getConfigBoolean("play.sound", false));
|
configPlaySound = new JCheckBox("Sound when rip completes", Utils.getConfigBoolean("play.sound", false));
|
||||||
configPlaySound.setHorizontalAlignment(JCheckBox.RIGHT);
|
configPlaySound.setHorizontalAlignment(JCheckBox.RIGHT);
|
||||||
configPlaySound.setHorizontalTextPosition(JCheckBox.LEFT);
|
configPlaySound.setHorizontalTextPosition(JCheckBox.LEFT);
|
||||||
configSaveOrderCheckbox = new JCheckBox("Save images in order", Utils.getConfigBoolean("download.save_order", true));
|
configSaveOrderCheckbox = new JCheckBox("Preserve order", Utils.getConfigBoolean("download.save_order", true));
|
||||||
configSaveOrderCheckbox.setHorizontalAlignment(JCheckBox.RIGHT);
|
configSaveOrderCheckbox.setHorizontalAlignment(JCheckBox.RIGHT);
|
||||||
configSaveOrderCheckbox.setHorizontalTextPosition(JCheckBox.LEFT);
|
configSaveOrderCheckbox.setHorizontalTextPosition(JCheckBox.LEFT);
|
||||||
configShowPopup = new JCheckBox("Notification when rip starts", Utils.getConfigBoolean("download.show_popup", false));
|
configShowPopup = new JCheckBox("Notification when rip starts", Utils.getConfigBoolean("download.show_popup", false));
|
||||||
configShowPopup.setHorizontalAlignment(JCheckBox.RIGHT);
|
configShowPopup.setHorizontalAlignment(JCheckBox.RIGHT);
|
||||||
configShowPopup.setHorizontalTextPosition(JCheckBox.LEFT);
|
configShowPopup.setHorizontalTextPosition(JCheckBox.LEFT);
|
||||||
|
configSaveLogs = new JCheckBox("Save logs", Utils.getConfigBoolean("log.save", false));
|
||||||
|
configSaveLogs.setHorizontalAlignment(JCheckBox.RIGHT);
|
||||||
|
configSaveLogs.setHorizontalTextPosition(JCheckBox.LEFT);
|
||||||
configSaveDirLabel = new JLabel();
|
configSaveDirLabel = new JLabel();
|
||||||
try {
|
try {
|
||||||
String workingDir = (Utils.shortenPath(Utils.getWorkingDirectory()));
|
String workingDir = (Utils.shortenPath(Utils.getWorkingDirectory()));
|
||||||
@ -341,10 +346,11 @@ public class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
gbc.gridy = 4; gbc.gridx = 0; configurationPanel.add(configRetriesLabel, gbc);
|
gbc.gridy = 4; gbc.gridx = 0; configurationPanel.add(configRetriesLabel, gbc);
|
||||||
gbc.gridx = 1; configurationPanel.add(configRetriesText, gbc);
|
gbc.gridx = 1; configurationPanel.add(configRetriesText, gbc);
|
||||||
gbc.gridy = 5; gbc.gridx = 0; configurationPanel.add(configOverwriteCheckbox, gbc);
|
gbc.gridy = 5; gbc.gridx = 0; configurationPanel.add(configOverwriteCheckbox, gbc);
|
||||||
|
gbc.gridx = 1; configurationPanel.add(configSaveOrderCheckbox, gbc);
|
||||||
gbc.gridy = 6; gbc.gridx = 0; configurationPanel.add(configPlaySound, gbc);
|
gbc.gridy = 6; gbc.gridx = 0; configurationPanel.add(configPlaySound, gbc);
|
||||||
gbc.gridy = 7; gbc.gridx = 0; configurationPanel.add(configSaveOrderCheckbox, gbc);
|
gbc.gridx = 1; configurationPanel.add(configSaveLogs, gbc);
|
||||||
gbc.gridy = 8; gbc.gridx = 0; configurationPanel.add(configShowPopup, gbc);
|
gbc.gridy = 7; gbc.gridx = 0; configurationPanel.add(configShowPopup, gbc);
|
||||||
gbc.gridy = 9; gbc.gridx = 0; configurationPanel.add(configSaveDirLabel, gbc);
|
gbc.gridy = 8; gbc.gridx = 0; configurationPanel.add(configSaveDirLabel, gbc);
|
||||||
gbc.gridx = 1; configurationPanel.add(configSaveDirButton, gbc);
|
gbc.gridx = 1; configurationPanel.add(configSaveDirButton, gbc);
|
||||||
|
|
||||||
gbc.gridy = 0; pane.add(ripPanel, gbc);
|
gbc.gridy = 0; pane.add(ripPanel, gbc);
|
||||||
@ -538,6 +544,13 @@ public class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
Utils.setConfigBoolean("download.save_order", configSaveOrderCheckbox.isSelected());
|
Utils.setConfigBoolean("download.save_order", configSaveOrderCheckbox.isSelected());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
configSaveLogs.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
|
Utils.setConfigBoolean("log.save", configSaveLogs.isSelected());
|
||||||
|
Utils.configureLogger();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupTrayIcon() {
|
private void setupTrayIcon() {
|
||||||
@ -728,7 +741,7 @@ public class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
ripper.setup();
|
ripper.setup();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
failed = true;
|
failed = true;
|
||||||
logger.error("Could not find ripper for URL " + url);
|
logger.error("Could not find ripper for URL " + url, e);
|
||||||
error("Could not find ripper for given URL");
|
error("Could not find ripper for given URL");
|
||||||
}
|
}
|
||||||
if (!failed) {
|
if (!failed) {
|
||||||
|
@ -21,7 +21,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 = Logger.getLogger(UpdateUtils.class);
|
||||||
private static final String DEFAULT_VERSION = "1.0.60";
|
private static final String DEFAULT_VERSION = "1.0.61";
|
||||||
private static final String updateJsonURL = "http://rarchives.com/ripme.json";
|
private static final String updateJsonURL = "http://rarchives.com/ripme.json";
|
||||||
private static final String updateJarURL = "http://rarchives.com/ripme.jar";
|
private static final String updateJarURL = "http://rarchives.com/ripme.jar";
|
||||||
private static final String mainFileName = "ripme.jar";
|
private static final String mainFileName = "ripme.jar";
|
||||||
|
@ -2,6 +2,7 @@ package com.rarchives.ripme.utils;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@ -20,7 +21,9 @@ import javax.sound.sampled.LineListener;
|
|||||||
|
|
||||||
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.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
import org.apache.log4j.PropertyConfigurator;
|
||||||
|
|
||||||
import com.rarchives.ripme.ripper.AbstractRipper;
|
import com.rarchives.ripme.ripper.AbstractRipper;
|
||||||
|
|
||||||
@ -308,4 +311,26 @@ public class Utils {
|
|||||||
logger.error("Failed to play sound " + filename, e);
|
logger.error("Failed to play sound " + filename, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures root logger, either for FILE output or just console.
|
||||||
|
*/
|
||||||
|
public static void configureLogger() {
|
||||||
|
LogManager.shutdown();
|
||||||
|
String logFile;
|
||||||
|
if (getConfigBoolean("log.save", false)) {
|
||||||
|
logFile = "log4j.file.properties";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
logFile = "log4j.properties";
|
||||||
|
}
|
||||||
|
InputStream stream = Utils.class.getClassLoader().getResourceAsStream(logFile);
|
||||||
|
if (stream == null) {
|
||||||
|
PropertyConfigurator.configure("src/main/resources/" + logFile);
|
||||||
|
} else {
|
||||||
|
PropertyConfigurator.configure(stream);
|
||||||
|
}
|
||||||
|
logger.info("Loaded " + logFile);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
18
src/main/resources/log4j.file.properties
Normal file
18
src/main/resources/log4j.file.properties
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# define the file appender
|
||||||
|
log4j.appender.FILE = org.apache.log4j.RollingFileAppender
|
||||||
|
log4j.appender.FILE.File = ripme.log
|
||||||
|
log4j.appender.FILE.ImmediateFlush = true
|
||||||
|
log4j.appender.FILE.Threshold = debug
|
||||||
|
log4j.appender.FILE.maxFileSize = 20MB
|
||||||
|
log4j.appender.FILE.layout = org.apache.log4j.PatternLayout
|
||||||
|
log4j.appender.FILE.layout.ConversionPattern = %d %-4r [%t] %-5p %c{2} %x - %m%n
|
||||||
|
|
||||||
|
# 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, FILE
|
@ -1,11 +1,3 @@
|
|||||||
# define the file appender
|
|
||||||
log4j.appender.FILE = org.apache.log4j.RollingFileAppender
|
|
||||||
log4j.appender.FILE.File = ripme.log
|
|
||||||
log4j.appender.FILE.ImmediateFlush = true
|
|
||||||
log4j.appender.FILE.Threshold = debug
|
|
||||||
log4j.appender.FILE.maxFileSize = 20MB
|
|
||||||
log4j.appender.FILE.layout = org.apache.log4j.PatternLayout
|
|
||||||
log4j.appender.FILE.layout.ConversionPattern = %d %-4r [%t] %-5p %c{2} %x - %m%n
|
|
||||||
|
|
||||||
# define the console appender
|
# define the console appender
|
||||||
log4j.appender.stdout = org.apache.log4j.ConsoleAppender
|
log4j.appender.stdout = org.apache.log4j.ConsoleAppender
|
||||||
@ -15,4 +7,4 @@ log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
|
|||||||
log4j.appender.stdout.layout.ConversionPattern = %m%n
|
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
|
# now map our console appender as a root logger, means all log messages will go to this appender
|
||||||
log4j.rootLogger = debug, stdout, FILE
|
log4j.rootLogger = debug, stdout
|
Loading…
Reference in New Issue
Block a user