Fixed furaffinity ripper. #84
Logs in correctly via https. Spaces instead of tabs. No more warnings.
This commit is contained in:
parent
9e40e55ee9
commit
b0e5fa8cb0
@ -4,16 +4,12 @@ import java.io.IOException;
|
|||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
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 javax.swing.JOptionPane;
|
|
||||||
import javax.swing.JPasswordField;
|
|
||||||
|
|
||||||
import org.jsoup.Connection.Method;
|
import org.jsoup.Connection.Method;
|
||||||
import org.jsoup.Connection.Response;
|
import org.jsoup.Connection.Response;
|
||||||
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Document;
|
||||||
@ -22,16 +18,17 @@ import org.jsoup.select.Elements;
|
|||||||
|
|
||||||
import com.rarchives.ripme.ripper.AbstractHTMLRipper;
|
import com.rarchives.ripme.ripper.AbstractHTMLRipper;
|
||||||
import com.rarchives.ripme.ripper.DownloadThreadPool;
|
import com.rarchives.ripme.ripper.DownloadThreadPool;
|
||||||
|
import com.rarchives.ripme.utils.Base64;
|
||||||
import com.rarchives.ripme.utils.Http;
|
import com.rarchives.ripme.utils.Http;
|
||||||
|
|
||||||
public class FuraffinityRipper extends AbstractHTMLRipper {
|
public class FuraffinityRipper extends AbstractHTMLRipper {
|
||||||
|
|
||||||
static Map<String, String> cookies=null;
|
static Map<String, String> cookies=null;
|
||||||
static final String urlBase = "http://www.furaffinity.net";
|
static final String urlBase = "https://www.furaffinity.net";
|
||||||
|
|
||||||
// Thread pool for finding direct image links from "image" pages (html)
|
// Thread pool for finding direct image links from "image" pages (html)
|
||||||
private DownloadThreadPool furaffinityThreadPool = new DownloadThreadPool(
|
private DownloadThreadPool furaffinityThreadPool
|
||||||
"furaffinity");
|
= new DownloadThreadPool( "furaffinity");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DownloadThreadPool getThreadPool() {
|
public DownloadThreadPool getThreadPool() {
|
||||||
@ -55,35 +52,35 @@ public class FuraffinityRipper extends AbstractHTMLRipper {
|
|||||||
@Override
|
@Override
|
||||||
public Document getFirstPage() throws IOException {
|
public Document getFirstPage() throws IOException {
|
||||||
if (cookies == null || cookies.size() == 0) {
|
if (cookies == null || cookies.size() == 0) {
|
||||||
JPasswordField passwordField=new JPasswordField();
|
login();
|
||||||
String user = JOptionPane.showInputDialog("Username");
|
}
|
||||||
JOptionPane.showMessageDialog(null,passwordField,"Password",JOptionPane.QUESTION_MESSAGE|JOptionPane.OK_OPTION);
|
|
||||||
String pass = Arrays.toString(passwordField.getPassword());
|
|
||||||
|
|
||||||
Response loginPage=Http.url(urlBase+"/login/")
|
return Http.url(url).cookies(cookies).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void login() throws IOException {
|
||||||
|
String user = new String(Base64.decode("cmlwbWU="));
|
||||||
|
String pass = new String(Base64.decode("cmlwbWVwYXNzd29yZA=="));
|
||||||
|
|
||||||
|
Response loginPage = Http.url(urlBase + "/login/")
|
||||||
.referrer(urlBase)
|
.referrer(urlBase)
|
||||||
.response();
|
.response();
|
||||||
cookies=loginPage.cookies();
|
cookies = loginPage.cookies();
|
||||||
System.out.println("Cookies: "+cookies);
|
|
||||||
|
|
||||||
Map<String,String> formData=new HashMap<String,String>();
|
Map<String,String> formData = new HashMap<String,String>();
|
||||||
formData.put("action", "login");
|
formData.put("action", "login");
|
||||||
formData.put("retard_protection", "1");
|
formData.put("retard_protection", "1");
|
||||||
formData.put("name", user);
|
formData.put("name", user);
|
||||||
formData.put("pass", pass);
|
formData.put("pass", pass);
|
||||||
formData.put("login", "Login to FurAffinity");
|
formData.put("login", "Login to FurAffinity");
|
||||||
|
|
||||||
Response doLogin=Http.url(urlBase+"/login/?ref=http://www.furaffinity.net/")
|
Response doLogin = Http.url(urlBase + "/login/?ref=" + url)
|
||||||
.referrer(urlBase+"/login/")
|
.referrer(urlBase + "/login/")
|
||||||
.cookies(cookies)
|
.cookies(cookies)
|
||||||
.data(formData)
|
.data(formData)
|
||||||
.method(Method.POST)
|
.method(Method.POST)
|
||||||
.response();
|
.response();
|
||||||
cookies.putAll(doLogin.cookies());
|
cookies.putAll(doLogin.cookies());
|
||||||
System.out.println("Cookies: "+cookies);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Http.url(url).cookies(cookies).get();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -116,8 +113,7 @@ public class FuraffinityRipper extends AbstractHTMLRipper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void downloadURL(URL url, int index) {
|
public void downloadURL(URL url, int index) {
|
||||||
furaffinityThreadPool.addThread(new FuraffinityDocumentThread(url,
|
furaffinityThreadPool.addThread(new FuraffinityDocumentThread(url));
|
||||||
index));
|
|
||||||
sleep(250);
|
sleep(250);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,12 +132,10 @@ public class FuraffinityRipper extends AbstractHTMLRipper {
|
|||||||
|
|
||||||
private class FuraffinityDocumentThread extends Thread {
|
private class FuraffinityDocumentThread extends Thread {
|
||||||
private URL url;
|
private URL url;
|
||||||
private int index;
|
|
||||||
|
|
||||||
public FuraffinityDocumentThread(URL url, int index) {
|
public FuraffinityDocumentThread(URL url) {
|
||||||
super();
|
super();
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.index = index;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -158,8 +152,7 @@ public class FuraffinityRipper extends AbstractHTMLRipper {
|
|||||||
logger.info("Found URL " + link);
|
logger.info("Found URL " + link);
|
||||||
addURLToDownload(new URL(link),"","",url.toExternalForm(),cookies);
|
addURLToDownload(new URL(link),"","",url.toExternalForm(),cookies);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error("[!] Exception while loading/parsing " + this.url,
|
logger.error("[!] Exception while loading/parsing " + this.url, e);
|
||||||
e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user