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