1.0.59 - Detect when an album can be ripped instantly #60

This commit is contained in:
4pr0n 2014-06-07 19:54:36 -07:00
parent fe24620e47
commit add3c043b2
4 changed files with 50 additions and 9 deletions

View File

@ -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.58</version> <version>1.0.59</version>
<name>ripme</name> <name>ripme</name>
<url>http://rip.rarchives.com</url> <url>http://rip.rarchives.com</url>
<properties> <properties>

View File

@ -303,13 +303,17 @@ public abstract class AbstractRipper
waitForThreads(); waitForThreads();
sendUpdate(STATUS.RIP_ERRORED, e.getMessage()); sendUpdate(STATUS.RIP_ERRORED, e.getMessage());
} finally { } finally {
if (this.workingDir.list().length == 0) { cleanup();
// No files, delete the dir }
logger.info("Deleting empty directory " + this.workingDir); }
boolean deleteResult = this.workingDir.delete();
if (!deleteResult) { public void cleanup() {
logger.error("Unable to delete empty directory " + this.workingDir); if (this.workingDir.list().length == 0) {
} // No files, delete the dir
logger.info("Deleting empty directory " + this.workingDir);
boolean deleteResult = this.workingDir.delete();
if (!deleteResult) {
logger.error("Unable to delete empty directory " + this.workingDir);
} }
} }
} }

View File

@ -49,6 +49,8 @@ import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.UIManager; import javax.swing.UIManager;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.BadLocationException; import javax.swing.text.BadLocationException;
import javax.swing.text.SimpleAttributeSet; import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants; import javax.swing.text.StyleConstants;
@ -357,6 +359,41 @@ public class MainWindow implements Runnable, RipStatusHandler {
private void setupHandlers() { private void setupHandlers() {
ripButton.addActionListener(new RipButtonHandler()); ripButton.addActionListener(new RipButtonHandler());
ripTextfield.addActionListener(new RipButtonHandler()); ripTextfield.addActionListener(new RipButtonHandler());
ripTextfield.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void removeUpdate(DocumentEvent e) {
update();
}
@Override
public void insertUpdate(DocumentEvent e) {
update();
}
@Override
public void changedUpdate(DocumentEvent e) {
update();
}
private void update() {
if (!ripTextfield.isEnabled()) {
return;
}
try {
String urlText = ripTextfield.getText();
if (!urlText.startsWith("http:")) {
urlText = "http://" + urlText;
}
URL url = new URL(urlText);
AbstractRipper ripper = AbstractRipper.getRipper(url);
statusWithColor(ripper.getHost() + " album detected", Color.GREEN);
File dir = ripper.getWorkingDir();
if (dir.list().length == 1) {
new File(dir.getAbsolutePath() + File.separator + "log.txt").delete();
}
ripper.cleanup();
} catch (Exception e) {
statusWithColor("Can't rip this URL", Color.RED);
}
}
});
stopButton.addActionListener(new ActionListener() { stopButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {

View File

@ -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.58"; private static final String DEFAULT_VERSION = "1.0.59";
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";