1.0.43 - Added Modelmayhem ripper #8
This commit is contained in:
parent
3148d10be3
commit
863f722f9c
2
pom.xml
2
pom.xml
@ -4,7 +4,7 @@
|
||||
<groupId>com.rarchives.ripme</groupId>
|
||||
<artifactId>ripme</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.0.42</version>
|
||||
<version>1.0.43</version>
|
||||
<name>ripme</name>
|
||||
<url>http://rip.rarchives.com</url>
|
||||
<properties>
|
||||
|
@ -0,0 +1,128 @@
|
||||
package com.rarchives.ripme.ripper.rippers;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.jsoup.Connection.Method;
|
||||
import org.jsoup.Connection.Response;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
|
||||
import com.rarchives.ripme.ripper.AlbumRipper;
|
||||
import com.rarchives.ripme.ui.RipStatusMessage.STATUS;
|
||||
|
||||
public class ModelmayhemRipper extends AlbumRipper {
|
||||
|
||||
private static final String DOMAIN = "modelmayhem.com",
|
||||
HOST = "modelmayhem";
|
||||
private static final Logger logger = Logger.getLogger(ModelmayhemRipper.class);
|
||||
|
||||
public ModelmayhemRipper(URL url) throws IOException {
|
||||
super(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRip(URL url) {
|
||||
return (url.getHost().endsWith(DOMAIN));
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL sanitizeURL(URL url) throws MalformedURLException {
|
||||
return url;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rip() throws IOException {
|
||||
Map<String,String> cookies = null,
|
||||
postData = new HashMap<String,String>();
|
||||
String gid = getGID(this.url),
|
||||
ref = "http://www.modelmayhem.com/" + gid;
|
||||
|
||||
Response resp = null;
|
||||
String theurl = "http://www.modelmayhem.com/" + gid;
|
||||
logger.info("Loading " + theurl);
|
||||
resp = Jsoup.connect(theurl)
|
||||
.timeout(5000)
|
||||
.referrer("")
|
||||
.userAgent(USER_AGENT)
|
||||
.method(Method.GET)
|
||||
.execute();
|
||||
cookies = resp.cookies();
|
||||
|
||||
resp = Jsoup.connect("http://www.modelmayhem.com/includes/js/auth.php")
|
||||
.cookies(cookies)
|
||||
.referrer(ref)
|
||||
.userAgent(USER_AGENT)
|
||||
.method(Method.GET)
|
||||
.execute();
|
||||
String authText = resp.parse().html();
|
||||
String mmservice = authText.substring(authText.indexOf("token = '") + 9);
|
||||
mmservice = mmservice.substring(0, mmservice.indexOf("'"));
|
||||
|
||||
cookies.putAll(resp.cookies());
|
||||
|
||||
cookies.put("worksafe", "0");
|
||||
theurl = "http://www.modelmayhem.com/services/photo_viewer/albums/" + gid;
|
||||
postData.put("MMSERVICE", mmservice);
|
||||
resp = Jsoup.connect(theurl)
|
||||
.data(postData)
|
||||
.cookies(cookies)
|
||||
.referrer(ref)
|
||||
.userAgent(USER_AGENT)
|
||||
.method(Method.POST)
|
||||
.execute();
|
||||
cookies.putAll(resp.cookies());
|
||||
|
||||
theurl = "http://www.modelmayhem.com/services/photo_viewer/pictures/" + gid + "/0/0/1/0";
|
||||
this.sendUpdate(STATUS.LOADING_RESOURCE, theurl);
|
||||
logger.info("Loading " + theurl);
|
||||
resp = Jsoup.connect(theurl)
|
||||
.data(postData)
|
||||
.cookies(cookies)
|
||||
.referrer(ref)
|
||||
.userAgent(USER_AGENT)
|
||||
.method(Method.POST)
|
||||
.execute();
|
||||
|
||||
Document doc = resp.parse();
|
||||
String jsonText = doc.body().html();
|
||||
jsonText = jsonText.replace(""", "\"");
|
||||
System.err.println(jsonText);
|
||||
JSONObject json = new JSONObject(jsonText);
|
||||
JSONArray pictures = json.getJSONArray("pictures");
|
||||
for (int i = 0; i < pictures.length(); i++) {
|
||||
JSONObject picture = pictures.getJSONObject(i);
|
||||
String bigImage = picture.getString("big_image");
|
||||
if (bigImage.trim().equals("")) {
|
||||
logger.info("Got empty image for " + picture.toString(2));
|
||||
continue;
|
||||
}
|
||||
addURLToDownload(new URL(bigImage), String.format("%03d_", i + 1));
|
||||
}
|
||||
waitForThreads();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHost() {
|
||||
return HOST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGID(URL url) throws MalformedURLException {
|
||||
Pattern p = Pattern.compile("^https?://[w.]*modelmayhem.com.*/([0-9]+)/?.*$");
|
||||
Matcher m = p.matcher(url.toExternalForm());
|
||||
if (m.matches()) {
|
||||
return m.group(1);
|
||||
}
|
||||
throw new MalformedURLException("Modelmayhem user ID not found in " + url + ", expected http://modelmayhem.com/userid");
|
||||
}
|
||||
|
||||
}
|
@ -21,7 +21,7 @@ import com.rarchives.ripme.utils.Utils;
|
||||
public class UpdateUtils {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(UpdateUtils.class);
|
||||
private static final String DEFAULT_VERSION = "1.0.42";
|
||||
private static final String DEFAULT_VERSION = "1.0.43";
|
||||
private static final String updateJsonURL = "http://rarchives.com/ripme.json";
|
||||
private static final String updateJarURL = "http://rarchives.com/ripme.jar";
|
||||
private static final String mainFileName = "ripme.jar";
|
||||
|
Loading…
Reference in New Issue
Block a user