ImageStash.com is permanently down: remove ImagestashRipper
This commit is contained in:
parent
fc3912585b
commit
dffe9a40aa
@ -1,87 +0,0 @@
|
||||
package com.rarchives.ripme.ripper.rippers;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import com.rarchives.ripme.ripper.AbstractJSONRipper;
|
||||
import com.rarchives.ripme.utils.Http;
|
||||
|
||||
public class ImagestashRipper extends AbstractJSONRipper {
|
||||
|
||||
private int page = 1;
|
||||
|
||||
public ImagestashRipper(URL url) throws IOException {
|
||||
super(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHost() {
|
||||
return "imagestash";
|
||||
}
|
||||
@Override
|
||||
public String getDomain() {
|
||||
return "imagestash.org";
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getFirstPage() throws IOException {
|
||||
String baseURL = "https://imagestash.org/images?tags="
|
||||
+ getGID(url)
|
||||
+ "&page=" + page;
|
||||
return Http.url(baseURL).getJSON();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getNextPage(JSONObject json) throws IOException {
|
||||
int count = json.getInt("count"),
|
||||
offset = json.getInt("offset"),
|
||||
total = json.getInt("total");
|
||||
if (count + offset >= total || json.getJSONArray("images").length() == 0) {
|
||||
throw new IOException("No more images");
|
||||
}
|
||||
sleep(1000);
|
||||
page++;
|
||||
return getFirstPage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getURLsFromJSON(JSONObject json) {
|
||||
List<String> imageURLs = new ArrayList<>();
|
||||
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 = "https://imagestash.org" + imageURL;
|
||||
}
|
||||
imageURLs.add(imageURL);
|
||||
}
|
||||
return imageURLs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadURL(URL url, int index) {
|
||||
addURLToDownload(url, getPrefix(index));
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package com.rarchives.ripme.tst.ripper.rippers;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import com.rarchives.ripme.ripper.rippers.ImagestashRipper;
|
||||
|
||||
public class ImagestashRipperTest extends RippersTest {
|
||||
/*
|
||||
public void testImagestashRip() throws IOException {
|
||||
ImagestashRipper ripper = new ImagestashRipper(new URL("https://imagestash.org/tag/everydayuncensor"));
|
||||
testRipper(ripper);
|
||||
}
|
||||
*/
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user