Merge pull request #313 from cyian-1756/api-changes

Added hasASAPRipping(), which if returns true allows a ripper to not return anything from getURLsFromPage()
This commit is contained in:
cyian-1756 2018-02-07 11:07:09 -05:00 committed by GitHub
commit 80e746adbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 14 deletions

View File

@ -69,23 +69,25 @@ public abstract class AbstractHTMLRipper extends AlbumRipper {
while (doc != null) { while (doc != null) {
List<String> imageURLs = getURLsFromPage(doc); List<String> imageURLs = getURLsFromPage(doc);
// Remove all but 1 image if (!hasASAPRipping()) {
if (isThisATest()) { // Remove all but 1 image
while (imageURLs.size() > 1) { if (isThisATest()) {
imageURLs.remove(1); while (imageURLs.size() > 1) {
imageURLs.remove(1);
}
} }
}
if (imageURLs.size() == 0) { if (imageURLs.size() == 0) {
throw new IOException("No images found at " + doc.location()); throw new IOException("No images found at " + doc.location());
} }
for (String imageURL : imageURLs) { for (String imageURL : imageURLs) {
index += 1; index += 1;
logger.debug("Found image url #" + index + ": " + imageURL); logger.debug("Found image url #" + index + ": " + imageURL);
downloadURL(new URL(imageURL), index); downloadURL(new URL(imageURL), index);
if (isStopped()) { if (isStopped()) {
break; break;
}
} }
} }
if (hasDescriptionSupport() && Utils.getConfigBoolean("descriptions.save", false)) { if (hasDescriptionSupport() && Utils.getConfigBoolean("descriptions.save", false)) {

View File

@ -43,6 +43,7 @@ public abstract class AbstractRipper
public abstract void rip() throws IOException; public abstract void rip() throws IOException;
public abstract String getHost(); public abstract String getHost();
public abstract String getGID(URL url) throws MalformedURLException; public abstract String getGID(URL url) throws MalformedURLException;
public boolean hasASAPRipping() { return false; }
private boolean shouldStop = false; private boolean shouldStop = false;
private boolean thisIsATest = false; private boolean thisIsATest = false;