Rolled E621Ripper back from 1.6.0 to the 1.5.15 version

This commit is contained in:
cyian-1756 2017-10-26 04:47:14 -04:00
parent 3db32d2ffc
commit 3f3f7d6031

View File

@ -1,169 +1,142 @@
// package com.rarchives.ripme.ripper.rippers;
// package com.rarchives.ripme.ripper.rippers;
// import com.rarchives.ripme.ripper.AbstractHTMLRipper;
// import com.rarchives.ripme.ripper.DownloadThreadPool; import com.rarchives.ripme.ripper.AbstractHTMLRipper;
// import com.rarchives.ripme.utils.Http; import com.rarchives.ripme.ripper.DownloadThreadPool;
// import com.rarchives.ripme.utils.Utils; import com.rarchives.ripme.utils.Http;
// import java.io.IOException; import com.rarchives.ripme.utils.Utils;
// import java.io.UnsupportedEncodingException; import java.io.IOException;
// import java.net.MalformedURLException; import java.net.MalformedURLException;
// import java.net.URL; import java.net.URI;
// import java.net.URLDecoder; import java.net.URISyntaxException;
// import java.util.ArrayList; import java.net.URL;
// import java.util.List; import java.util.ArrayList;
// import java.util.logging.Level; import java.util.List;
// import java.util.logging.Logger; import java.util.logging.Level;
// import org.jsoup.nodes.Document; import java.util.logging.Logger;
// import org.jsoup.nodes.Element; import java.util.regex.Matcher;
// import org.jsoup.select.Elements; import java.util.regex.Pattern;
// import org.jsoup.nodes.Document;
// public class E621Ripper extends AbstractHTMLRipper { import org.jsoup.nodes.Element;
// private static final int POOL_IMAGES_PER_PAGE = 24; import org.jsoup.select.Elements;
//
// private DownloadThreadPool e621ThreadPool = new DownloadThreadPool("e621"); /**
// *
// private E621Ripper(URL url) throws IOException { * @author
// super(url); */
// } public class E621Ripper extends AbstractHTMLRipper{
// private static Pattern gidPattern=null;
// @Override private static Pattern gidPattern2=null;
// public DownloadThreadPool getThreadPool() { private static Pattern gidPatternPool=null;
// return e621ThreadPool;
// } private DownloadThreadPool e621ThreadPool=new DownloadThreadPool("e621");
//
// @Override public E621Ripper(URL url) throws IOException {
// public String getDomain() { super(url);
// return "e621.net"; }
// }
// @Override
// @Override public DownloadThreadPool getThreadPool() {
// public String getHost() { return e621ThreadPool;
// return "e621"; }
// }
// @Override
// @Override public String getDomain() {
// public Document getFirstPage() throws IOException { return "e621.net";
// if (url.getPath().startsWith("/pool/show/")) { }
// return Http.url("https://e621.net/pool/show/" + getTerm(url)).get();
// } else { @Override
// return Http.url("https://e621.net/post/index/1/" + getTerm(url)).get(); public String getHost() {
// } return "e621";
// } }
//
// @Override @Override
// public List<String> getURLsFromPage(Document page) { public Document getFirstPage() throws IOException {
// Elements elements = page.select("#post-list .thumb a,#pool-show .thumb a"); if(url.getPath().startsWith("/pool/show/"))
// List<String> res = new ArrayList<>(elements.size()); return Http.url("https://e621.net/pool/show/"+getTerm(url)).get();
// else
// if (page.getElementById("pool-show") != null) { return Http.url("https://e621.net/post/index/1/"+getTerm(url)).get();
// int index = 0; }
//
// Element e = page.getElementById("paginator"); @Override
// if (e != null) { public List<String> getURLsFromPage(Document page) {
// e = e.getElementsByClass("current").first(); Elements elements=page.select("#post-list .thumb a,#pool-show .thumb a");
// if (e != null) { List<String> res=new ArrayList<String>(elements.size());
// index = (Integer.parseInt(e.text()) - 1) * POOL_IMAGES_PER_PAGE;
// } for(Element e:elements){
// } res.add(e.absUrl("href")+"#"+e.child(0).attr("id").substring(1));
// }
// for (Element e_ : elements) {
// res.add(e_.absUrl("href") + "#" + ++index); return res;
// } }
//
// } else { @Override
// for (Element e : elements) { public Document getNextPage(Document page) throws IOException {
// res.add(e.absUrl("href") + "#" + e.child(0).attr("id").substring(1)); for(Element e:page.select("#paginator a")){
// } if(e.attr("rel").equals("next"))
// } return Http.url(e.absUrl("href")).get();
// }
// return res;
// } return null;
// }
// @Override
// public Document getNextPage(Document page) throws IOException { @Override
// for (Element e : page.select("#paginator a")) { public void downloadURL(final URL url, int index) {
// if (e.attr("rel").equals("next")) { e621ThreadPool.addThread(new Thread(new Runnable() {
// return Http.url(e.absUrl("href")).get(); public void run() {
// } try {
// } Document page=Http.url(url).get();
//
// return null; addURLToDownload(new URL(page.getElementById("image").absUrl("src")),Utils.getConfigBoolean("download.save_order",true)?url.getRef()+"-":"");
// } } catch (IOException ex) {
// Logger.getLogger(E621Ripper.class.getName()).log(Level.SEVERE, null, ex);
// @Override }
// public void downloadURL(final URL url, int index) { }
// e621ThreadPool.addThread(new Thread(() -> { }));
// try { }
// Document page = Http.url(url).get();
// Element e = page.getElementById("image"); private String getTerm(URL url) throws MalformedURLException{
// if(gidPattern==null)
// if (e != null) { gidPattern=Pattern.compile("^https?://(www\\.)?e621\\.net/post/index/[^/]+/([a-zA-Z0-9$_.+!*'(),%-]+)(/.*)?(#.*)?$");
// addURLToDownload(new URL(e.absUrl("src")), Utils.getConfigBoolean("download.save_order", true) ? url.getRef() + "-" : ""); if(gidPatternPool==null)
// } else if ((e = page.select(".content object>param[name=\"movie\"]").first()) != null) { gidPatternPool=Pattern.compile("^https?://(www\\.)?e621\\.net/pool/show/([a-zA-Z0-9$_.+!*'(),%-]+)(\\?.*)?(/.*)?(#.*)?$");
// addURLToDownload(new URL(e.absUrl("value")), Utils.getConfigBoolean("download.save_order", true) ? url.getRef() + "-" : "");
// } else { Matcher m = gidPattern.matcher(url.toExternalForm());
// Logger.getLogger(E621Ripper.class.getName()).log(Level.WARNING, "Unsupported media type - please report to program author: " + url.toString()); if(m.matches())
// } return m.group(2);
//
// } catch (IOException ex) { m = gidPatternPool.matcher(url.toExternalForm());
// Logger.getLogger(E621Ripper.class.getName()).log(Level.SEVERE, null, ex); if(m.matches())
// } return m.group(2);
// }));
// } throw new MalformedURLException("Expected e621.net URL format: e621.net/post/index/1/searchterm - got "+url+" instead");
// }
// private String getTerm(URL url) throws MalformedURLException {
// String query = url.getQuery(); @Override
// public String getGID(URL url) throws MalformedURLException {
// if (query != null) { try {
// return Utils.parseUrlQuery(query, "tags"); String prefix="";
// } if(url.getPath().startsWith("/pool/show/"))
// prefix="pool_";
// if (query == null) {
// if ((query = url.getPath()).startsWith("/post/index/")) { return Utils.filesystemSafe(prefix+new URI(getTerm(url)).getPath());
// query = query.substring(12); } catch (URISyntaxException ex) {
// Logger.getLogger(PahealRipper.class.getName()).log(Level.SEVERE, null, ex);
// int pos = query.indexOf('/'); }
// if (pos == -1) {
// return null; throw new MalformedURLException("Expected e621.net URL format: e621.net/post/index/1/searchterm - got "+url+" instead");
// } }
//
// // skip page number @Override
// query = query.substring(pos + 1); public URL sanitizeURL(URL url) throws MalformedURLException {
// if(gidPattern2==null)
// if (query.endsWith("/")) { gidPattern2=Pattern.compile("^https?://(www\\.)?e621\\.net/post/search\\?tags=([a-zA-Z0-9$_.+!*'(),%-]+)(/.*)?(#.*)?$");
// query = query.substring(0, query.length() - 1);
// } Matcher m = gidPattern2.matcher(url.toExternalForm());
// if(m.matches())
// try { return new URL("https://e621.net/post/index/1/"+m.group(2).replace("+","%20"));
// return URLDecoder.decode(query, "UTF-8");
// } catch (UnsupportedEncodingException e) { return url;
// // Shouldn't happen since UTF-8 is required to be supported }
// throw new RuntimeException(e);
// } }
//
// } else if (query.startsWith("/pool/show/")) {
// query = query.substring(11);
//
// if (query.endsWith("/")) {
// query = query.substring(0, query.length() - 1);
// }
//
// return query;
// }
// }
//
// return null;
// }
//
// @Override
// public String getGID(URL url) throws MalformedURLException {
// String prefix = "";
// if (url.getPath().startsWith("/pool/show/")) {
// prefix = "pool_";
// } else {
// prefix = "term_";
// }
//
// return Utils.filesystemSafe(prefix + getTerm(url));
// }
// }