1.0.48 - Imagestash.org /tag/ ripper #8
This commit is contained in:
parent
2947c3d56b
commit
0073de17ea
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.47</version>
|
<version>1.0.48</version>
|
||||||
<name>ripme</name>
|
<name>ripme</name>
|
||||||
<url>http://rip.rarchives.com</url>
|
<url>http://rip.rarchives.com</url>
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -25,10 +25,7 @@ public class ImagearnRipper extends AlbumRipper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canRip(URL url) {
|
public boolean canRip(URL url) {
|
||||||
if (!url.getHost().endsWith(DOMAIN)) {
|
return url.getHost().endsWith(DOMAIN);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public URL sanitizeURL(URL url) throws MalformedURLException {
|
public URL sanitizeURL(URL url) throws MalformedURLException {
|
||||||
|
@ -0,0 +1,107 @@
|
|||||||
|
package com.rarchives.ripme.ripper.rippers;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
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.Jsoup;
|
||||||
|
|
||||||
|
import com.rarchives.ripme.ripper.AlbumRipper;
|
||||||
|
import com.rarchives.ripme.ui.RipStatusMessage.STATUS;
|
||||||
|
import com.rarchives.ripme.utils.Utils;
|
||||||
|
|
||||||
|
public class ImagestashRipper extends AlbumRipper {
|
||||||
|
|
||||||
|
private static final String DOMAIN = "imagestash.org",
|
||||||
|
HOST = "imagestash";
|
||||||
|
private static final Logger logger = Logger.getLogger(ImagestashRipper.class);
|
||||||
|
|
||||||
|
public ImagestashRipper(URL url) throws IOException {
|
||||||
|
super(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canRip(URL url) {
|
||||||
|
System.err.println(url.getHost() +"/"+DOMAIN);
|
||||||
|
return url.getHost().equals(DOMAIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
public URL sanitizeURL(URL url) throws MalformedURLException {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void rip() throws IOException {
|
||||||
|
// Given URL: https://imagestash.org/tag/everydayuncensor
|
||||||
|
// GID: "everydayuncensor"
|
||||||
|
// JSON URL: https://imagestash.org/images?tags=everydayuncensor&page=1
|
||||||
|
String baseURL = "https://imagestash.org/images?tags=" + getGID(this.url);
|
||||||
|
int page = 0, index = 0;
|
||||||
|
while (true) {
|
||||||
|
page++;
|
||||||
|
String nextURL = baseURL + "&page=" + page;
|
||||||
|
logger.info("[ ] Retrieving " + nextURL);
|
||||||
|
sendUpdate(STATUS.LOADING_RESOURCE, nextURL);
|
||||||
|
String jsonText = Jsoup.connect(nextURL)
|
||||||
|
.ignoreContentType(true)
|
||||||
|
.userAgent(USER_AGENT)
|
||||||
|
.method(Method.GET)
|
||||||
|
.execute()
|
||||||
|
.body();
|
||||||
|
logger.info(jsonText);
|
||||||
|
JSONObject json = new JSONObject(jsonText);
|
||||||
|
JSONArray images = json.getJSONArray("images");
|
||||||
|
for (int i = 0; i < images.length(); i++) {
|
||||||
|
JSONObject image = images.getJSONObject(i);
|
||||||
|
String imageURL = image.getString("src");
|
||||||
|
if (imageURL.startsWith("/")) {
|
||||||
|
imageURL = "http://imagestash.org" + imageURL;
|
||||||
|
}
|
||||||
|
index += 1;
|
||||||
|
String prefix = "";
|
||||||
|
if (Utils.getConfigBoolean("download.save_order", true)) {
|
||||||
|
prefix = String.format("%03d_", index);
|
||||||
|
}
|
||||||
|
addURLToDownload(new URL(imageURL), prefix);
|
||||||
|
}
|
||||||
|
// Check if there are more images to fetch
|
||||||
|
int count = json.getInt("count"),
|
||||||
|
offset = json.getInt("offset"),
|
||||||
|
total = json.getInt("total");
|
||||||
|
if (count + offset >= total || images.length() == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Wait a bit
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
logger.error("Interrupted while waiting to load next page", e);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
waitForThreads();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHost() {
|
||||||
|
return HOST;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getGID(URL url) throws MalformedURLException {
|
||||||
|
Pattern p = Pattern.compile("^.*imagestash.org/tag/([a-zA-Z0-9\\-_]+)$");
|
||||||
|
Matcher m = p.matcher(url.toExternalForm());
|
||||||
|
if (m.matches()) {
|
||||||
|
return m.group(1);
|
||||||
|
}
|
||||||
|
throw new MalformedURLException(
|
||||||
|
"Expected imagestash.org tag formats: "
|
||||||
|
+ "imagestash.org/tag/tagname"
|
||||||
|
+ " Got: " + url);
|
||||||
|
}
|
||||||
|
}
|
@ -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.47";
|
private static final String DEFAULT_VERSION = "1.0.48";
|
||||||
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