parent
1fc037358a
commit
91ef1c1b31
2
pom.xml
2
pom.xml
@ -4,7 +4,7 @@
|
|||||||
<groupId>com.rarchives.ripme</groupId>
|
<groupId>com.rarchives.ripme</groupId>
|
||||||
<artifactId>ripme</artifactId>
|
<artifactId>ripme</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<version>1.0.82</version>
|
<version>1.0.83</version>
|
||||||
<name>ripme</name>
|
<name>ripme</name>
|
||||||
<url>http://rip.rarchives.com</url>
|
<url>http://rip.rarchives.com</url>
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -4,19 +4,25 @@ 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.HashMap;
|
||||||
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.jsoup.Connection.Method;
|
||||||
|
import org.jsoup.Connection.Response;
|
||||||
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Document;
|
||||||
import org.jsoup.nodes.Element;
|
import org.jsoup.nodes.Element;
|
||||||
|
|
||||||
import com.rarchives.ripme.ripper.AbstractHTMLRipper;
|
import com.rarchives.ripme.ripper.AbstractHTMLRipper;
|
||||||
|
import com.rarchives.ripme.utils.Base64;
|
||||||
import com.rarchives.ripme.utils.Http;
|
import com.rarchives.ripme.utils.Http;
|
||||||
|
|
||||||
public class TwodgalleriesRipper extends AbstractHTMLRipper {
|
public class TwodgalleriesRipper extends AbstractHTMLRipper {
|
||||||
|
|
||||||
private int offset = 0;
|
private int offset = 0;
|
||||||
|
private Map<String,String> cookies = new HashMap<String,String>();
|
||||||
|
|
||||||
public TwodgalleriesRipper(URL url) throws IOException {
|
public TwodgalleriesRipper(URL url) throws IOException {
|
||||||
super(url);
|
super(url);
|
||||||
@ -35,36 +41,48 @@ public class TwodgalleriesRipper extends AbstractHTMLRipper {
|
|||||||
public String getGID(URL url) throws MalformedURLException {
|
public String getGID(URL url) throws MalformedURLException {
|
||||||
Pattern p; Matcher m;
|
Pattern p; Matcher m;
|
||||||
|
|
||||||
p = Pattern.compile("^.*2dgalleries.com/browse/profile\\?id=([0-9]+).*$");
|
p = Pattern.compile("^.*2dgalleries.com/artist/([a-zA-Z0-9\\-]+).*$");
|
||||||
m = p.matcher(url.toExternalForm());
|
m = p.matcher(url.toExternalForm());
|
||||||
if (m.matches()) {
|
if (m.matches()) {
|
||||||
return m.group(1);
|
return m.group(1);
|
||||||
}
|
}
|
||||||
throw new MalformedURLException(
|
throw new MalformedURLException(
|
||||||
"Expected 2dgalleries.com album format: "
|
"Expected 2dgalleries.com album format: "
|
||||||
+ "2dgalleries.com/browse/profile?id=####"
|
+ "2dgalleries.com/artist/..."
|
||||||
+ " Got: " + url);
|
+ " Got: " + url);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getURL(String userid, int offset) {
|
private String getURL(String userid, int offset) {
|
||||||
return "http://en.2dgalleries.com/browse/user-artworks?uid=" + userid
|
return "http://en.2dgalleries.com/artist/" + userid
|
||||||
|
+ "?timespan=4"
|
||||||
|
+ "&order=1"
|
||||||
|
+ "&catid=2"
|
||||||
+ "&offset=" + offset
|
+ "&offset=" + offset
|
||||||
+ "&ajx=1&pager=1&hr=1&pid=" + userid;
|
+ "&ajx=1&pager=1";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Document getFirstPage() throws IOException {
|
public Document getFirstPage() throws IOException {
|
||||||
|
try {
|
||||||
|
login();
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error("Failed to login", e);
|
||||||
|
}
|
||||||
String url = getURL(getGID(this.url), offset);
|
String url = getURL(getGID(this.url), offset);
|
||||||
return Http.url(url).get();
|
return Http.url(url)
|
||||||
|
.cookies(cookies)
|
||||||
|
.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Document getNextPage(Document doc) throws IOException {
|
public Document getNextPage(Document doc) throws IOException {
|
||||||
offset += 3;
|
offset += 24;
|
||||||
String url = getURL(getGID(this.url), offset);
|
String url = getURL(getGID(this.url), offset);
|
||||||
sleep(500);
|
sleep(500);
|
||||||
Document nextDoc = Http.url(url).get();
|
Document nextDoc = Http.url(url)
|
||||||
if (nextDoc.select(".noartwork").size() > 0) {
|
.cookies(cookies)
|
||||||
|
.get();
|
||||||
|
if (nextDoc.select("div.hcaption > img").size() == 0) {
|
||||||
throw new IOException("No more images to retrieve");
|
throw new IOException("No more images to retrieve");
|
||||||
}
|
}
|
||||||
return nextDoc;
|
return nextDoc;
|
||||||
@ -73,7 +91,7 @@ public class TwodgalleriesRipper extends AbstractHTMLRipper {
|
|||||||
@Override
|
@Override
|
||||||
public List<String> getURLsFromPage(Document doc) {
|
public List<String> getURLsFromPage(Document doc) {
|
||||||
List<String> imageURLs = new ArrayList<String>();
|
List<String> imageURLs = new ArrayList<String>();
|
||||||
for (Element thumb : doc.select("img")) {
|
for (Element thumb : doc.select("div.hcaption > img")) {
|
||||||
String image = thumb.attr("src");
|
String image = thumb.attr("src");
|
||||||
image = image.replace("/200H/", "/");
|
image = image.replace("/200H/", "/");
|
||||||
if (image.startsWith("//")) {
|
if (image.startsWith("//")) {
|
||||||
@ -90,4 +108,24 @@ public class TwodgalleriesRipper 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 login() throws IOException {
|
||||||
|
Response resp = Http.url(this.url).response();
|
||||||
|
cookies = resp.cookies();
|
||||||
|
String ctoken = resp.parse().select("form > input[name=ctoken]").first().attr("value");
|
||||||
|
|
||||||
|
Map<String,String> postdata = new HashMap<String,String>();
|
||||||
|
postdata.put("user[login]", new String(Base64.decode("cmlwbWU=")));
|
||||||
|
postdata.put("user[password]", new String(Base64.decode("cmlwcGVy")));
|
||||||
|
postdata.put("rememberme", "1");
|
||||||
|
postdata.put("ctoken", ctoken);
|
||||||
|
|
||||||
|
resp = Http.url("http://en.2dgalleries.com/account/login")
|
||||||
|
.referrer("http://en.2dgalleries.com/")
|
||||||
|
.cookies(cookies)
|
||||||
|
.data(postdata)
|
||||||
|
.method(Method.POST)
|
||||||
|
.response();
|
||||||
|
cookies = resp.cookies();
|
||||||
|
}
|
||||||
}
|
}
|
@ -21,7 +21,7 @@ import com.rarchives.ripme.utils.Utils;
|
|||||||
public class UpdateUtils {
|
public class UpdateUtils {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(UpdateUtils.class);
|
private static final Logger logger = Logger.getLogger(UpdateUtils.class);
|
||||||
private static final String DEFAULT_VERSION = "1.0.82";
|
private static final String DEFAULT_VERSION = "1.0.83";
|
||||||
private static final String updateJsonURL = "http://rarchives.com/ripme.json";
|
private static final String updateJsonURL = "http://rarchives.com/ripme.json";
|
||||||
private static final String updateJarURL = "http://rarchives.com/ripme.jar";
|
private static final String updateJarURL = "http://rarchives.com/ripme.jar";
|
||||||
private static final String mainFileName = "ripme.jar";
|
private static final String mainFileName = "ripme.jar";
|
||||||
|
Loading…
Reference in New Issue
Block a user