From c4f2d52370b9a92d306f7ec4715431e31d3cdbaa Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Mon, 25 Jun 2018 05:32:37 -0400 Subject: [PATCH] Fixed erome ripper and added quickQueue support --- .../ripme/ripper/rippers/EromeRipper.java | 78 +++++++++---------- 1 file changed, 35 insertions(+), 43 deletions(-) diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/EromeRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/EromeRipper.java index a01c134a..2711cd1d 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/EromeRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/EromeRipper.java @@ -22,6 +22,8 @@ import com.rarchives.ripme.utils.Http; */ public class EromeRipper extends AbstractHTMLRipper { + boolean rippingProfile; + public EromeRipper (URL url) throws IOException { super(url); @@ -42,6 +44,27 @@ public class EromeRipper extends AbstractHTMLRipper { addURLToDownload(url, getPrefix(index)); } + @Override + public boolean hasQueueSupport() { + return true; + } + + @Override + public boolean pageContainsAlbums(URL url) { + Pattern pa = Pattern.compile("https?://www.erome.com/([a-zA-Z0-9_-]*)/?"); + Matcher ma = pa.matcher(url.toExternalForm()); + return ma.matches(); + } + + @Override + public List getAlbumsToQueue(Document doc) { + List urlsToAddToQueue = new ArrayList<>(); + for (Element elem : doc.select("div#albums > div.album > a")) { + urlsToAddToQueue.add(elem.attr("href")); + } + return urlsToAddToQueue; + } + @Override public String getAlbumTitle(URL url) throws MalformedURLException { try { @@ -53,6 +76,8 @@ public class EromeRipper extends AbstractHTMLRipper { } catch (IOException e) { // Fall back to default album naming convention LOGGER.info("Unable to find title at " + url); + } catch (NullPointerException e) { + return getHost() + "_" + getGID(url); } return super.getAlbumTitle(url); } @@ -66,21 +91,7 @@ public class EromeRipper extends AbstractHTMLRipper { @Override public List getURLsFromPage(Document doc) { List URLs = new ArrayList<>(); - //Pictures - Elements imgs = doc.select("div.img > img.img-front"); - for (Element img : imgs) { - String imageURL = img.attr("src"); - imageURL = "https:" + imageURL; - URLs.add(imageURL); - } - //Videos - Elements vids = doc.select("div.video > video > source"); - for (Element vid : vids) { - String videoURL = vid.attr("src"); - URLs.add("https:" + videoURL); - } - - return URLs; + return getMediaFromPage(doc); } @Override @@ -100,7 +111,7 @@ public class EromeRipper extends AbstractHTMLRipper { return m.group(1); } - p = Pattern.compile("^https?://erome.com/a/([a-zA-Z0-9]*)/?$"); + p = Pattern.compile("^https?://www.erome.com/([a-zA-Z0-9_-]+)/?$"); m = p.matcher(url.toExternalForm()); if (m.matches()) { @@ -110,34 +121,15 @@ public class EromeRipper extends AbstractHTMLRipper { throw new MalformedURLException("erome album not found in " + url + ", expected https://www.erome.com/album"); } - public static List getURLs(URL url) throws IOException{ - - Response resp = Http.url(url) - .ignoreContentType() - .response(); - - Document doc = resp.parse(); - - List URLs = new ArrayList<>(); - //Pictures - Elements imgs = doc.getElementsByTag("img"); - for (Element img : imgs) { - if (img.hasClass("album-image")) { - String imageURL = img.attr("src"); - imageURL = "https:" + imageURL; - URLs.add(new URL(imageURL)); - } + private List getMediaFromPage(Document doc) { + List results = new ArrayList<>(); + for (Element el : doc.select("img.img-front")) { + results.add("https:" + el.attr("src")); } - //Videos - Elements vids = doc.getElementsByTag("video"); - for (Element vid : vids) { - if (vid.hasClass("album-video")) { - Elements source = vid.getElementsByTag("source"); - String videoURL = source.first().attr("src"); - URLs.add(new URL(videoURL)); - } + for (Element el : doc.select("source[label=HD]")) { + results.add("https:" + el.attr("src")); } - - return URLs; + return results; } + }