Skip to content

Commit 53df6ca

Browse files
committed
1.0.71 - Fuskator ripper for #8
1 parent 349804c commit 53df6ca

4 files changed

Lines changed: 110 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.70</version>
7+
<version>1.0.71</version>
88
<name>ripme</name>
99
<url>http://rip.rarchives.com</url>
1010
<properties>
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
package com.rarchives.ripme.ripper.rippers;
2+
3+
import java.io.IOException;
4+
import java.io.UnsupportedEncodingException;
5+
import java.net.MalformedURLException;
6+
import java.net.URL;
7+
import java.net.URLDecoder;
8+
import java.util.ArrayList;
9+
import java.util.List;
10+
import java.util.regex.Matcher;
11+
import java.util.regex.Pattern;
12+
13+
import org.jsoup.nodes.Document;
14+
15+
import com.rarchives.ripme.ripper.AbstractHTMLRipper;
16+
import com.rarchives.ripme.utils.Http;
17+
import com.rarchives.ripme.utils.Utils;
18+
19+
public class FuskatorRipper extends AbstractHTMLRipper {
20+
21+
public FuskatorRipper(URL url) throws IOException {
22+
super(url);
23+
}
24+
25+
@Override
26+
public String getHost() {
27+
return "fuskator";
28+
}
29+
@Override
30+
public String getDomain() {
31+
return "fuskator.com";
32+
}
33+
34+
@Override
35+
public URL sanitizeURL(URL url) throws MalformedURLException {
36+
String u = url.toExternalForm();
37+
if (u.contains("/thumbs/")) {
38+
u = u.replace("/thumbs/", "/full/");
39+
}
40+
return new URL(u);
41+
}
42+
43+
@Override
44+
public String getGID(URL url) throws MalformedURLException {
45+
Pattern p = Pattern.compile("^.*fuskator.com/full/([a-zA-Z0-9\\-]+).*$");
46+
Matcher m = p.matcher(url.toExternalForm());
47+
if (m.matches()) {
48+
return m.group(1);
49+
}
50+
throw new MalformedURLException(
51+
"Expected fuskator.com gallery formats: "
52+
+ "fuskator.com/full/id/..."
53+
+ " Got: " + url);
54+
}
55+
56+
@Override
57+
public Document getFirstPage() throws IOException {
58+
return Http.url(url).get();
59+
}
60+
61+
@Override
62+
public List<String> getURLsFromPage(Document doc) {
63+
List<String> imageURLs = new ArrayList<String>();
64+
String html = doc.html();
65+
// Get "baseUrl"
66+
String baseUrl = Utils.between(html, "var baseUrl = unescape('", "'").get(0);
67+
try {
68+
baseUrl = URLDecoder.decode(baseUrl, "UTF-8");
69+
} catch (UnsupportedEncodingException e) {
70+
logger.warn("Error while decoding " + baseUrl, e);
71+
}
72+
if (baseUrl.startsWith("//")) {
73+
baseUrl = "http:" + baseUrl;
74+
}
75+
// Iterate over images
76+
for (String filename : Utils.between(html, ".src=baseUrl+'", "'")) {
77+
imageURLs.add(baseUrl + filename);
78+
}
79+
return imageURLs;
80+
}
81+
82+
@Override
83+
public void downloadURL(URL url, int index) {
84+
addURLToDownload(url, getPrefix(index));
85+
}
86+
}

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.70";
24+
private static final String DEFAULT_VERSION = "1.0.71";
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";

src/main/java/com/rarchives/ripme/utils/Utils.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,4 +333,26 @@ public static void configureLogger() {
333333
logger.info("Loaded " + logFile);
334334
}
335335

336+
/**
337+
* Gets list of strings between two strings.
338+
* @param fullText Text to retrieve from.
339+
* @param start String that precedes the desired text
340+
* @param finish String that follows the desired text
341+
* @return List of all strings that are between 'start' and 'finish'
342+
*/
343+
public static List<String> between(String fullText, String start, String finish) {
344+
List<String> result = new ArrayList<String>();
345+
int i, j;
346+
i = fullText.indexOf(start);
347+
while (i >= 0) {
348+
i += start.length();
349+
j = fullText.indexOf(finish, i);
350+
if (j < 0) {
351+
break;
352+
}
353+
result.add(fullText.substring(i, j));
354+
i = fullText.indexOf(start, j + finish.length());
355+
}
356+
return result;
357+
}
336358
}

0 commit comments

Comments
 (0)