1.0.26 - Ability to rerip history from command-line
"-r" command-line option Try "-h" for help and other options Closes #23
This commit is contained in:
parent
2875ee8d41
commit
b62c2248a0
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.25</version>
|
<version>1.0.26</version>
|
||||||
<name>ripme</name>
|
<name>ripme</name>
|
||||||
<url>http://rip.rarchives.com</url>
|
<url>http://rip.rarchives.com</url>
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -2,6 +2,8 @@ package com.rarchives.ripme;
|
|||||||
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
@ -30,36 +32,23 @@ public class App {
|
|||||||
logger.info("Initialized ripme v" + UpdateUtils.getThisJarVersion());
|
logger.info("Initialized ripme v" + UpdateUtils.getThisJarVersion());
|
||||||
|
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
CommandLine cl = handleArguments(args);
|
handleArguments(args);
|
||||||
|
|
||||||
try {
|
|
||||||
URL url = new URL(cl.getOptionValue('u'));
|
|
||||||
rip(url);
|
|
||||||
} catch (MalformedURLException e) {
|
|
||||||
logger.error("[!] Given URL is not valid. Expected URL format is http://domain.com/...");
|
|
||||||
System.exit(-1);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
MainWindow mw = new MainWindow();
|
MainWindow mw = new MainWindow();
|
||||||
SwingUtilities.invokeLater(mw);
|
SwingUtilities.invokeLater(mw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void rip(URL url) {
|
public static void rip(URL url) throws Exception {
|
||||||
try {
|
|
||||||
AbstractRipper ripper = AbstractRipper.getRipper(url);
|
AbstractRipper ripper = AbstractRipper.getRipper(url);
|
||||||
ripper.rip();
|
ripper.rip();
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("[!] Error while ripping: " + e.getMessage(), e);
|
|
||||||
System.exit(-1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CommandLine handleArguments(String[] args) {
|
public static void handleArguments(String[] args) {
|
||||||
CommandLine cl = getArgs(args);
|
CommandLine cl = getArgs(args);
|
||||||
if (cl.hasOption('h')) {
|
if (cl.hasOption('h')) {
|
||||||
HelpFormatter hf = new HelpFormatter();
|
HelpFormatter hf = new HelpFormatter();
|
||||||
hf.printHelp("asdf", getOptions());
|
hf.printHelp("java -jar ripme.jar [OPTIONS]", getOptions());
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
if (cl.hasOption('w')) {
|
if (cl.hasOption('w')) {
|
||||||
@ -68,12 +57,51 @@ public class App {
|
|||||||
if (cl.hasOption('t')) {
|
if (cl.hasOption('t')) {
|
||||||
Utils.setConfigInteger("threads.size", Integer.parseInt(cl.getOptionValue('t')));
|
Utils.setConfigInteger("threads.size", Integer.parseInt(cl.getOptionValue('t')));
|
||||||
}
|
}
|
||||||
|
if (cl.hasOption('r')) {
|
||||||
|
// Re-rip all via command-line
|
||||||
|
List<String> history = Utils.getConfigList("download.history");
|
||||||
|
for (String urlString : history) {
|
||||||
|
try {
|
||||||
|
URL url = new URL(urlString.trim());
|
||||||
|
rip(url);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("[!] Failed to rip URL " + urlString, e);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Thread.sleep(500);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
logger.warn("[!] Interrupted while re-ripping history");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Exit
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
if (cl.hasOption('u')) {
|
||||||
|
// User provided URL, rip it.
|
||||||
|
try {
|
||||||
|
URL url = new URL(cl.getOptionValue('u').trim());
|
||||||
|
rip(url);
|
||||||
|
List<String> history = Utils.getConfigList("download.history");
|
||||||
|
if (!history.contains(url.toExternalForm())) {
|
||||||
|
history.add(url.toExternalForm());
|
||||||
|
Utils.setConfigList("download.history", Arrays.asList(history.toArray()));
|
||||||
|
Utils.saveConfig();
|
||||||
|
}
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
logger.error("[!] Given URL is not valid. Expected URL format is http://domain.com/...");
|
||||||
|
System.exit(-1);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("[!] Error while ripping URL " + cl.getOptionValue('u'), e);
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!cl.hasOption('u')) {
|
if (!cl.hasOption('u')) {
|
||||||
System.err.println("\nRequired URL ('-u' or '--url') not provided");
|
System.err.println("\nRequired URL ('-u' or '--url') not provided");
|
||||||
System.err.println("\n\tExample: java -jar ripme.jar -u http://imgur.com/a/abcde");
|
System.err.println("\n\tExample: java -jar ripme.jar -u http://imgur.com/a/abcde");
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
return cl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Options getOptions() {
|
public static Options getOptions() {
|
||||||
@ -82,6 +110,7 @@ public class App {
|
|||||||
opts.addOption("u", "url", true, "URL of album to rip");
|
opts.addOption("u", "url", true, "URL of album to rip");
|
||||||
opts.addOption("t", "threads", true, "Number of download threads per rip");
|
opts.addOption("t", "threads", true, "Number of download threads per rip");
|
||||||
opts.addOption("w", "overwrite", false, "Overwrite existing files");
|
opts.addOption("w", "overwrite", false, "Overwrite existing files");
|
||||||
|
opts.addOption("r", "rerip", false, "Re-rip all ripped albums");
|
||||||
return opts;
|
return opts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ import org.jsoup.nodes.Document;
|
|||||||
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.25";
|
private static final String DEFAULT_VERSION = "1.0.26";
|
||||||
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";
|
||||||
|
Loading…
Reference in New Issue
Block a user