Various style cleanup.
This commit is contained in:
parent
9410ea806c
commit
d8d7b5096a
@ -98,14 +98,13 @@ public class App {
|
||||
}
|
||||
if (cl.hasOption('R')) {
|
||||
loadHistory();
|
||||
|
||||
if (HISTORY.toList().size() == 0) {
|
||||
System.err.println("There are no history entries to re-rip. Rip some albums first");
|
||||
System.exit(-1);
|
||||
}
|
||||
int added = 0;
|
||||
for (HistoryEntry entry : HISTORY.toList()) {
|
||||
if (entry.selected) {
|
||||
if (entry.selected) {
|
||||
added++;
|
||||
try {
|
||||
URL url = new URL(entry.url);
|
||||
@ -123,8 +122,8 @@ public class App {
|
||||
}
|
||||
}
|
||||
if (added == 0) {
|
||||
System.err.println("No history entries have been 'Checked'\n" +
|
||||
"Check an entry by clicking the checkbox to the right of the URL or Right-click a URL to check/uncheck all items");
|
||||
System.err.println("No history entries have been 'Checked'\n" +
|
||||
"Check an entry by clicking the checkbox to the right of the URL or Right-click a URL to check/uncheck all items");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
@ -138,33 +137,25 @@ public class App {
|
||||
System.err.println("\nCannot specify '-d' and '-D' simultaneously");
|
||||
System.exit(-1);
|
||||
}
|
||||
if(cl.hasOption('l')) {
|
||||
if (cl.hasOption('l')) {
|
||||
// change the default rips directory
|
||||
Utils.setConfigString("rips.directory", cl.getOptionValue('l'));
|
||||
}
|
||||
|
||||
if (cl.hasOption('f')) {
|
||||
|
||||
String filename = cl.getOptionValue('f');
|
||||
|
||||
String filename = cl.getOptionValue('f');
|
||||
try {
|
||||
|
||||
String url;
|
||||
|
||||
BufferedReader br = new BufferedReader(new FileReader(filename));
|
||||
BufferedReader br = new BufferedReader(new FileReader(filename));
|
||||
while((url = br.readLine()) != null) {
|
||||
// loop through each url in the file and proces each url individually.
|
||||
ripURL(url.trim(), cl.hasOption("n"));
|
||||
}
|
||||
|
||||
} catch (FileNotFoundException fne) {
|
||||
logger.error("[!] File containing list of URLs not found. Cannot continue.");
|
||||
} catch (IOException ioe) {
|
||||
logger.error("[!] Failed reading file containing list of URLs. Cannot continue.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (cl.hasOption('u')) {
|
||||
String url = cl.getOptionValue('u').trim();
|
||||
ripURL(url, cl.hasOption("n"));
|
||||
@ -195,15 +186,15 @@ public class App {
|
||||
|
||||
public static Options getOptions() {
|
||||
Options opts = new Options();
|
||||
opts.addOption("h", "help", false, "Print the help");
|
||||
opts.addOption("u", "url", true, "URL of album to rip");
|
||||
opts.addOption("t", "threads", true, "Number of download threads per rip");
|
||||
opts.addOption("h", "help", false, "Print the help");
|
||||
opts.addOption("u", "url", true, "URL of album to rip");
|
||||
opts.addOption("t", "threads", true, "Number of download threads per rip");
|
||||
opts.addOption("w", "overwrite", false, "Overwrite existing files");
|
||||
opts.addOption("r", "rerip", false, "Re-rip all ripped albums");
|
||||
opts.addOption("R", "rerip-selected", false, "Re-rip all selected albums");
|
||||
opts.addOption("d", "saveorder", false, "Save the order of images in album");
|
||||
opts.addOption("r", "rerip", false, "Re-rip all ripped albums");
|
||||
opts.addOption("R", "rerip-selected", false, "Re-rip all selected albums");
|
||||
opts.addOption("d", "saveorder", false, "Save the order of images in album");
|
||||
opts.addOption("D", "nosaveorder", false, "Don't save order of images");
|
||||
opts.addOption("4", "skip404", false, "Don't retry after a 404 (not found) error");
|
||||
opts.addOption("4", "skip404", false, "Don't retry after a 404 (not found) error");
|
||||
opts.addOption("l", "ripsdirectory", true, "Rips Directory (Default: ./rips)");
|
||||
opts.addOption("n", "no-prop-file", false, "Do not create properties file.");
|
||||
opts.addOption("f", "urls-file", true, "Rip URLs from a file.");
|
||||
@ -233,7 +224,7 @@ public class App {
|
||||
logger.error("Failed to load history from file " + historyFile, e);
|
||||
System.out.println(
|
||||
"RipMe failed to load the history file at " + historyFile.getAbsolutePath() + "\n\n" +
|
||||
"Error: " + e.getMessage() + "\n\n" +
|
||||
"Error: " + e.getMessage() + "\n\n" +
|
||||
"Closing RipMe will automatically overwrite the contents of this file,\n" +
|
||||
"so you may want to back the file up before closing RipMe!");
|
||||
}
|
||||
|
@ -22,13 +22,13 @@ import com.rarchives.ripme.ui.RipStatusMessage.STATUS;
|
||||
import com.rarchives.ripme.utils.Utils;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public abstract class AbstractRipper
|
||||
public abstract class AbstractRipper
|
||||
extends Observable
|
||||
implements RipperInterface, Runnable {
|
||||
|
||||
protected static final Logger logger = Logger.getLogger(AbstractRipper.class);
|
||||
|
||||
public static final String USER_AGENT =
|
||||
public static final String USER_AGENT =
|
||||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:36.0) Gecko/20100101 Firefox/36.0";
|
||||
|
||||
protected URL url;
|
||||
@ -60,7 +60,7 @@ public abstract class AbstractRipper
|
||||
/**
|
||||
* Ensures inheriting ripper can rip this URL, raises exception if not.
|
||||
* Otherwise initializes working directory and thread pool.
|
||||
*
|
||||
*
|
||||
* @param url
|
||||
* URL to rip.
|
||||
* @throws IOException
|
||||
@ -149,8 +149,7 @@ public abstract class AbstractRipper
|
||||
}
|
||||
return addURLToDownload(url, saveFileAs, referrer, cookies);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Queues file to be downloaded and saved. With options.
|
||||
* @param url
|
||||
@ -267,10 +266,10 @@ public abstract class AbstractRipper
|
||||
public URL getURL() {
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return
|
||||
* Path to the directory in which all files
|
||||
* Path to the directory in which all files
|
||||
* ripped via this ripper will be stored.
|
||||
*/
|
||||
public File getWorkingDir() {
|
||||
@ -278,7 +277,7 @@ public abstract class AbstractRipper
|
||||
}
|
||||
|
||||
public abstract void setWorkingDir(URL url) throws IOException;
|
||||
|
||||
|
||||
public String getAlbumTitle(URL url) throws MalformedURLException {
|
||||
return getHost() + "_" + getGID(url);
|
||||
}
|
||||
@ -354,9 +353,9 @@ public abstract class AbstractRipper
|
||||
}
|
||||
observer.update(this, new RipStatusMessage(status, message));
|
||||
}
|
||||
|
||||
|
||||
public abstract int getCompletionPercentage();
|
||||
|
||||
|
||||
public abstract String getStatusText();
|
||||
|
||||
/**
|
||||
@ -381,7 +380,7 @@ public abstract class AbstractRipper
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void cleanup() {
|
||||
if (this.workingDir.list().length == 0) {
|
||||
// No files, delete the dir
|
||||
@ -392,7 +391,7 @@ public abstract class AbstractRipper
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean sleep(int milliseconds) {
|
||||
try {
|
||||
logger.debug("Sleeping " + milliseconds + "ms");
|
||||
@ -419,4 +418,4 @@ public abstract class AbstractRipper
|
||||
public boolean isThisATest() {
|
||||
return thisIsATest;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ import com.rarchives.ripme.ripper.rippers.ripperhelpers.ChanSite;
|
||||
import com.rarchives.ripme.utils.Http;
|
||||
import com.rarchives.ripme.utils.RipUtils;
|
||||
|
||||
|
||||
public class ChanRipper extends AbstractHTMLRipper {
|
||||
public static List<ChanSite> explicit_domains = Arrays.asList(
|
||||
new ChanSite(Arrays.asList("boards.4chan.org"), Arrays.asList("4cdn.org", "is.4chan.org", "is2.4chan.org")),
|
||||
@ -93,7 +92,7 @@ public class ChanRipper extends AbstractHTMLRipper {
|
||||
* FoolFuuka uses the same (url) layout as 4chan
|
||||
*
|
||||
* @param url
|
||||
* @return
|
||||
* @return
|
||||
* The thread id in string form
|
||||
* @throws java.net.MalformedURLException */
|
||||
@Override
|
||||
@ -194,12 +193,11 @@ public class ChanRipper extends AbstractHTMLRipper {
|
||||
continue;
|
||||
}
|
||||
|
||||
List<URL> urls = RipUtils.getFilesFromURL(originalURL);
|
||||
//for (int i = 0; i < urls.size(); i++) {
|
||||
List<URL> urls = RipUtils.getFilesFromURL(originalURL);
|
||||
for(URL imageurl : urls){
|
||||
imageURLs.add(imageurl.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isStopped()) {
|
||||
break;
|
||||
|
@ -16,7 +16,6 @@ import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class History {
|
||||
|
||||
private final List<HistoryEntry> list;
|
||||
private static final String[] COLUMNS = new String[] {
|
||||
"URL",
|
||||
@ -98,7 +97,7 @@ public class History {
|
||||
list.add(new HistoryEntry().fromJSON(json));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void fromFile(String filename) throws IOException {
|
||||
InputStream is = new FileInputStream(filename);
|
||||
try {
|
||||
@ -111,7 +110,7 @@ public class History {
|
||||
is.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void fromList(List<String> stringList) {
|
||||
for (String item : stringList) {
|
||||
HistoryEntry entry = new HistoryEntry();
|
||||
@ -127,15 +126,15 @@ public class History {
|
||||
}
|
||||
return jsonArray;
|
||||
}
|
||||
|
||||
public List<HistoryEntry> toList() {
|
||||
|
||||
public List<HistoryEntry> toList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
public boolean isEmpty(){
|
||||
return list.isEmpty();
|
||||
|
||||
public boolean isEmpty() {
|
||||
return list.isEmpty();
|
||||
}
|
||||
|
||||
|
||||
public void toFile(String filename) throws IOException {
|
||||
OutputStream os = new FileOutputStream(filename);
|
||||
try {
|
||||
@ -144,5 +143,4 @@ public class History {
|
||||
os.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
|
||||
import com.rarchives.ripme.utils.Utils;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class UpdateUtils {
|
||||
|
||||
@ -124,7 +123,7 @@ public class UpdateUtils {
|
||||
else if (newVersions[i] < oldVersions[i]) {
|
||||
logger.debug("oldVersion " + getThisJarVersion() + " > latestVersion " + latestVersion);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// At this point, the version numbers are exactly the same.
|
||||
@ -200,7 +199,7 @@ public class UpdateUtils {
|
||||
logger.info("Executing: " + batchFile);
|
||||
Runtime.getRuntime().exec(batchExec);
|
||||
} catch (IOException e) {
|
||||
//TODO implement proper stack trace handling this is really just intented as a placeholder until you implement proper error handling
|
||||
//TODO implement proper stack trace handling this is really just intented as a placeholder until you implement proper error handling
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user