1.0.70 Reddit ripper retrieves gfycat and vidble links
As requested in #8
This commit is contained in:
parent
86ae583da6
commit
349804c968
2
pom.xml
2
pom.xml
@ -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.69</version>
|
<version>1.0.70</version>
|
||||||
<name>ripme</name>
|
<name>ripme</name>
|
||||||
<url>http://rip.rarchives.com</url>
|
<url>http://rip.rarchives.com</url>
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -3,23 +3,18 @@ package com.rarchives.ripme.ripper.rippers;
|
|||||||
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.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Document;
|
||||||
import org.jsoup.select.Elements;
|
import org.jsoup.select.Elements;
|
||||||
|
|
||||||
import com.rarchives.ripme.ripper.AlbumRipper;
|
import com.rarchives.ripme.ripper.AbstractHTMLRipper;
|
||||||
import com.rarchives.ripme.ui.RipStatusMessage.STATUS;
|
|
||||||
import com.rarchives.ripme.utils.Http;
|
import com.rarchives.ripme.utils.Http;
|
||||||
import com.rarchives.ripme.utils.Utils;
|
|
||||||
|
|
||||||
public class VidbleRipper extends AlbumRipper {
|
public class VidbleRipper extends AbstractHTMLRipper {
|
||||||
|
|
||||||
private static final String DOMAIN = "vidble.com",
|
|
||||||
HOST = "vidble";
|
|
||||||
|
|
||||||
private Document albumDoc = null;
|
|
||||||
|
|
||||||
public VidbleRipper(URL url) throws IOException {
|
public VidbleRipper(URL url) throws IOException {
|
||||||
super(url);
|
super(url);
|
||||||
@ -27,7 +22,11 @@ public class VidbleRipper extends AlbumRipper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHost() {
|
public String getHost() {
|
||||||
return HOST;
|
return "vidble";
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getDomain() {
|
||||||
|
return "vidble.com";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -46,44 +45,40 @@ public class VidbleRipper extends AlbumRipper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void rip() throws IOException {
|
public Document getFirstPage() throws IOException {
|
||||||
logger.info("Retrieving " + this.url);
|
return Http.url(url).get();
|
||||||
sendUpdate(STATUS.LOADING_RESOURCE, this.url.toExternalForm());
|
}
|
||||||
if (albumDoc == null) {
|
|
||||||
albumDoc = Http.url(this.url).get();
|
@Override
|
||||||
}
|
public List<String> getURLsFromPage(Document doc) {
|
||||||
Elements els = albumDoc.select("#ContentPlaceHolder1_thumbs");
|
return getURLsFromPageStatic(doc);
|
||||||
if (els.size() == 0) {
|
}
|
||||||
throw new IOException("No thumbnails found at " + this.url);
|
|
||||||
}
|
private static List<String> getURLsFromPageStatic(Document doc) {
|
||||||
int index = 0;
|
List<String> imageURLs = new ArrayList<String>();
|
||||||
String thumbs = els.get(0).attr("value");
|
Elements els = doc.select("#ContentPlaceHolder1_thumbs");
|
||||||
|
String thumbs = els.first().attr("value");
|
||||||
for (String thumb : thumbs.split(",")) {
|
for (String thumb : thumbs.split(",")) {
|
||||||
if (thumb.trim().equals("")) {
|
if (thumb.trim().equals("")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
thumb = thumb.replaceAll("_[a-zA-Z]{3,5}", "");
|
thumb = thumb.replaceAll("_[a-zA-Z]{3,5}", "");
|
||||||
String image = "http://vidble.com/" + thumb;
|
imageURLs.add("http://vidble.com/" + thumb);
|
||||||
index += 1;
|
|
||||||
String prefix = "";
|
|
||||||
if (Utils.getConfigBoolean("download.save_order", true)) {
|
|
||||||
prefix = String.format("%03d_", index);
|
|
||||||
}
|
|
||||||
addURLToDownload(new URL(image), prefix);
|
|
||||||
}
|
}
|
||||||
waitForThreads();
|
return imageURLs;
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canRip(URL url) {
|
|
||||||
if (!url.getHost().endsWith(DOMAIN)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URL sanitizeURL(URL url) throws MalformedURLException {
|
public void downloadURL(URL url, int index) {
|
||||||
return url;
|
addURLToDownload(url, getPrefix(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<URL> getURLsFromPage(URL url) throws IOException {
|
||||||
|
List<URL> urls = new ArrayList<URL>();
|
||||||
|
Document doc = Http.url(url).get();
|
||||||
|
for (String stringURL : getURLsFromPageStatic(doc)) {
|
||||||
|
urls.add(new URL(stringURL));
|
||||||
|
}
|
||||||
|
return urls;
|
||||||
|
}
|
||||||
}
|
}
|
@ -51,8 +51,20 @@ public class GfycatRipper extends VideoRipper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void rip() throws IOException {
|
public void rip() throws IOException {
|
||||||
logger.info(" Retrieving " + this.url.toExternalForm());
|
String vidUrl = getVideoURL(this.url);
|
||||||
Document doc = Http.url(this.url).get();
|
addURLToDownload(new URL(vidUrl), "gfycat_" + getGID(this.url));
|
||||||
|
waitForThreads();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method for retrieving video URLs.
|
||||||
|
* @param url URL to gfycat page
|
||||||
|
* @return URL to video
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public static String getVideoURL(URL url) throws IOException {
|
||||||
|
logger.info("Retrieving " + url.toExternalForm());
|
||||||
|
Document doc = Http.url(url).get();
|
||||||
Elements videos = doc.select("source#mp4source");
|
Elements videos = doc.select("source#mp4source");
|
||||||
if (videos.size() == 0) {
|
if (videos.size() == 0) {
|
||||||
throw new IOException("Could not find source#mp4source at " + url);
|
throw new IOException("Could not find source#mp4source at " + url);
|
||||||
@ -61,7 +73,6 @@ public class GfycatRipper extends VideoRipper {
|
|||||||
if (vidUrl.startsWith("//")) {
|
if (vidUrl.startsWith("//")) {
|
||||||
vidUrl = "http:" + vidUrl;
|
vidUrl = "http:" + vidUrl;
|
||||||
}
|
}
|
||||||
addURLToDownload(new URL(vidUrl), "gfycat_" + getGID(this.url));
|
return vidUrl;
|
||||||
waitForThreads();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -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.69";
|
private static final String DEFAULT_VERSION = "1.0.70";
|
||||||
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";
|
||||||
|
@ -15,8 +15,10 @@ import org.jsoup.nodes.Element;
|
|||||||
|
|
||||||
import com.rarchives.ripme.ripper.AbstractRipper;
|
import com.rarchives.ripme.ripper.AbstractRipper;
|
||||||
import com.rarchives.ripme.ripper.rippers.ImgurRipper;
|
import com.rarchives.ripme.ripper.rippers.ImgurRipper;
|
||||||
|
import com.rarchives.ripme.ripper.rippers.VidbleRipper;
|
||||||
import com.rarchives.ripme.ripper.rippers.ImgurRipper.ImgurAlbum;
|
import com.rarchives.ripme.ripper.rippers.ImgurRipper.ImgurAlbum;
|
||||||
import com.rarchives.ripme.ripper.rippers.ImgurRipper.ImgurImage;
|
import com.rarchives.ripme.ripper.rippers.ImgurRipper.ImgurImage;
|
||||||
|
import com.rarchives.ripme.ripper.rippers.video.GfycatRipper;
|
||||||
|
|
||||||
public class RipUtils {
|
public class RipUtils {
|
||||||
private static final Logger logger = Logger.getLogger(RipUtils.class);
|
private static final Logger logger = Logger.getLogger(RipUtils.class);
|
||||||
@ -25,19 +27,36 @@ public class RipUtils {
|
|||||||
List<URL> result = new ArrayList<URL>();
|
List<URL> result = new ArrayList<URL>();
|
||||||
|
|
||||||
// Imgur album
|
// Imgur album
|
||||||
if ((url.getHost().equals("m.imgur.com") || url.getHost().equals("imgur.com"))
|
if ((url.getHost().endsWith("imgur.com"))
|
||||||
&& url.toExternalForm().contains("imgur.com/a/")) {
|
&& url.toExternalForm().contains("imgur.com/a/")) {
|
||||||
try {
|
try {
|
||||||
ImgurAlbum imgurAlbum = ImgurRipper.getImgurAlbum(url);
|
ImgurAlbum imgurAlbum = ImgurRipper.getImgurAlbum(url);
|
||||||
for (ImgurImage imgurImage : imgurAlbum.images) {
|
for (ImgurImage imgurImage : imgurAlbum.images) {
|
||||||
result.add(imgurImage.url);
|
result.add(imgurImage.url);
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error("[!] Exception while loading album " + url, e);
|
logger.error("[!] Exception while loading album " + url, e);
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
else if (url.getHost().endsWith("gfycat.com")) {
|
||||||
|
try {
|
||||||
|
String videoURL = GfycatRipper.getVideoURL(url);
|
||||||
|
result.add(new URL(videoURL));
|
||||||
|
} catch (IOException e) {
|
||||||
|
// Do nothing
|
||||||
|
logger.warn("Exception while retrieving gfycat page:", e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
else if (url.toExternalForm().contains("vidble.com/album/")) {
|
||||||
|
try {
|
||||||
|
result.addAll(VidbleRipper.getURLsFromPage(url));
|
||||||
|
} catch (IOException e) {
|
||||||
|
// Do nothing
|
||||||
|
logger.warn("Exception while retrieving vidble page:", e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Direct link to image
|
// Direct link to image
|
||||||
|
Loading…
Reference in New Issue
Block a user