Prettier console output
This commit is contained in:
parent
ae2a85fa38
commit
569b7fbdc4
@ -29,7 +29,7 @@ public class App {
|
||||
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/...");
|
||||
logger.error("[!] Given URL is not valid. Expected URL format is http://domain.com/...");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
@ -39,11 +39,11 @@ public class App {
|
||||
AbstractRipper ripper = AbstractRipper.getRipper(url);
|
||||
ripper.rip();
|
||||
} catch (Exception e) {
|
||||
logger.error("Caught exception:", e);
|
||||
logger.error("[!] Caught exception: " + e.getMessage(), e);
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static CommandLine handleArguments(String[] args) {
|
||||
CommandLine cl = getArgs(args);
|
||||
if (cl.hasOption('h')) {
|
||||
@ -77,7 +77,7 @@ public class App {
|
||||
CommandLine cl = parser.parse(getOptions(), args, false);
|
||||
return cl;
|
||||
} catch (ParseException e) {
|
||||
logger.error("Error while parsing command-line arguments: " + args, e);
|
||||
logger.error("[!] Error while parsing command-line arguments: " + args, e);
|
||||
System.exit(-1);
|
||||
return null;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public abstract class AbstractRipper implements RipperInterface {
|
||||
try {
|
||||
saveFileAs = new File(workingDir.getCanonicalPath() + File.separator + prefix + saveAs);
|
||||
} catch (IOException e) {
|
||||
logger.error("Error creating save file path for URL '" + url + "':", e);
|
||||
logger.error("[!] Error creating save file path for URL '" + url + "':", e);
|
||||
return;
|
||||
}
|
||||
logger.debug("Downloading " + url + " to " + saveFileAs);
|
||||
@ -84,7 +84,7 @@ public abstract class AbstractRipper implements RipperInterface {
|
||||
path += getHost() + "_" + getGID(this.url) + File.separator;
|
||||
this.workingDir = new File(path);
|
||||
if (!this.workingDir.exists()) {
|
||||
logger.info("Creating working directory(s): " + this.workingDir);
|
||||
logger.info("[+] Creating working directory: " + this.workingDir);
|
||||
this.workingDir.mkdirs();
|
||||
}
|
||||
logger.debug("Set working directory to: " + this.workingDir);
|
||||
|
@ -28,15 +28,15 @@ public class DownloadFileThread extends Thread {
|
||||
// Check if file already exists
|
||||
if (saveAs.exists()) {
|
||||
if (Utils.getConfigBoolean("file.overwrite", false)) {
|
||||
logger.info("File already exists and 'file.overwrite' is true, deleting: " + saveAs);
|
||||
logger.info("[!] File already exists and 'file.overwrite' is true, deleting: " + saveAs);
|
||||
saveAs.delete();
|
||||
} else {
|
||||
logger.info("Not downloading " + url + " because file already exists: " + saveAs);
|
||||
logger.info("[!] Not downloading " + url + " because file already exists: " + saveAs);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
logger.info("Downloading file from: " + url);
|
||||
logger.info("[ ] Downloading file from: " + url);
|
||||
try {
|
||||
Response response;
|
||||
response = Jsoup.connect(url.toExternalForm())
|
||||
@ -46,10 +46,10 @@ public class DownloadFileThread extends Thread {
|
||||
out.write(response.bodyAsBytes());
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
logger.error("Exception while downloading file: " + url, e);
|
||||
logger.error("[!] Exception while downloading file: " + url, e);
|
||||
return;
|
||||
}
|
||||
logger.info("Download completed: " + url);
|
||||
logger.info("[+] Download completed: " + url);
|
||||
}
|
||||
|
||||
}
|
@ -33,7 +33,6 @@ public class ImagefapRipper extends AbstractRipper {
|
||||
*/
|
||||
public URL sanitizeURL(URL url) throws MalformedURLException {
|
||||
String gid = getGID(url);
|
||||
logger.debug("GID=" + gid);
|
||||
URL newURL = new URL("http://www.imagefap.com/gallery.php?gid="
|
||||
+ gid + "&view=2");
|
||||
logger.debug("Sanitized URL from " + url + " to " + newURL);
|
||||
@ -60,7 +59,8 @@ public class ImagefapRipper extends AbstractRipper {
|
||||
|
||||
@Override
|
||||
public void rip() throws IOException {
|
||||
logger.debug("Retrieving " + this.url.toExternalForm());
|
||||
int index = 0;
|
||||
logger.info("[ ] Retrieving " + this.url.toExternalForm());
|
||||
Document doc = Jsoup.connect(this.url.toExternalForm()).get();
|
||||
for (Element thumb : doc.select("#gallery img")) {
|
||||
if (!thumb.hasAttr("src") || !thumb.hasAttr("width")) {
|
||||
@ -70,12 +70,16 @@ public class ImagefapRipper extends AbstractRipper {
|
||||
image = image.replaceAll(
|
||||
"http://x.*.fap.to/images/thumb/",
|
||||
"http://fap.to/images/full/");
|
||||
processURL(new URL(image));
|
||||
index += 1;
|
||||
processURL(new URL(image), String.format("%03d_", index));
|
||||
}
|
||||
logger.info("[ ] Waiting for threads to finish...");
|
||||
threadPool.waitForThreads();
|
||||
}
|
||||
|
||||
public void processURL(URL url) {
|
||||
logger.info("Found " + url);
|
||||
public void processURL(URL url, String prefix) {
|
||||
logger.debug("Found URL: " + url);
|
||||
addURLToDownload(url, prefix);
|
||||
}
|
||||
|
||||
public boolean canRip(URL url) {
|
||||
|
@ -75,12 +75,13 @@ public class ImgurRipper extends AbstractRipper {
|
||||
// TODO Get all albums by user
|
||||
break;
|
||||
}
|
||||
logger.info("[ ] Waiting for threads to finish...");
|
||||
threadPool.waitForThreads();
|
||||
}
|
||||
|
||||
private void ripAlbum(URL url) throws IOException {
|
||||
int index = 0;
|
||||
logger.info("Retrieving " + url.toExternalForm());
|
||||
logger.info("[ ] Retrieving " + url.toExternalForm());
|
||||
Document doc = Jsoup.connect(url.toExternalForm()).get();
|
||||
for (Element thumb : doc.select("div.image")) {
|
||||
String image;
|
||||
@ -91,7 +92,7 @@ public class ImgurRipper extends AbstractRipper {
|
||||
image = "http:" + thumb.select("img").attr("src");
|
||||
} else {
|
||||
// Unable to find image in this div
|
||||
logger.error("Unable to find image in div: " + thumb.toString());
|
||||
logger.error("[!] Unable to find image in div: " + thumb.toString());
|
||||
continue;
|
||||
}
|
||||
index += 1;
|
||||
|
@ -19,7 +19,7 @@ public class Utils {
|
||||
try {
|
||||
config = new PropertiesConfiguration(configFile);
|
||||
} catch (ConfigurationException e) {
|
||||
logger.error("Failed to load properties file from " + configFile, e);
|
||||
logger.error("[!] Failed to load properties file from " + configFile, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user