Skip to content

Commit

Permalink
1.0.34 - Anonib ripper, better updater #8
Browse files Browse the repository at this point in the history
  • Loading branch information
4pr0n committed May 4, 2014
1 parent a50198c commit 0ff9fa6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -4,7 +4,7 @@
<groupId>com.rarchives.ripme</groupId>
<artifactId>ripme</artifactId>
<packaging>jar</packaging>
<version>1.0.33</version>
<version>1.0.34</version>
<name>ripme</name>
<url>http://rip.rarchives.com</url>
<properties>
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/com/rarchives/ripme/ripper/rippers/ChanRipper.java
Expand Up @@ -38,6 +38,9 @@ public String getHost() {
@Override
public boolean canRip(URL url) {
// TODO Whitelist?
if (url.getHost().equals("anon-ib.com")) {
return true;
}
return url.getHost().contains("chan") &&
( url.toExternalForm().contains("/res/") // Most chans
|| url.toExternalForm().contains("/thread/")); // 4chan
Expand All @@ -53,10 +56,10 @@ public String getGID(URL url) throws MalformedURLException {

String u = url.toExternalForm();
if (u.contains("/res/")) {
p = Pattern.compile("^.*chan.*\\.[a-z]{2,3}/[a-zA-Z0-9]+/res/([0-9]+)(\\.html|\\.php)?.*$");
p = Pattern.compile("^.*(chan|anon-ib).*\\.[a-z]{2,3}/[a-zA-Z0-9]+/res/([0-9]+)(\\.html|\\.php)?.*$");
m = p.matcher(u);
if (m.matches()) {
return m.group(1);
return m.group(2);
}
}
else if (u.contains("/thread/")) {
Expand Down Expand Up @@ -91,6 +94,11 @@ public void rip() throws IOException {
logger.debug("Skipping link that does not contain /src/: " + link.attr("href"));
continue;
}
if (link.attr("href").contains("=http")
|| link.attr("href").contains("http://imgops.com/")) {
logger.debug("Skipping link that contains '=http' or 'imgops.com': " + link.attr("href"));
continue;
}
System.err.println("URL=" + link.attr("href"));
p = Pattern.compile("^.*\\.(jpg|jpeg|png|gif)$", Pattern.CASE_INSENSITIVE);
m = p.matcher(link.attr("href"));
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/com/rarchives/ripme/ui/UpdateUtils.java
Expand Up @@ -16,10 +16,12 @@
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

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.33";
private static final String DEFAULT_VERSION = "1.0.34";
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";
Expand Down Expand Up @@ -58,6 +60,9 @@ public static void updateProgram(JLabel configUpdateLabel) {
StringBuilder changeList = new StringBuilder();
for (int i = 0; i < jsonChangeList.length(); i++) {
String change = jsonChangeList.getString(i);
if (change.startsWith(UpdateUtils.getThisJarVersion() + ":")) {
break;
}
changeList.append("<br> + " + change);
}

Expand Down Expand Up @@ -136,7 +141,7 @@ private static void downloadJarAndLaunch(String updateJarURL)
Response response;
response = Jsoup.connect(updateJarURL)
.ignoreContentType(true)
.timeout(60000)
.timeout(Utils.getConfigInteger("download.timeout", 60 * 1000))
.maxBodySize(1024 * 1024 * 100)
.execute();
FileOutputStream out = new FileOutputStream(updateFileName);
Expand Down

0 comments on commit 0ff9fa6

Please sign in to comment.