Merge pull request #681 from cyian-1756/FACookieFix
Users can now use their own account when ripping Furaffinity
This commit is contained in:
commit
d1a6542912
@ -12,8 +12,10 @@ import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.rarchives.ripme.ui.RipStatusMessage;
|
||||
import com.rarchives.ripme.utils.Utils;
|
||||
import org.jsoup.Connection.Response;
|
||||
import org.jsoup.HttpStatusException;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
@ -27,10 +29,24 @@ import com.rarchives.ripme.utils.Http;
|
||||
public class FuraffinityRipper extends AbstractHTMLRipper {
|
||||
|
||||
private static final String urlBase = "https://www.furaffinity.net";
|
||||
private static Map<String,String> cookies = new HashMap<>();
|
||||
static {
|
||||
cookies.put("b", "bd5ccac8-51dc-4265-8ae1-7eac685ad667");
|
||||
cookies.put("a", "7c41b782-d01d-4b0e-b45b-62a4f0b2a369");
|
||||
private Map<String,String> cookies = new HashMap<>();
|
||||
|
||||
private void setCookies() {
|
||||
if (Utils.getConfigBoolean("furaffinity.login", true)) {
|
||||
LOGGER.info("Logging in using cookies");
|
||||
String faACookie = Utils.getConfigString("furaffinity.cookie.a", "897bc45b-1f87-49f1-8a85-9412bc103e7a");
|
||||
String faBCookie = Utils.getConfigString("furaffinity.cookie.b", "c8807f36-7a85-4caf-80ca-01c2a2368267");
|
||||
warnAboutSharedAccount(faACookie, faBCookie);
|
||||
cookies.put("a", faACookie);
|
||||
cookies.put("b", faBCookie);
|
||||
}
|
||||
}
|
||||
|
||||
private void warnAboutSharedAccount(String a, String b) {
|
||||
if (a.equals("897bc45b-1f87-49f1-8a85-9412bc103e7a") && b.equals("c8807f36-7a85-4caf-80ca-01c2a2368267")) {
|
||||
sendUpdate(RipStatusMessage.STATUS.DOWNLOAD_ERRORED,
|
||||
"WARNING: Using the shared furaffinity account exposes both your IP and how many items you downloaded to the other users of the share account");
|
||||
}
|
||||
}
|
||||
|
||||
// Thread pool for finding direct image links from "image" pages (html)
|
||||
@ -61,6 +77,8 @@ public class FuraffinityRipper extends AbstractHTMLRipper {
|
||||
}
|
||||
@Override
|
||||
public Document getFirstPage() throws IOException {
|
||||
setCookies();
|
||||
LOGGER.info(Http.url(url).cookies(cookies).get().html());
|
||||
return Http.url(url).cookies(cookies).get();
|
||||
}
|
||||
|
||||
@ -80,12 +98,21 @@ public class FuraffinityRipper extends AbstractHTMLRipper {
|
||||
}
|
||||
|
||||
private String getImageFromPost(String url) {
|
||||
sleep(1000);
|
||||
Document d = null;
|
||||
try {
|
||||
LOGGER.info("found url " + Http.url(url).cookies(cookies).get().select("meta[property=og:image]").attr("content"));
|
||||
return Http.url(url).cookies(cookies).get().select("meta[property=og:image]").attr("content");
|
||||
d = Http.url(url).cookies(cookies).get();
|
||||
Elements links = d.getElementsByTag("a");
|
||||
for (Element link : links) {
|
||||
if (link.text().equals("Download")) {
|
||||
LOGGER.info("Found image " + link.attr("href"));
|
||||
return "https:" + link.attr("href");
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
return "";
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -93,7 +120,12 @@ public class FuraffinityRipper extends AbstractHTMLRipper {
|
||||
List<String> urls = new ArrayList<>();
|
||||
Elements urlElements = page.select("figure.t-image > b > u > a");
|
||||
for (Element e : urlElements) {
|
||||
urls.add(getImageFromPost(urlBase + e.select("a").first().attr("href")));
|
||||
String urlToAdd = getImageFromPost(urlBase + e.select("a").first().attr("href"));
|
||||
if (url != null) {
|
||||
if (urlToAdd.startsWith("http")) {
|
||||
urls.add(urlToAdd);
|
||||
}
|
||||
}
|
||||
}
|
||||
return urls;
|
||||
}
|
||||
@ -200,16 +232,5 @@ public class FuraffinityRipper extends AbstractHTMLRipper {
|
||||
+ " instead");
|
||||
}
|
||||
|
||||
private class FuraffinityDocumentThread extends Thread {
|
||||
private URL url;
|
||||
|
||||
FuraffinityDocumentThread(URL url) {
|
||||
super();
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user