Fix indentation.

This commit is contained in:
MetaPrime 2017-05-15 10:24:36 -07:00
parent 3d359be958
commit 2055cb0d9d
2 changed files with 35 additions and 34 deletions

View File

@ -16,7 +16,7 @@ import com.rarchives.ripme.utils.Utils;
* Simplified ripper, designed for ripping from sites by parsing HTML.
*/
public abstract class AbstractHTMLRipper extends AlbumRipper {
public AbstractHTMLRipper(URL url) throws IOException {
super(url);
}
@ -30,7 +30,7 @@ public abstract class AbstractHTMLRipper extends AlbumRipper {
}
public abstract List<String> getURLsFromPage(Document page);
public List<String> getDescriptionsFromPage(Document doc) throws IOException {
throw new IOException("getDescriptionsFromPage not implemented"); // Do I do this or make an abstract function?
throw new IOException("getDescriptionsFromPage not implemented"); // Do I do this or make an abstract function?
}
public abstract void downloadURL(URL url, int index);
public DownloadThreadPool getThreadPool() {
@ -45,16 +45,16 @@ public abstract class AbstractHTMLRipper extends AlbumRipper {
public boolean canRip(URL url) {
return url.getHost().endsWith(getDomain());
}
@Override
public URL sanitizeURL(URL url) throws MalformedURLException {
return url;
}
public boolean hasDescriptionSupport() {
return false;
return false;
}
public String[] getDescription(String url,Document page) throws IOException {
throw new IOException("getDescription not implemented"); // Do I do this or make an abstract function?
throw new IOException("getDescription not implemented"); // Do I do this or make an abstract function?
}
public int descSleepTime() {
return 100;
@ -66,7 +66,7 @@ public abstract class AbstractHTMLRipper extends AlbumRipper {
logger.info("Retrieving " + this.url);
sendUpdate(STATUS.LOADING_RESOURCE, this.url.toExternalForm());
Document doc = getFirstPage();
while (doc != null) {
List<String> imageURLs = getURLsFromPage(doc);
// Remove all but 1 image
@ -79,7 +79,7 @@ public abstract class AbstractHTMLRipper extends AlbumRipper {
if (imageURLs.size() == 0) {
throw new IOException("No images found at " + doc.location());
}
for (String imageURL : imageURLs) {
index += 1;
logger.debug("Found image url #" + index + ": " + imageURL);
@ -90,15 +90,15 @@ public abstract class AbstractHTMLRipper extends AlbumRipper {
}
if (hasDescriptionSupport() && Utils.getConfigBoolean("descriptions.save", false)) {
logger.debug("Fetching description(s) from " + doc.location());
List<String> textURLs = getDescriptionsFromPage(doc);
if (textURLs.size() > 0) {
List<String> textURLs = getDescriptionsFromPage(doc);
if (textURLs.size() > 0) {
logger.debug("Found description link(s) from " + doc.location());
for (String textURL : textURLs) {
if (isStopped()) {
break;
}
textindex += 1;
logger.debug("Getting description from " + textURL);
for (String textURL : textURLs) {
if (isStopped()) {
break;
}
textindex += 1;
logger.debug("Getting description from " + textURL);
String[] tempDesc = getDescription(textURL,doc);
if (tempDesc != null) {
if (Utils.getConfigBoolean("file.overwrite", false) || !(new File(
@ -116,8 +116,8 @@ public abstract class AbstractHTMLRipper extends AlbumRipper {
}
}
}
}
}
}
}
if (isStopped() || isThisATest()) {
@ -142,7 +142,7 @@ public abstract class AbstractHTMLRipper extends AlbumRipper {
}
public String fileNameFromURL(URL url) {
String saveAs = url.toExternalForm();
if (saveAs.substring(saveAs.length() - 1) == "/") { saveAs = saveAs.substring(0,saveAs.length() - 1) ;}
if (saveAs.substring(saveAs.length() - 1) == "/") { saveAs = saveAs.substring(0,saveAs.length() - 1) ;}
saveAs = saveAs.substring(saveAs.lastIndexOf('/')+1);
if (saveAs.indexOf('?') >= 0) { saveAs = saveAs.substring(0, saveAs.indexOf('?')); }
if (saveAs.indexOf('#') >= 0) { saveAs = saveAs.substring(0, saveAs.indexOf('#')); }

View File

@ -49,7 +49,7 @@ public class DeviantartRipper extends AbstractHTMLRipper {
}
@Override
public boolean hasDescriptionSupport() {
return true;
return true;
}
@Override
public URL sanitizeURL(URL url) throws MalformedURLException {
@ -132,7 +132,8 @@ public class DeviantartRipper extends AbstractHTMLRipper {
continue;
}
script = script.substring(script.indexOf(id));
script = script.substring(script.indexOf("},\"src\":\"") + 9, script.indexOf("\",\"type\"")); // first },"src":"url" after id
// first },"src":"url" after id
script = script.substring(script.indexOf("},\"src\":\"") + 9, script.indexOf("\",\"type\""));
return script.replace("\\/", "/");
} catch (StringIndexOutOfBoundsException e) {
logger.debug("Unable to get json link from " + page.location());
@ -156,23 +157,23 @@ public class DeviantartRipper extends AbstractHTMLRipper {
}
// Get full-sized image via helper methods
String fullSize = null;
if (thumb.attr("data-super-full-img").contains("//orig")) {
fullSize = thumb.attr("data-super-full-img");
} else {
String spanUrl = thumb.attr("href");
String fullSize1 = jsonToImage(page,spanUrl.substring(spanUrl.lastIndexOf('-') + 1));
if (fullSize1 == null || !fullSize1.contains("//orig")) {
if (thumb.attr("data-super-full-img").contains("//orig")) {
fullSize = thumb.attr("data-super-full-img");
} else {
String spanUrl = thumb.attr("href");
String fullSize1 = jsonToImage(page,spanUrl.substring(spanUrl.lastIndexOf('-') + 1));
if (fullSize1 == null || !fullSize1.contains("//orig")) {
fullSize = smallToFull(img.attr("src"), spanUrl);
}
if (fullSize == null && fullSize1 != null) {
}
if (fullSize == null && fullSize1 != null) {
fullSize = fullSize1;
}
}
}
if (fullSize == null) {
if (thumb.attr("data-super-full-img") != null) {
fullSize = thumb.attr("data-super-full-img");
if (thumb.attr("data-super-full-img") != null) {
fullSize = thumb.attr("data-super-full-img");
} else if (thumb.attr("data-super-img") != null) {
fullSize = thumb.attr("data-super-img");
fullSize = thumb.attr("data-super-img");
} else {
continue;
}
@ -273,7 +274,7 @@ public class DeviantartRipper extends AbstractHTMLRipper {
}
return result.toString();
}
/**
* Attempts to download description for image.
* Comes in handy when people put entire stories in their description.
@ -329,7 +330,7 @@ public class DeviantartRipper extends AbstractHTMLRipper {
return null;
}
}
/**
* If largest resolution for image at 'thumb' is found, starts downloading
* and returns null.