1.0.91 - Cleaning up ChanRipper, fix to work with anonib

This commit is contained in:
4pr0n 2014-11-14 06:03:13 -08:00
parent fa16954781
commit 707f64c516
3 changed files with 26 additions and 37 deletions

View File

@ -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.90</version> <version>1.0.91</version>
<name>ripme</name> <name>ripme</name>
<url>http://rip.rarchives.com</url> <url>http://rip.rarchives.com</url>
<properties> <properties>

View File

@ -18,18 +18,12 @@ import java.util.Arrays;
public class ChanRipper extends AbstractHTMLRipper { public class ChanRipper extends AbstractHTMLRipper {
//ArrayList<String> explicit_domains = new ArrayList<String>();
public static List<ChanSite> explicit_domains = Arrays.asList( public static List<ChanSite> explicit_domains = Arrays.asList(
//Tested (main boards)
//Untested (main boards)
new ChanSite(Arrays.asList("anon-ib.com")),
new ChanSite(Arrays.asList("boards.4chan.org"), Arrays.asList("4cdn.org")), new ChanSite(Arrays.asList("boards.4chan.org"), Arrays.asList("4cdn.org")),
//Tested (archives) new ChanSite(Arrays.asList("archive.moe"), Arrays.asList("data.archive.moe")),
new ChanSite(Arrays.asList("archive.moe"),Arrays.asList("data.archive.moe")), //4chan archive (successor of foolz archive) Archives: [ a / biz / c / co / diy / gd / i / int / jp / m / mlp / out / po / q / s4s / sci / sp / tg / tv / v / vg / vp / vr / wsg ] new ChanSite(Arrays.asList("4archive.org"), Arrays.asList("imgur.com")),
//Untested (archives)new ChanSite(Arrays.asList("anon-ib.com")), new ChanSite(Arrays.asList("archive.4plebs.org"), Arrays.asList("img.4plebs.org")),
new ChanSite(Arrays.asList("4archive.org"),Arrays.asList("imgur.com")), //4chan archive (on demand) new ChanSite(Arrays.asList("fgts.jp"), Arrays.asList("dat.fgts.jp"))
new ChanSite(Arrays.asList("archive.4plebs.org"),Arrays.asList("img.4plebs.org")), //4chan archive Archives: [ adv / f / hr / o / pol / s4s / tg / trv / tv / x ] Boards: [ plebs ]
new ChanSite(Arrays.asList("fgts.jp"),Arrays.asList("dat.fgts.jp")) //4chan archive Archives: [ asp / cm / h / hc / hm / n / p / r / s / soc / y ]
); );
public static List<String> url_piece_blacklist = Arrays.asList( public static List<String> url_piece_blacklist = Arrays.asList(
"=http", "=http",
@ -44,15 +38,13 @@ public class ChanRipper extends AbstractHTMLRipper {
public ChanRipper(URL url) throws IOException { public ChanRipper(URL url) throws IOException {
super(url); super(url);
for (ChanSite _chanSite : explicit_domains) { for (ChanSite _chanSite : explicit_domains) {
for (String host : _chanSite.domains) { if (_chanSite.domains.contains(url.getHost())) {
if (url.getHost().equals(host)) {
chanSite = _chanSite; chanSite = _chanSite;
generalChanSite = false; generalChanSite = false;
} }
} }
}
if (chanSite == null) { if (chanSite == null) {
chanSite = new ChanSite(Arrays.asList("url.getHost()")); chanSite = new ChanSite(Arrays.asList(url.getHost()));
} }
} }
@ -70,15 +62,11 @@ public class ChanRipper extends AbstractHTMLRipper {
@Override @Override
public boolean canRip(URL url) { public boolean canRip(URL url) {
//explicit_domains testing
for (ChanSite _chanSite : explicit_domains) { for (ChanSite _chanSite : explicit_domains) {
for (String host : _chanSite.domains) { if (_chanSite.domains.contains(url.getHost())) {
if (url.getHost().equals(host)) {
return true; return true;
} }
} }
}
//It'll fail further down the road.
return url.toExternalForm().contains("/res/") // Most chans return url.toExternalForm().contains("/res/") // Most chans
|| url.toExternalForm().contains("/thread/"); // 4chan, archive.moe || url.toExternalForm().contains("/thread/"); // 4chan, archive.moe
} }
@ -125,7 +113,7 @@ public class ChanRipper extends AbstractHTMLRipper {
if (!link.hasAttr("href")) { if (!link.hasAttr("href")) {
continue; continue;
} }
String href = link.attr("href"); String href = link.attr("href").trim();
//Check all blacklist items //Check all blacklist items
for (String blacklist_item : url_piece_blacklist) { for (String blacklist_item : url_piece_blacklist) {
@ -142,6 +130,7 @@ public class ChanRipper extends AbstractHTMLRipper {
} }
} }
} }
if(self_hosted||generalChanSite){ if(self_hosted||generalChanSite){
p = Pattern.compile("^.*\\.(jpg|jpeg|png|gif|apng|webp|tif|tiff|webm)$", Pattern.CASE_INSENSITIVE); p = Pattern.compile("^.*\\.(jpg|jpeg|png|gif|apng|webp|tif|tiff|webm)$", Pattern.CASE_INSENSITIVE);
m = p.matcher(href); m = p.matcher(href);

View File

@ -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.90"; private static final String DEFAULT_VERSION = "1.0.91";
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";