Fix for multi-page deviantart albums #42
This commit is contained in:
parent
29b1afea06
commit
0722667b4e
@ -19,6 +19,7 @@ import org.jsoup.nodes.Document;
|
|||||||
import org.jsoup.nodes.Element;
|
import org.jsoup.nodes.Element;
|
||||||
|
|
||||||
import com.rarchives.ripme.ripper.AlbumRipper;
|
import com.rarchives.ripme.ripper.AlbumRipper;
|
||||||
|
import com.rarchives.ripme.ui.RipStatusMessage.STATUS;
|
||||||
import com.rarchives.ripme.utils.Utils;
|
import com.rarchives.ripme.utils.Utils;
|
||||||
|
|
||||||
public class DeviantartRipper extends AlbumRipper {
|
public class DeviantartRipper extends AlbumRipper {
|
||||||
@ -49,35 +50,46 @@ public class DeviantartRipper extends AlbumRipper {
|
|||||||
public void rip() throws IOException {
|
public void rip() throws IOException {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
String nextURL = this.url.toExternalForm();
|
String nextURL = this.url.toExternalForm();
|
||||||
|
|
||||||
while (nextURL != null) {
|
while (nextURL != null) {
|
||||||
|
|
||||||
logger.info(" Retrieving " + nextURL);
|
logger.info(" Retrieving " + nextURL);
|
||||||
|
sendUpdate(STATUS.LOADING_RESOURCE, "Retrieving " + nextURL);
|
||||||
Document doc = Jsoup.connect(nextURL)
|
Document doc = Jsoup.connect(nextURL)
|
||||||
.userAgent(USER_AGENT)
|
.userAgent(USER_AGENT)
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
|
for (Element thumb : doc.select("div.zones-container a.thumb img")) {
|
||||||
|
if (thumb.attr("transparent").equals("false")) {
|
||||||
|
continue; // a.thumbs to other albums are invisible
|
||||||
|
}
|
||||||
|
|
||||||
|
String fullSizePage = thumbToFull(thumb.attr("src"));
|
||||||
|
try {
|
||||||
|
URL fullsizePageURL = new URL(fullSizePage);
|
||||||
|
index++;
|
||||||
|
addURLToDownload(fullsizePageURL, String.format("%03d_", index));
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
logger.error("[!] Invalid thumbnail image: " + thumbToFull(fullSizePage));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(SLEEP_TIME);
|
Thread.sleep(SLEEP_TIME);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
logger.error("[!] Interrupted while waiting for page to load", e);
|
logger.error("[!] Interrupted while waiting for page to load", e);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for (Element thumb : doc.select("a.thumb img")) {
|
|
||||||
String fullSize = thumbToFull(thumb.attr("src"));
|
|
||||||
URL pageURL;
|
|
||||||
try {
|
|
||||||
pageURL = new URL(fullSize);
|
|
||||||
} catch (MalformedURLException e) {
|
|
||||||
logger.error("[!] Invalid thumbnail image: " + thumbToFull(fullSize));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
index++;
|
|
||||||
addURLToDownload(pageURL, String.format("%03d_", index));
|
|
||||||
}
|
|
||||||
nextURL = null;
|
nextURL = null;
|
||||||
for (Element nextButton : doc.select("a.away")) {
|
for (Element nextButton : doc.select("a.away")) {
|
||||||
if (nextButton.attr("href").contains("offset=" + index)) {
|
if (nextButton.attr("href").contains("offset=" + index)) {
|
||||||
nextURL = this.url.toExternalForm() + "?offset=" + index;
|
nextURL = this.url.toExternalForm() + "?offset=" + index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (nextURL == null) {
|
||||||
|
logger.info("No next button found");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
waitForThreads();
|
waitForThreads();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user