Fix indentation.
This commit is contained in:
parent
3d359be958
commit
2055cb0d9d
@ -16,7 +16,7 @@ import com.rarchives.ripme.utils.Utils;
|
|||||||
* Simplified ripper, designed for ripping from sites by parsing HTML.
|
* Simplified ripper, designed for ripping from sites by parsing HTML.
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractHTMLRipper extends AlbumRipper {
|
public abstract class AbstractHTMLRipper extends AlbumRipper {
|
||||||
|
|
||||||
public AbstractHTMLRipper(URL url) throws IOException {
|
public AbstractHTMLRipper(URL url) throws IOException {
|
||||||
super(url);
|
super(url);
|
||||||
}
|
}
|
||||||
@ -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() {
|
||||||
@ -45,16 +45,16 @@ public abstract class AbstractHTMLRipper extends AlbumRipper {
|
|||||||
public boolean canRip(URL url) {
|
public boolean canRip(URL url) {
|
||||||
return url.getHost().endsWith(getDomain());
|
return url.getHost().endsWith(getDomain());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URL sanitizeURL(URL url) throws MalformedURLException {
|
public URL sanitizeURL(URL url) throws MalformedURLException {
|
||||||
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;
|
||||||
@ -66,7 +66,7 @@ public abstract class AbstractHTMLRipper extends AlbumRipper {
|
|||||||
logger.info("Retrieving " + this.url);
|
logger.info("Retrieving " + this.url);
|
||||||
sendUpdate(STATUS.LOADING_RESOURCE, this.url.toExternalForm());
|
sendUpdate(STATUS.LOADING_RESOURCE, this.url.toExternalForm());
|
||||||
Document doc = getFirstPage();
|
Document doc = getFirstPage();
|
||||||
|
|
||||||
while (doc != null) {
|
while (doc != null) {
|
||||||
List<String> imageURLs = getURLsFromPage(doc);
|
List<String> imageURLs = getURLsFromPage(doc);
|
||||||
// Remove all but 1 image
|
// Remove all but 1 image
|
||||||
@ -79,7 +79,7 @@ public abstract class AbstractHTMLRipper extends AlbumRipper {
|
|||||||
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);
|
||||||
@ -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('#')); }
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
@ -273,7 +274,7 @@ public class DeviantartRipper extends AbstractHTMLRipper {
|
|||||||
}
|
}
|
||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to download description for image.
|
* Attempts to download description for image.
|
||||||
* Comes in handy when people put entire stories in their description.
|
* Comes in handy when people put entire stories in their description.
|
||||||
@ -329,7 +330,7 @@ public class DeviantartRipper extends AbstractHTMLRipper {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If largest resolution for image at 'thumb' is found, starts downloading
|
* If largest resolution for image at 'thumb' is found, starts downloading
|
||||||
* and returns null.
|
* and returns null.
|
||||||
|
Loading…
Reference in New Issue
Block a user