1
0
mirror of https://github.com/RipMeApp/ripme.git synced 2025-08-28 08:10:11 +02:00

Fixes TheChive bug so that it can now rip gifs.

This commit is contained in:
Kevin Jiang
2018-10-13 20:48:26 -04:00
parent 1a25334445
commit 39ba3349bb

View File

@@ -1,4 +1,3 @@
package com.rarchives.ripme.ripper.rippers;
import com.rarchives.ripme.ripper.AbstractHTMLRipper;
@@ -17,7 +16,7 @@ import org.jsoup.nodes.Element;
public class ThechiveRipper extends AbstractHTMLRipper {
public ThechiveRipper(URL url) throws IOException {
super(url);
super(url);
}
@Override
@@ -38,8 +37,8 @@ public class ThechiveRipper extends AbstractHTMLRipper {
boolean isTag = false;
return m.group(1);
}
throw new MalformedURLException("Expected thechive.com URL format: " +
"thechive.com/YEAR/MONTH/DAY/POSTTITLE/ - got " + url + " instead");
throw new MalformedURLException("Expected thechive.com URL format: "
+ "thechive.com/YEAR/MONTH/DAY/POSTTITLE/ - got " + url + " instead");
}
@Override
@@ -52,11 +51,19 @@ public class ThechiveRipper extends AbstractHTMLRipper {
public List<String> getURLsFromPage(Document doc) {
List<String> result = new ArrayList<>();
for (Element el : doc.select("img.attachment-gallery-item-full")) {
String imageSource = el.attr("src");
String imageSource;
if (el.attr("data-gifsrc").isEmpty()) { //If it's not a gif
imageSource = el.attr("src");
} else { //If it is a gif
imageSource = el.attr("data-gifsrc") //from data-gifsrc attribute
.replaceAll("\\?w=\\d{3}", ""); //remove the width modifier at the end to get highest resolution
//May need to replace the regex's {3} later on if website starts giving higher-res photos by default.
}
// We replace thumbs with resizes so we can the full sized images
imageSource = imageSource.replace("thumbs", "resizes");
result.add(imageSource);
}
}
return result;
}
@@ -65,5 +72,4 @@ public class ThechiveRipper extends AbstractHTMLRipper {
addURLToDownload(url, getPrefix(index));
}
}