mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-08-26 07:14:38 +02:00
Merge pull request #1222 from Tush-r/fuskator
Fixed FuskatorRipper not ripping images.
This commit is contained in:
@@ -1,23 +1,30 @@
|
|||||||
package com.rarchives.ripme.ripper.rippers;
|
package com.rarchives.ripme.ripper.rippers;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLDecoder;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
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 org.json.JSONArray;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
import org.jsoup.Connection.Method;
|
||||||
|
import org.jsoup.Connection.Response;
|
||||||
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Document;
|
||||||
|
|
||||||
import com.rarchives.ripme.ripper.AbstractHTMLRipper;
|
import com.rarchives.ripme.ripper.AbstractHTMLRipper;
|
||||||
import com.rarchives.ripme.utils.Http;
|
import com.rarchives.ripme.utils.Http;
|
||||||
import com.rarchives.ripme.utils.Utils;
|
|
||||||
|
|
||||||
public class FuskatorRipper extends AbstractHTMLRipper {
|
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 {
|
public FuskatorRipper(URL url) throws IOException {
|
||||||
super(url);
|
super(url);
|
||||||
}
|
}
|
||||||
@@ -26,6 +33,7 @@ public class FuskatorRipper extends AbstractHTMLRipper {
|
|||||||
public String getHost() {
|
public String getHost() {
|
||||||
return "fuskator";
|
return "fuskator";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDomain() {
|
public String getDomain() {
|
||||||
return "fuskator.com";
|
return "fuskator.com";
|
||||||
@@ -37,6 +45,9 @@ public class FuskatorRipper extends AbstractHTMLRipper {
|
|||||||
if (u.contains("/thumbs/")) {
|
if (u.contains("/thumbs/")) {
|
||||||
u = u.replace("/thumbs/", "/full/");
|
u = u.replace("/thumbs/", "/full/");
|
||||||
}
|
}
|
||||||
|
if (u.contains("/expanded/")) {
|
||||||
|
u = u.replaceAll("/expanded/", "/full/");
|
||||||
|
}
|
||||||
return new URL(u);
|
return new URL(u);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,34 +59,41 @@ public class FuskatorRipper extends AbstractHTMLRipper {
|
|||||||
return m.group(1);
|
return m.group(1);
|
||||||
}
|
}
|
||||||
throw new MalformedURLException(
|
throw new MalformedURLException(
|
||||||
"Expected fuskator.com gallery formats: "
|
"Expected fuskator.com gallery formats: " + "fuskator.com/full/id/..." + " Got: " + url);
|
||||||
+ "fuskator.com/full/id/..."
|
|
||||||
+ " Got: " + url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Document getFirstPage() throws IOException {
|
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
|
@Override
|
||||||
public List<String> getURLsFromPage(Document doc) {
|
public List<String> getURLsFromPage(Document doc) {
|
||||||
List<String> imageURLs = new ArrayList<>();
|
List<String> imageURLs = new ArrayList<>();
|
||||||
String html = doc.html();
|
JSONObject json;
|
||||||
// Get "baseUrl"
|
|
||||||
String baseUrl = Utils.between(html, "unescape('", "'").get(0);
|
|
||||||
try {
|
try {
|
||||||
baseUrl = URLDecoder.decode(baseUrl, "UTF-8");
|
getXAuthToken();
|
||||||
} catch (UnsupportedEncodingException e) {
|
if (xAuthToken == null || xAuthToken.isEmpty()) {
|
||||||
LOGGER.warn("Error while decoding " + baseUrl, e);
|
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;
|
JSONArray imageArray = json.getJSONArray("images");
|
||||||
}
|
for (int i = 0; i < imageArray.length(); i++) {
|
||||||
// Iterate over images
|
imageURLs.add("https:" + imageArray.getJSONObject(i).getString("imageUrl"));
|
||||||
for (String filename : Utils.between(html, "+'", "'")) {
|
|
||||||
imageURLs.add(baseUrl + filename);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return imageURLs;
|
return imageURLs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,4 +101,12 @@ public class FuskatorRipper extends AbstractHTMLRipper {
|
|||||||
public void downloadURL(URL url, int index) {
|
public void downloadURL(URL url, int index) {
|
||||||
addURLToDownload(url, getPrefix(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;
|
package com.rarchives.ripme.tst.ripper.rippers;
|
||||||
//
|
|
||||||
//import java.io.IOException;
|
import java.io.IOException;
|
||||||
//import java.net.URL;
|
import java.net.URL;
|
||||||
//
|
|
||||||
//import com.rarchives.ripme.ripper.rippers.FuskatorRipper;
|
import com.rarchives.ripme.ripper.rippers.FuskatorRipper;
|
||||||
//
|
|
||||||
//public class FuskatorRipperTest extends RippersTest {
|
public class FuskatorRipperTest extends RippersTest {
|
||||||
// public void testFuskatorAlbum() throws IOException {
|
public void testFuskatorAlbum() throws IOException {
|
||||||
// FuskatorRipper ripper = new FuskatorRipper(new URL("https://fuskator.com/thumbs/hqt6pPXAf9z/Shaved-Blonde-Babe-Katerina-Ambre.html"));
|
FuskatorRipper ripper = new FuskatorRipper(new URL("https://fuskator.com/thumbs/hqt6pPXAf9z/Shaved-Blonde-Babe-Katerina-Ambre.html"));
|
||||||
// testRipper(ripper);
|
testRipper(ripper);
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
|
|
||||||
// Disabled because of https://github.com/RipMeApp/ripme/issues/393
|
// Disabled because of https://github.com/RipMeApp/ripme/issues/393
|
Reference in New Issue
Block a user