mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-08-26 07:14:38 +02:00
Fixed FuskatorRipper not ripping images.
This commit is contained in:
@@ -1,23 +1,30 @@
|
||||
package com.rarchives.ripme.ripper.rippers;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.jsoup.Connection.Method;
|
||||
import org.jsoup.Connection.Response;
|
||||
import org.jsoup.nodes.Document;
|
||||
|
||||
import com.rarchives.ripme.ripper.AbstractHTMLRipper;
|
||||
import com.rarchives.ripme.utils.Http;
|
||||
import com.rarchives.ripme.utils.Utils;
|
||||
|
||||
public class FuskatorRipper extends AbstractHTMLRipper {
|
||||
|
||||
private String jsonurl = "https://fuskator.com/ajax/gal.aspx";
|
||||
private String xAuthUrl = "https://fuskator.com/ajax/auth.aspx";
|
||||
private String xAuthToken;
|
||||
private Map<String, String> cookies;
|
||||
|
||||
public FuskatorRipper(URL url) throws IOException {
|
||||
super(url);
|
||||
}
|
||||
@@ -26,6 +33,7 @@ public class FuskatorRipper extends AbstractHTMLRipper {
|
||||
public String getHost() {
|
||||
return "fuskator";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDomain() {
|
||||
return "fuskator.com";
|
||||
@@ -37,6 +45,9 @@ public class FuskatorRipper extends AbstractHTMLRipper {
|
||||
if (u.contains("/thumbs/")) {
|
||||
u = u.replace("/thumbs/", "/full/");
|
||||
}
|
||||
if (u.contains("/expanded/")) {
|
||||
u = u.replaceAll("/expanded/", "/full/");
|
||||
}
|
||||
return new URL(u);
|
||||
}
|
||||
|
||||
@@ -48,34 +59,41 @@ public class FuskatorRipper extends AbstractHTMLRipper {
|
||||
return m.group(1);
|
||||
}
|
||||
throw new MalformedURLException(
|
||||
"Expected fuskator.com gallery formats: "
|
||||
+ "fuskator.com/full/id/..."
|
||||
+ " Got: " + url);
|
||||
"Expected fuskator.com gallery formats: " + "fuskator.com/full/id/..." + " Got: " + url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Document getFirstPage() throws IOException {
|
||||
return Http.url(url).get();
|
||||
// return Http.url(url).get();
|
||||
Response res = Http.url(url).response();
|
||||
cookies = res.cookies();
|
||||
return res.parse();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getURLsFromPage(Document doc) {
|
||||
List<String> imageURLs = new ArrayList<>();
|
||||
String html = doc.html();
|
||||
// Get "baseUrl"
|
||||
String baseUrl = Utils.between(html, "unescape('", "'").get(0);
|
||||
JSONObject json;
|
||||
|
||||
try {
|
||||
baseUrl = URLDecoder.decode(baseUrl, "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
LOGGER.warn("Error while decoding " + baseUrl, e);
|
||||
getXAuthToken();
|
||||
if (xAuthToken == null || xAuthToken.isEmpty()) {
|
||||
throw new IOException("No xAuthToken found.");
|
||||
}
|
||||
|
||||
// All good. Fetch JSON data from jsonUrl.
|
||||
json = Http.url(jsonurl).cookies(cookies).data("X-Auth", xAuthToken).data("hash", getGID(url))
|
||||
.data("_", Long.toString(System.currentTimeMillis())).getJSON();
|
||||
} catch (IOException e) {
|
||||
LOGGER.error("Couldnt fetch images.", e.getCause());
|
||||
return imageURLs;
|
||||
}
|
||||
if (baseUrl.startsWith("//")) {
|
||||
baseUrl = "http:" + baseUrl;
|
||||
}
|
||||
// Iterate over images
|
||||
for (String filename : Utils.between(html, "+'", "'")) {
|
||||
imageURLs.add(baseUrl + filename);
|
||||
|
||||
JSONArray imageArray = json.getJSONArray("images");
|
||||
for (int i = 0; i < imageArray.length(); i++) {
|
||||
imageURLs.add("https:" + imageArray.getJSONObject(i).getString("imageUrl"));
|
||||
}
|
||||
|
||||
return imageURLs;
|
||||
}
|
||||
|
||||
@@ -83,4 +101,12 @@ public class FuskatorRipper extends AbstractHTMLRipper {
|
||||
public void downloadURL(URL url, int index) {
|
||||
addURLToDownload(url, getPrefix(index));
|
||||
}
|
||||
|
||||
private void getXAuthToken() throws IOException {
|
||||
if (cookies == null || cookies.isEmpty()) {
|
||||
throw new IOException("Null cookies or no cookies found.");
|
||||
}
|
||||
Response res = Http.url(xAuthUrl).cookies(cookies).method(Method.POST).response();
|
||||
xAuthToken = res.body();
|
||||
}
|
||||
}
|
||||
|
@@ -1,15 +1,15 @@
|
||||
//package com.rarchives.ripme.tst.ripper.rippers;
|
||||
//
|
||||
//import java.io.IOException;
|
||||
//import java.net.URL;
|
||||
//
|
||||
//import com.rarchives.ripme.ripper.rippers.FuskatorRipper;
|
||||
//
|
||||
//public class FuskatorRipperTest extends RippersTest {
|
||||
// public void testFuskatorAlbum() throws IOException {
|
||||
// FuskatorRipper ripper = new FuskatorRipper(new URL("https://fuskator.com/thumbs/hqt6pPXAf9z/Shaved-Blonde-Babe-Katerina-Ambre.html"));
|
||||
// testRipper(ripper);
|
||||
// }
|
||||
//}
|
||||
package com.rarchives.ripme.tst.ripper.rippers;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import com.rarchives.ripme.ripper.rippers.FuskatorRipper;
|
||||
|
||||
public class FuskatorRipperTest extends RippersTest {
|
||||
public void testFuskatorAlbum() throws IOException {
|
||||
FuskatorRipper ripper = new FuskatorRipper(new URL("https://fuskator.com/thumbs/hqt6pPXAf9z/Shaved-Blonde-Babe-Katerina-Ambre.html"));
|
||||
testRipper(ripper);
|
||||
}
|
||||
}
|
||||
|
||||
// Disabled because of https://github.com/RipMeApp/ripme/issues/393
|
Reference in New Issue
Block a user