mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-08-11 00:14:12 +02:00
@@ -1,10 +1,7 @@
|
|||||||
package com.rarchives.ripme.ripper.rippers;
|
package com.rarchives.ripme.ripper.rippers;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.*;
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -12,8 +9,6 @@ import java.util.Map;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import com.rarchives.ripme.utils.Utils;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.jsoup.Connection.Response;
|
import org.jsoup.Connection.Response;
|
||||||
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Document;
|
||||||
import org.jsoup.nodes.Element;
|
import org.jsoup.nodes.Element;
|
||||||
@@ -25,7 +20,7 @@ import com.rarchives.ripme.utils.Http;
|
|||||||
|
|
||||||
public class EightmusesRipper extends AbstractHTMLRipper {
|
public class EightmusesRipper extends AbstractHTMLRipper {
|
||||||
|
|
||||||
private Map<String,String> cookies = new HashMap<>();
|
private Map<String, String> cookies = new HashMap<>();
|
||||||
|
|
||||||
public EightmusesRipper(URL url) throws IOException {
|
public EightmusesRipper(URL url) throws IOException {
|
||||||
super(url);
|
super(url);
|
||||||
@@ -82,10 +77,10 @@ public class EightmusesRipper extends AbstractHTMLRipper {
|
|||||||
@Override
|
@Override
|
||||||
public List<String> getURLsFromPage(Document page) {
|
public List<String> getURLsFromPage(Document page) {
|
||||||
List<String> imageURLs = new ArrayList<>();
|
List<String> imageURLs = new ArrayList<>();
|
||||||
int x = 1;
|
|
||||||
// This contains the thumbnails of all images on the page
|
// This contains the thumbnails of all images on the page
|
||||||
Elements pageImages = page.getElementsByClass("c-tile");
|
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 true this link is a sub album
|
||||||
if (thumb.attr("href").contains("/comics/album/")) {
|
if (thumb.attr("href").contains("/comics/album/")) {
|
||||||
String subUrl = "https://www.8muses.com" + thumb.attr("href");
|
String subUrl = "https://www.8muses.com" + thumb.attr("href");
|
||||||
@@ -109,24 +104,14 @@ public class EightmusesRipper extends AbstractHTMLRipper {
|
|||||||
if (thumb.hasAttr("data-cfsrc")) {
|
if (thumb.hasAttr("data-cfsrc")) {
|
||||||
image = thumb.attr("data-cfsrc");
|
image = thumb.attr("data-cfsrc");
|
||||||
} else {
|
} else {
|
||||||
// Deobfustace the json data
|
Element imageElement = thumb.select("img").first();
|
||||||
String rawJson = deobfuscateJSON(page.select("script#ractive-public").html()
|
image = "https://comics.8muses.com" + imageElement.attr("data-src").replace("/th/", "/fl/");
|
||||||
.replaceAll(">", ">").replaceAll("<", "<").replace("&", "&"));
|
|
||||||
JSONObject json = new JSONObject(rawJson);
|
|
||||||
try {
|
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();
|
URL imageUrl = new URI(image).toURL();
|
||||||
addURLToDownload(imageUrl, getSubdir(page.select("title").text()), this.url.toExternalForm(), cookies, getPrefixShort(x), "", null, true);
|
addURLToDownload(imageUrl, getSubdir(page.select("title").text()), this.url.toExternalForm(), cookies, getPrefixShort(i), "", null, true);
|
||||||
// X is our page index
|
|
||||||
x++;
|
|
||||||
if (isThisATest()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return imageURLs;
|
|
||||||
} catch (MalformedURLException | URISyntaxException e) {
|
} catch (MalformedURLException | URISyntaxException e) {
|
||||||
LOGGER.error("\"" + image + "\" is malformed");
|
LOGGER.error("\"" + image + "\" is malformed");
|
||||||
|
LOGGER.error(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!image.contains("8muses.com")) {
|
if (!image.contains("8muses.com")) {
|
||||||
@@ -166,26 +151,4 @@ public class EightmusesRipper extends AbstractHTMLRipper {
|
|||||||
public String getPrefixShort(int index) {
|
public String getPrefixShort(int index) {
|
||||||
return String.format("%03d", 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user