diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/EightmusesRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/EightmusesRipper.java index cede5274..7cfd568f 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/EightmusesRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/EightmusesRipper.java @@ -1,10 +1,7 @@ package com.rarchives.ripme.ripper.rippers; import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; +import java.net.*; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -12,8 +9,6 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; -import com.rarchives.ripme.utils.Utils; -import org.json.JSONObject; import org.jsoup.Connection.Response; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; @@ -25,7 +20,7 @@ import com.rarchives.ripme.utils.Http; public class EightmusesRipper extends AbstractHTMLRipper { - private Map cookies = new HashMap<>(); + private Map cookies = new HashMap<>(); public EightmusesRipper(URL url) throws IOException { super(url); @@ -82,10 +77,10 @@ public class EightmusesRipper extends AbstractHTMLRipper { @Override public List getURLsFromPage(Document page) { List imageURLs = new ArrayList<>(); - int x = 1; // This contains the thumbnails of all images on the page Elements pageImages = page.getElementsByClass("c-tile"); - for (Element thumb : pageImages) { + for (int i = 0; i < pageImages.size(); i++) { + Element thumb = pageImages.get(i); // If true this link is a sub album if (thumb.attr("href").contains("/comics/album/")) { String subUrl = "https://www.8muses.com" + thumb.attr("href"); @@ -109,24 +104,14 @@ public class EightmusesRipper extends AbstractHTMLRipper { if (thumb.hasAttr("data-cfsrc")) { image = thumb.attr("data-cfsrc"); } else { - // Deobfustace the json data - String rawJson = deobfuscateJSON(page.select("script#ractive-public").html() - .replaceAll(">", ">").replaceAll("<", "<").replace("&", "&")); - JSONObject json = new JSONObject(rawJson); + Element imageElement = thumb.select("img").first(); + image = "https://comics.8muses.com" + imageElement.attr("data-src").replace("/th/", "/fl/"); try { - for (int i = 0; i != json.getJSONArray("pictures").length(); i++) { - image = "https://www.8muses.com/image/fl/" + json.getJSONArray("pictures").getJSONObject(i).getString("publicUri"); - URL imageUrl = new URI(image).toURL(); - addURLToDownload(imageUrl, getSubdir(page.select("title").text()), this.url.toExternalForm(), cookies, getPrefixShort(x), "", null, true); - // X is our page index - x++; - if (isThisATest()) { - break; - } - } - return imageURLs; + URL imageUrl = new URI(image).toURL(); + addURLToDownload(imageUrl, getSubdir(page.select("title").text()), this.url.toExternalForm(), cookies, getPrefixShort(i), "", null, true); } catch (MalformedURLException | URISyntaxException e) { LOGGER.error("\"" + image + "\" is malformed"); + LOGGER.error(e.getMessage()); } } if (!image.contains("8muses.com")) { @@ -166,26 +151,4 @@ public class EightmusesRipper extends AbstractHTMLRipper { public String getPrefixShort(int index) { return String.format("%03d", index); } - - private String deobfuscateJSON(String obfuscatedString) { - StringBuilder deobfuscatedString = new StringBuilder(); - // The first char in one of 8muses obfuscated strings is always ! so we replace it - for (char ch : obfuscatedString.replaceFirst("!", "").toCharArray()){ - deobfuscatedString.append(deobfuscateChar(ch)); - } - return deobfuscatedString.toString(); - } - - private String deobfuscateChar(char c) { - if ((int) c == 32) { - return fromCharCode(32); - } else if ((int) c > 120){ - return fromCharCode((int)c); - } - return fromCharCode(33 + (c + 14) % 94); - } - - private static String fromCharCode(int... codePoints) { - return new String(codePoints, 0, codePoints.length); - } } \ No newline at end of file