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.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import com.rarchives.ripme.ui.RipStatusMessage;
|
||||||
import com.rarchives.ripme.utils.Utils;
|
import com.rarchives.ripme.utils.Utils;
|
||||||
import org.jsoup.Connection.Response;
|
import org.jsoup.Connection.Response;
|
||||||
|
import org.jsoup.HttpStatusException;
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Document;
|
||||||
import org.jsoup.nodes.Element;
|
import org.jsoup.nodes.Element;
|
||||||
@ -27,10 +29,24 @@ import com.rarchives.ripme.utils.Http;
|
|||||||
public class FuraffinityRipper extends AbstractHTMLRipper {
|
public class FuraffinityRipper extends AbstractHTMLRipper {
|
||||||
|
|
||||||
private static final String urlBase = "https://www.furaffinity.net";
|
private static final String urlBase = "https://www.furaffinity.net";
|
||||||
private static Map<String,String> cookies = new HashMap<>();
|
private Map<String,String> cookies = new HashMap<>();
|
||||||
static {
|
|
||||||
cookies.put("b", "bd5ccac8-51dc-4265-8ae1-7eac685ad667");
|
private void setCookies() {
|
||||||
cookies.put("a", "7c41b782-d01d-4b0e-b45b-62a4f0b2a369");
|
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)
|
// Thread pool for finding direct image links from "image" pages (html)
|
||||||
@ -61,6 +77,8 @@ public class FuraffinityRipper extends AbstractHTMLRipper {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public Document getFirstPage() throws IOException {
|
public Document getFirstPage() throws IOException {
|
||||||
|
setCookies();
|
||||||
|
LOGGER.info(Http.url(url).cookies(cookies).get().html());
|
||||||
return Http.url(url).cookies(cookies).get();
|
return Http.url(url).cookies(cookies).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,20 +98,34 @@ public class FuraffinityRipper extends AbstractHTMLRipper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getImageFromPost(String url) {
|
private String getImageFromPost(String url) {
|
||||||
|
sleep(1000);
|
||||||
|
Document d = null;
|
||||||
try {
|
try {
|
||||||
LOGGER.info("found url " + Http.url(url).cookies(cookies).get().select("meta[property=og:image]").attr("content"));
|
d = Http.url(url).cookies(cookies).get();
|
||||||
return Http.url(url).cookies(cookies).get().select("meta[property=og:image]").attr("content");
|
Elements links = d.getElementsByTag("a");
|
||||||
} catch (IOException e) {
|
for (Element link : links) {
|
||||||
return "";
|
if (link.text().equals("Download")) {
|
||||||
|
LOGGER.info("Found image " + link.attr("href"));
|
||||||
|
return "https:" + link.attr("href");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getURLsFromPage(Document page) {
|
public List<String> getURLsFromPage(Document page) {
|
||||||
List<String> urls = new ArrayList<>();
|
List<String> urls = new ArrayList<>();
|
||||||
Elements urlElements = page.select("figure.t-image > b > u > a");
|
Elements urlElements = page.select("figure.t-image > b > u > a");
|
||||||
for (Element e : urlElements) {
|
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;
|
return urls;
|
||||||
}
|
}
|
||||||
@ -200,16 +232,5 @@ public class FuraffinityRipper extends AbstractHTMLRipper {
|
|||||||
+ " instead");
|
+ " instead");
|
||||||
}
|
}
|
||||||
|
|
||||||
private class FuraffinityDocumentThread extends Thread {
|
|
||||||
private URL url;
|
|
||||||
|
|
||||||
FuraffinityDocumentThread(URL url) {
|
|
||||||
super();
|
|
||||||
this.url = url;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user