mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-08-29 00:29:55 +02:00
Fixes TheChive bug so that it can now rip gifs.
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
package com.rarchives.ripme.ripper.rippers;
|
package com.rarchives.ripme.ripper.rippers;
|
||||||
|
|
||||||
import com.rarchives.ripme.ripper.AbstractHTMLRipper;
|
import com.rarchives.ripme.ripper.AbstractHTMLRipper;
|
||||||
@@ -17,7 +16,7 @@ import org.jsoup.nodes.Element;
|
|||||||
public class ThechiveRipper extends AbstractHTMLRipper {
|
public class ThechiveRipper extends AbstractHTMLRipper {
|
||||||
|
|
||||||
public ThechiveRipper(URL url) throws IOException {
|
public ThechiveRipper(URL url) throws IOException {
|
||||||
super(url);
|
super(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -38,8 +37,8 @@ public class ThechiveRipper extends AbstractHTMLRipper {
|
|||||||
boolean isTag = false;
|
boolean isTag = false;
|
||||||
return m.group(1);
|
return m.group(1);
|
||||||
}
|
}
|
||||||
throw new MalformedURLException("Expected thechive.com URL format: " +
|
throw new MalformedURLException("Expected thechive.com URL format: "
|
||||||
"thechive.com/YEAR/MONTH/DAY/POSTTITLE/ - got " + url + " instead");
|
+ "thechive.com/YEAR/MONTH/DAY/POSTTITLE/ - got " + url + " instead");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -52,11 +51,19 @@ public class ThechiveRipper extends AbstractHTMLRipper {
|
|||||||
public List<String> getURLsFromPage(Document doc) {
|
public List<String> getURLsFromPage(Document doc) {
|
||||||
List<String> result = new ArrayList<>();
|
List<String> result = new ArrayList<>();
|
||||||
for (Element el : doc.select("img.attachment-gallery-item-full")) {
|
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
|
// We replace thumbs with resizes so we can the full sized images
|
||||||
imageSource = imageSource.replace("thumbs", "resizes");
|
imageSource = imageSource.replace("thumbs", "resizes");
|
||||||
result.add(imageSource);
|
result.add(imageSource);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,5 +72,4 @@ public class ThechiveRipper extends AbstractHTMLRipper {
|
|||||||
addURLToDownload(url, getPrefix(index));
|
addURLToDownload(url, getPrefix(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user