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

@ -30,7 +30,7 @@ public abstract class AbstractHTMLRipper extends AlbumRipper {
} }
public abstract List<String> getURLsFromPage(Document page); public abstract List<String> getURLsFromPage(Document page);
public List<String> getDescriptionsFromPage(Document doc) throws IOException { 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 abstract void downloadURL(URL url, int index);
public DownloadThreadPool getThreadPool() { public DownloadThreadPool getThreadPool() {
@ -51,10 +51,10 @@ public abstract class AbstractHTMLRipper extends AlbumRipper {
return url; return url;
} }
public boolean hasDescriptionSupport() { public boolean hasDescriptionSupport() {
return false; return false;
} }
public String[] getDescription(String url,Document page) throws IOException { 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() { public int descSleepTime() {
return 100; return 100;
@ -90,15 +90,15 @@ public abstract class AbstractHTMLRipper extends AlbumRipper {
} }
if (hasDescriptionSupport() && Utils.getConfigBoolean("descriptions.save", false)) { if (hasDescriptionSupport() && Utils.getConfigBoolean("descriptions.save", false)) {
logger.debug("Fetching description(s) from " + doc.location()); logger.debug("Fetching description(s) from " + doc.location());
List<String> textURLs = getDescriptionsFromPage(doc); List<String> textURLs = getDescriptionsFromPage(doc);
if (textURLs.size() > 0) { if (textURLs.size() > 0) {
logger.debug("Found description link(s) from " + doc.location()); logger.debug("Found description link(s) from " + doc.location());
for (String textURL : textURLs) { for (String textURL : textURLs) {
if (isStopped()) { if (isStopped()) {
break; break;
} }
textindex += 1; textindex += 1;
logger.debug("Getting description from " + textURL); logger.debug("Getting description from " + textURL);
String[] tempDesc = getDescription(textURL,doc); String[] tempDesc = getDescription(textURL,doc);
if (tempDesc != null) { if (tempDesc != null) {
if (Utils.getConfigBoolean("file.overwrite", false) || !(new File( if (Utils.getConfigBoolean("file.overwrite", false) || !(new File(
@ -116,8 +116,8 @@ public abstract class AbstractHTMLRipper extends AlbumRipper {
} }
} }
} }
} }
} }
if (isStopped() || isThisATest()) { if (isStopped() || isThisATest()) {
@ -142,7 +142,7 @@ public abstract class AbstractHTMLRipper extends AlbumRipper {
} }
public String fileNameFromURL(URL url) { public String fileNameFromURL(URL url) {
String saveAs = url.toExternalForm(); 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); 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('?')); }
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 @Override
public boolean hasDescriptionSupport() { public boolean hasDescriptionSupport() {
return true; return true;
} }
@Override @Override
public URL sanitizeURL(URL url) throws MalformedURLException { public URL sanitizeURL(URL url) throws MalformedURLException {
@ -132,7 +132,8 @@ public class DeviantartRipper extends AbstractHTMLRipper {
continue; continue;
} }
script = script.substring(script.indexOf(id)); 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("\\/", "/"); return script.replace("\\/", "/");
} catch (StringIndexOutOfBoundsException e) { } catch (StringIndexOutOfBoundsException e) {
logger.debug("Unable to get json link from " + page.location()); 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 // Get full-sized image via helper methods
String fullSize = null; String fullSize = null;
if (thumb.attr("data-super-full-img").contains("//orig")) { if (thumb.attr("data-super-full-img").contains("//orig")) {
fullSize = thumb.attr("data-super-full-img"); fullSize = thumb.attr("data-super-full-img");
} else { } else {
String spanUrl = thumb.attr("href"); String spanUrl = thumb.attr("href");
String fullSize1 = jsonToImage(page,spanUrl.substring(spanUrl.lastIndexOf('-') + 1)); String fullSize1 = jsonToImage(page,spanUrl.substring(spanUrl.lastIndexOf('-') + 1));
if (fullSize1 == null || !fullSize1.contains("//orig")) { if (fullSize1 == null || !fullSize1.contains("//orig")) {
fullSize = smallToFull(img.attr("src"), spanUrl); fullSize = smallToFull(img.attr("src"), spanUrl);
} }
if (fullSize == null && fullSize1 != null) { if (fullSize == null && fullSize1 != null) {
fullSize = fullSize1; fullSize = fullSize1;
} }
} }
if (fullSize == null) { if (fullSize == null) {
if (thumb.attr("data-super-full-img") != null) { if (thumb.attr("data-super-full-img") != null) {
fullSize = thumb.attr("data-super-full-img"); fullSize = thumb.attr("data-super-full-img");
} else if (thumb.attr("data-super-img") != null) { } else if (thumb.attr("data-super-img") != null) {
fullSize = thumb.attr("data-super-img"); fullSize = thumb.attr("data-super-img");
} else { } else {
continue; continue;
} }