Fixed E621 Ripper

This commit is contained in:
cyian-1756 2017-12-02 04:25:42 -05:00
parent 5a21a820b3
commit f82bb53eb7

View File

@ -54,13 +54,27 @@ public class E621Ripper extends AbstractHTMLRipper{
return Http.url("https://e621.net/post/index/1/"+getTerm(url)).get(); return Http.url("https://e621.net/post/index/1/"+getTerm(url)).get();
} }
private String getFullSizedImage(String url) {
try {
return Http.url("https://e621.net" + url).get().select("div > img#image").attr("src");
} catch (IOException e) {
logger.error("Unable to get full sized image from " + url);
return null;
}
}
@Override @Override
public List<String> getURLsFromPage(Document page) { public List<String> getURLsFromPage(Document page) {
Elements elements=page.select("#post-list .thumb a,#pool-show .thumb a"); Elements elements = page.select("div > span.thumb > a");
List<String> res=new ArrayList<String>(elements.size()); List<String> res = new ArrayList<>();
for(Element e:elements){ for(Element e:elements) {
res.add(e.absUrl("href")+"#"+e.child(0).attr("id").substring(1)); if (!e.attr("href").isEmpty()) {
String fullSizedImage = getFullSizedImage(e.attr("href"));
if (fullSizedImage != null && !fullSizedImage.equals("")) {
res.add(getFullSizedImage(e.attr("href")));
}
}
} }
return res; return res;
@ -68,27 +82,16 @@ public class E621Ripper extends AbstractHTMLRipper{
@Override @Override
public Document getNextPage(Document page) throws IOException { public Document getNextPage(Document page) throws IOException {
for(Element e:page.select("#paginator a")){ if (page.select("a.next_page") != null) {
if(e.attr("rel").equals("next")) return Http.url("https://e621.net" + page.select("a.next_page").attr("href")).get();
return Http.url(e.absUrl("href")).get(); } else {
} throw new IOException("No more pages");
}
return null; }
}
@Override @Override
public void downloadURL(final URL url, int index) { public void downloadURL(final URL url, int index) {
e621ThreadPool.addThread(new Thread(new Runnable() { addURLToDownload(url, getPrefix(index));
public void run() {
try {
Document page=Http.url(url).get();
addURLToDownload(new URL(page.getElementById("image").absUrl("src")),Utils.getConfigBoolean("download.save_order",true)?url.getRef()+"-":"");
} catch (IOException ex) {
logger.error(ex);
}
}
}));
} }
private String getTerm(URL url) throws MalformedURLException{ private String getTerm(URL url) throws MalformedURLException{