Skip to content

Commit 863f722

Browse files
committed
1.0.43 - Added Modelmayhem ripper #8
1 parent 3148d10 commit 863f722

3 files changed

Lines changed: 130 additions & 2 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<groupId>com.rarchives.ripme</groupId>
55
<artifactId>ripme</artifactId>
66
<packaging>jar</packaging>
7-
<version>1.0.42</version>
7+
<version>1.0.43</version>
88
<name>ripme</name>
99
<url>http://rip.rarchives.com</url>
1010
<properties>
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
package com.rarchives.ripme.ripper.rippers;
2+
3+
import java.io.IOException;
4+
import java.net.MalformedURLException;
5+
import java.net.URL;
6+
import java.util.HashMap;
7+
import java.util.Map;
8+
import java.util.regex.Matcher;
9+
import java.util.regex.Pattern;
10+
11+
import org.apache.log4j.Logger;
12+
import org.json.JSONArray;
13+
import org.json.JSONObject;
14+
import org.jsoup.Connection.Method;
15+
import org.jsoup.Connection.Response;
16+
import org.jsoup.Jsoup;
17+
import org.jsoup.nodes.Document;
18+
19+
import com.rarchives.ripme.ripper.AlbumRipper;
20+
import com.rarchives.ripme.ui.RipStatusMessage.STATUS;
21+
22+
public class ModelmayhemRipper extends AlbumRipper {
23+
24+
private static final String DOMAIN = "modelmayhem.com",
25+
HOST = "modelmayhem";
26+
private static final Logger logger = Logger.getLogger(ModelmayhemRipper.class);
27+
28+
public ModelmayhemRipper(URL url) throws IOException {
29+
super(url);
30+
}
31+
32+
@Override
33+
public boolean canRip(URL url) {
34+
return (url.getHost().endsWith(DOMAIN));
35+
}
36+
37+
@Override
38+
public URL sanitizeURL(URL url) throws MalformedURLException {
39+
return url;
40+
}
41+
42+
@Override
43+
public void rip() throws IOException {
44+
Map<String,String> cookies = null,
45+
postData = new HashMap<String,String>();
46+
String gid = getGID(this.url),
47+
ref = "http://www.modelmayhem.com/" + gid;
48+
49+
Response resp = null;
50+
String theurl = "http://www.modelmayhem.com/" + gid;
51+
logger.info("Loading " + theurl);
52+
resp = Jsoup.connect(theurl)
53+
.timeout(5000)
54+
.referrer("")
55+
.userAgent(USER_AGENT)
56+
.method(Method.GET)
57+
.execute();
58+
cookies = resp.cookies();
59+
60+
resp = Jsoup.connect("http://www.modelmayhem.com/includes/js/auth.php")
61+
.cookies(cookies)
62+
.referrer(ref)
63+
.userAgent(USER_AGENT)
64+
.method(Method.GET)
65+
.execute();
66+
String authText = resp.parse().html();
67+
String mmservice = authText.substring(authText.indexOf("token = '") + 9);
68+
mmservice = mmservice.substring(0, mmservice.indexOf("'"));
69+
70+
cookies.putAll(resp.cookies());
71+
72+
cookies.put("worksafe", "0");
73+
theurl = "http://www.modelmayhem.com/services/photo_viewer/albums/" + gid;
74+
postData.put("MMSERVICE", mmservice);
75+
resp = Jsoup.connect(theurl)
76+
.data(postData)
77+
.cookies(cookies)
78+
.referrer(ref)
79+
.userAgent(USER_AGENT)
80+
.method(Method.POST)
81+
.execute();
82+
cookies.putAll(resp.cookies());
83+
84+
theurl = "http://www.modelmayhem.com/services/photo_viewer/pictures/" + gid + "/0/0/1/0";
85+
this.sendUpdate(STATUS.LOADING_RESOURCE, theurl);
86+
logger.info("Loading " + theurl);
87+
resp = Jsoup.connect(theurl)
88+
.data(postData)
89+
.cookies(cookies)
90+
.referrer(ref)
91+
.userAgent(USER_AGENT)
92+
.method(Method.POST)
93+
.execute();
94+
95+
Document doc = resp.parse();
96+
String jsonText = doc.body().html();
97+
jsonText = jsonText.replace("&quot;", "\"");
98+
System.err.println(jsonText);
99+
JSONObject json = new JSONObject(jsonText);
100+
JSONArray pictures = json.getJSONArray("pictures");
101+
for (int i = 0; i < pictures.length(); i++) {
102+
JSONObject picture = pictures.getJSONObject(i);
103+
String bigImage = picture.getString("big_image");
104+
if (bigImage.trim().equals("")) {
105+
logger.info("Got empty image for " + picture.toString(2));
106+
continue;
107+
}
108+
addURLToDownload(new URL(bigImage), String.format("%03d_", i + 1));
109+
}
110+
waitForThreads();
111+
}
112+
113+
@Override
114+
public String getHost() {
115+
return HOST;
116+
}
117+
118+
@Override
119+
public String getGID(URL url) throws MalformedURLException {
120+
Pattern p = Pattern.compile("^https?://[w.]*modelmayhem.com.*/([0-9]+)/?.*$");
121+
Matcher m = p.matcher(url.toExternalForm());
122+
if (m.matches()) {
123+
return m.group(1);
124+
}
125+
throw new MalformedURLException("Modelmayhem user ID not found in " + url + ", expected http://modelmayhem.com/userid");
126+
}
127+
128+
}

src/main/java/com/rarchives/ripme/ui/UpdateUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
public class UpdateUtils {
2222

2323
private static final Logger logger = Logger.getLogger(UpdateUtils.class);
24-
private static final String DEFAULT_VERSION = "1.0.42";
24+
private static final String DEFAULT_VERSION = "1.0.43";
2525
private static final String updateJsonURL = "http://rarchives.com/ripme.json";
2626
private static final String updateJarURL = "http://rarchives.com/ripme.jar";
2727
private static final String mainFileName = "ripme.jar";

0 commit comments

Comments
 (0)