Reddit ripper now gets erome links
This commit is contained in:
parent
acb6356b94
commit
0f61dd00f0
@ -4,10 +4,13 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import com.rarchives.ripme.ripper.AbstractRipper;
|
||||||
|
import com.rarchives.ripme.ripper.rippers.video.GfycatRipper;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.json.JSONTokener;
|
import org.json.JSONTokener;
|
||||||
@ -17,6 +20,9 @@ import com.rarchives.ripme.ui.UpdateUtils;
|
|||||||
import com.rarchives.ripme.utils.Http;
|
import com.rarchives.ripme.utils.Http;
|
||||||
import com.rarchives.ripme.utils.RipUtils;
|
import com.rarchives.ripme.utils.RipUtils;
|
||||||
import com.rarchives.ripme.utils.Utils;
|
import com.rarchives.ripme.utils.Utils;
|
||||||
|
import org.jsoup.Jsoup;
|
||||||
|
import org.jsoup.nodes.Document;
|
||||||
|
import org.jsoup.nodes.Element;
|
||||||
|
|
||||||
public class RedditRipper extends AlbumRipper {
|
public class RedditRipper extends AlbumRipper {
|
||||||
|
|
||||||
|
@ -9,19 +9,18 @@ import java.util.List;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import com.rarchives.ripme.ripper.AbstractRipper;
|
||||||
|
import com.rarchives.ripme.ripper.rippers.EroShareRipper;
|
||||||
|
import com.rarchives.ripme.ripper.rippers.EromeRipper;
|
||||||
|
import com.rarchives.ripme.ripper.rippers.ImgurRipper;
|
||||||
|
import com.rarchives.ripme.ripper.rippers.VidbleRipper;
|
||||||
|
import com.rarchives.ripme.ripper.rippers.video.GfycatRipper;
|
||||||
import org.apache.commons.lang.math.NumberUtils;
|
import org.apache.commons.lang.math.NumberUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Document;
|
||||||
import org.jsoup.nodes.Element;
|
import org.jsoup.nodes.Element;
|
||||||
|
|
||||||
import com.rarchives.ripme.ripper.AbstractRipper;
|
|
||||||
import com.rarchives.ripme.ripper.rippers.ImgurRipper;
|
|
||||||
import com.rarchives.ripme.ripper.rippers.ImgurRipper.ImgurAlbum;
|
|
||||||
import com.rarchives.ripme.ripper.rippers.ImgurRipper.ImgurImage;
|
|
||||||
import com.rarchives.ripme.ripper.rippers.VidbleRipper;
|
|
||||||
import com.rarchives.ripme.ripper.rippers.video.GfycatRipper;
|
|
||||||
import com.rarchives.ripme.ripper.rippers.EroShareRipper;
|
|
||||||
|
|
||||||
public class RipUtils {
|
public class RipUtils {
|
||||||
private static final Logger logger = Logger.getLogger(RipUtils.class);
|
private static final Logger logger = Logger.getLogger(RipUtils.class);
|
||||||
@ -35,8 +34,8 @@ public class RipUtils {
|
|||||||
&& url.toExternalForm().contains("imgur.com/a/")) {
|
&& url.toExternalForm().contains("imgur.com/a/")) {
|
||||||
try {
|
try {
|
||||||
logger.debug("Fetching imgur album at " + url);
|
logger.debug("Fetching imgur album at " + url);
|
||||||
ImgurAlbum imgurAlbum = ImgurRipper.getImgurAlbum(url);
|
ImgurRipper.ImgurAlbum imgurAlbum = ImgurRipper.getImgurAlbum(url);
|
||||||
for (ImgurImage imgurImage : imgurAlbum.images) {
|
for (ImgurRipper.ImgurImage imgurImage : imgurAlbum.images) {
|
||||||
logger.debug("Got imgur image: " + imgurImage.url);
|
logger.debug("Got imgur image: " + imgurImage.url);
|
||||||
result.add(imgurImage.url);
|
result.add(imgurImage.url);
|
||||||
}
|
}
|
||||||
@ -49,8 +48,8 @@ public class RipUtils {
|
|||||||
// Imgur image series.
|
// Imgur image series.
|
||||||
try {
|
try {
|
||||||
logger.debug("Fetching imgur series at " + url);
|
logger.debug("Fetching imgur series at " + url);
|
||||||
ImgurAlbum imgurAlbum = ImgurRipper.getImgurSeries(url);
|
ImgurRipper.ImgurAlbum imgurAlbum = ImgurRipper.getImgurSeries(url);
|
||||||
for (ImgurImage imgurImage : imgurAlbum.images) {
|
for (ImgurRipper.ImgurImage imgurImage : imgurAlbum.images) {
|
||||||
logger.debug("Got imgur image: " + imgurImage.url);
|
logger.debug("Got imgur image: " + imgurImage.url);
|
||||||
result.add(imgurImage.url);
|
result.add(imgurImage.url);
|
||||||
}
|
}
|
||||||
@ -91,6 +90,21 @@ public class RipUtils {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (url.toExternalForm().contains("erome.com")) {
|
||||||
|
try {
|
||||||
|
logger.info("Getting eroshare album " + url);
|
||||||
|
EromeRipper r = new EromeRipper(url);
|
||||||
|
Document tempDoc = r.getFirstPage();
|
||||||
|
for (String u : r.getURLsFromPage(tempDoc)) {
|
||||||
|
result.add(new URL(u));
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
// Do nothing
|
||||||
|
logger.warn("Exception while retrieving eroshare page:", e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
Pattern p = Pattern.compile("https?://i.reddituploads.com/([a-zA-Z0-9]+)\\?.*");
|
Pattern p = Pattern.compile("https?://i.reddituploads.com/([a-zA-Z0-9]+)\\?.*");
|
||||||
Matcher m = p.matcher(url.toExternalForm());
|
Matcher m = p.matcher(url.toExternalForm());
|
||||||
if (m.matches()) {
|
if (m.matches()) {
|
||||||
@ -122,8 +136,8 @@ public class RipUtils {
|
|||||||
try {
|
try {
|
||||||
// Fetch the page
|
// Fetch the page
|
||||||
Document doc = Jsoup.connect(url.toExternalForm())
|
Document doc = Jsoup.connect(url.toExternalForm())
|
||||||
.userAgent(AbstractRipper.USER_AGENT)
|
.userAgent(AbstractRipper.USER_AGENT)
|
||||||
.get();
|
.get();
|
||||||
for (Element el : doc.select("meta")) {
|
for (Element el : doc.select("meta")) {
|
||||||
if (el.attr("name").equals("twitter:image:src")) {
|
if (el.attr("name").equals("twitter:image:src")) {
|
||||||
result.add(new URL(el.attr("content")));
|
result.add(new URL(el.attr("content")));
|
||||||
|
Loading…
Reference in New Issue
Block a user