Merge pull request #697 from cyian-1756/faCookieChange

Furaffinity ripper now uses RipUtils.getCookiesFromString to load cookies
This commit is contained in:
cyian-1756 2018-06-15 16:17:50 -04:00 committed by GitHub
commit b111a997fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 7 deletions

View File

@ -26,6 +26,8 @@ import com.rarchives.ripme.ripper.AbstractHTMLRipper;
import com.rarchives.ripme.ripper.DownloadThreadPool; import com.rarchives.ripme.ripper.DownloadThreadPool;
import com.rarchives.ripme.utils.Http; import com.rarchives.ripme.utils.Http;
import static com.rarchives.ripme.utils.RipUtils.getCookiesFromString;
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";
@ -34,16 +36,14 @@ public class FuraffinityRipper extends AbstractHTMLRipper {
private void setCookies() { private void setCookies() {
if (Utils.getConfigBoolean("furaffinity.login", true)) { if (Utils.getConfigBoolean("furaffinity.login", true)) {
LOGGER.info("Logging in using cookies"); LOGGER.info("Logging in using cookies");
String faACookie = Utils.getConfigString("furaffinity.cookie.a", "897bc45b-1f87-49f1-8a85-9412bc103e7a"); String faCookies = Utils.getConfigString("furaffinity.cookies", "a=897bc45b-1f87-49f1-8a85-9412bc103e7a;b=c8807f36-7a85-4caf-80ca-01c2a2368267");
String faBCookie = Utils.getConfigString("furaffinity.cookie.b", "c8807f36-7a85-4caf-80ca-01c2a2368267"); warnAboutSharedAccount(faCookies);
warnAboutSharedAccount(faACookie, faBCookie); cookies = getCookiesFromString(faCookies);
cookies.put("a", faACookie);
cookies.put("b", faBCookie);
} }
} }
private void warnAboutSharedAccount(String a, String b) { private void warnAboutSharedAccount(String loginCookies) {
if (a.equals("897bc45b-1f87-49f1-8a85-9412bc103e7a") && b.equals("c8807f36-7a85-4caf-80ca-01c2a2368267")) { if (loginCookies.equals("a=897bc45b-1f87-49f1-8a85-9412bc103e7a;b=c8807f36-7a85-4caf-80ca-01c2a2368267")) {
sendUpdate(RipStatusMessage.STATUS.DOWNLOAD_ERRORED, 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"); "WARNING: Using the shared furaffinity account exposes both your IP and how many items you downloaded to the other users of the share account");
} }

View File

@ -16,4 +16,12 @@ public class FuraffinityRipperTest extends RippersTest {
FuraffinityRipper ripper = new FuraffinityRipper(url); FuraffinityRipper ripper = new FuraffinityRipper(url);
assertEquals("mustardgas", ripper.getGID(url)); assertEquals("mustardgas", ripper.getGID(url));
} }
public void testLogin() throws IOException {
URL url = new URL("https://www.furaffinity.net/gallery/mustardgas/");
FuraffinityRipper ripper = new FuraffinityRipper(url);
// Check if the first page contain the username of ripmes shared account
Boolean containsUsername = ripper.getFirstPage().html().contains("ripmethrowaway");
assert containsUsername;
}
} }