Merge pull request #319 from blth/master
Added EroShare Ripper and Fixed Vidble ripper
This commit is contained in:
commit
a1cb242a53
@ -0,0 +1,128 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.rarchives.ripme.ripper.rippers;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.jsoup.Connection.Response;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
import org.jsoup.Connection.Method;
|
||||
|
||||
import com.rarchives.ripme.ripper.AbstractHTMLRipper;
|
||||
import com.rarchives.ripme.ui.RipStatusMessage.STATUS;
|
||||
import com.rarchives.ripme.utils.Http;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author losipher
|
||||
*/
|
||||
public class EroShareRipper extends AbstractHTMLRipper {
|
||||
|
||||
public EroShareRipper (URL url) throws IOException {
|
||||
super(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDomain() {
|
||||
return "eroshare.com";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHost() {
|
||||
return "eroshare";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadURL(URL url, int index){
|
||||
addURLToDownload(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getURLsFromPage(Document doc){
|
||||
List<String> URLs = new ArrayList<String>();
|
||||
//Pictures
|
||||
Elements imgs = doc.getElementsByTag("img");
|
||||
for (Element img : imgs){
|
||||
if (img.hasClass("album-image")){
|
||||
String imageURL = img.attr("src");
|
||||
imageURL = "https:" + imageURL;
|
||||
URLs.add(imageURL);
|
||||
}
|
||||
}
|
||||
//Videos
|
||||
Elements vids = doc.getElementsByTag("video");
|
||||
for (Element vid : vids){
|
||||
if (vid.hasClass("album-video")){
|
||||
Elements source = vid.getElementsByTag("source");
|
||||
String videoURL = source.first().attr("src");
|
||||
URLs.add(videoURL);
|
||||
}
|
||||
}
|
||||
|
||||
return URLs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Document getFirstPage() throws IOException {
|
||||
Response resp = Http.url(this.url)
|
||||
.ignoreContentType()
|
||||
.response();
|
||||
|
||||
Document doc = resp.parse();
|
||||
|
||||
return doc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGID(URL url) throws MalformedURLException {
|
||||
Pattern p = Pattern.compile("^https?://[w.]*eroshare.com/([a-zA-Z0-9\\-_]+)/?$");
|
||||
Matcher m = p.matcher(url.toExternalForm());
|
||||
if (m.matches()) {
|
||||
return m.group(1);
|
||||
}
|
||||
throw new MalformedURLException("eroshare album not found in " + url + ", expected https://eroshare.com/album");
|
||||
}
|
||||
|
||||
public static List<URL> getURLs(URL url) throws IOException{
|
||||
|
||||
Response resp = Http.url(url)
|
||||
.ignoreContentType()
|
||||
.response();
|
||||
|
||||
Document doc = resp.parse();
|
||||
|
||||
List<URL> URLs = new ArrayList<URL>();
|
||||
//Pictures
|
||||
Elements imgs = doc.getElementsByTag("img");
|
||||
for (Element img : imgs){
|
||||
if (img.hasClass("album-image")){
|
||||
String imageURL = img.attr("src");
|
||||
imageURL = "https:" + imageURL;
|
||||
URLs.add(new URL(imageURL));
|
||||
}
|
||||
}
|
||||
//Videos
|
||||
Elements vids = doc.getElementsByTag("video");
|
||||
for (Element vid : vids){
|
||||
if (vid.hasClass("album-video")){
|
||||
Elements source = vid.getElementsByTag("source");
|
||||
String videoURL = source.first().attr("src");
|
||||
URLs.add(new URL(videoURL));
|
||||
}
|
||||
}
|
||||
|
||||
return URLs;
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
import com.rarchives.ripme.ripper.AbstractHTMLRipper;
|
||||
@ -56,17 +57,18 @@ public class VidbleRipper extends AbstractHTMLRipper {
|
||||
|
||||
private static List<String> getURLsFromPageStatic(Document doc) {
|
||||
List<String> imageURLs = new ArrayList<String>();
|
||||
Elements els = doc.select("#ContentPlaceHolder1_thumbs");
|
||||
String thumbs = els.first().attr("value");
|
||||
for (String thumb : thumbs.split(",")) {
|
||||
if (thumb.trim().equals("") || thumb.contains("reddit.com")) {
|
||||
continue;
|
||||
Elements els = doc.select("#ContentPlaceHolder1_divContent");
|
||||
Elements imgs = els.select("img");
|
||||
for (Element img : imgs) {
|
||||
String src = img.absUrl("src");
|
||||
src = src.replaceAll("_[a-zA-Z]{3,5}", "");
|
||||
|
||||
if (!src.equals("")) {
|
||||
imageURLs.add(src);
|
||||
}
|
||||
thumb = thumb.replaceAll("_[a-zA-Z]{3,5}", "");
|
||||
imageURLs.add("http://vidble.com/" + thumb);
|
||||
}
|
||||
return imageURLs;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadURL(URL url, int index) {
|
||||
@ -81,4 +83,4 @@ public class VidbleRipper extends AbstractHTMLRipper {
|
||||
}
|
||||
return urls;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,8 @@ 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 {
|
||||
private static final Logger logger = Logger.getLogger(RipUtils.class);
|
||||
@ -69,7 +71,7 @@ public class RipUtils {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
else if (url.toExternalForm().contains("vidble.com/album/")) {
|
||||
else if (url.toExternalForm().contains("vidble.com/album/") || url.toExternalForm().contains("vidble.com/show/")) {
|
||||
try {
|
||||
logger.info("Getting vidble album " + url);
|
||||
result.addAll(VidbleRipper.getURLsFromPage(url));
|
||||
@ -79,6 +81,16 @@ public class RipUtils {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
else if (url.toExternalForm().contains("eroshare.com")) {
|
||||
try {
|
||||
logger.info("Getting eroshare album " + url);
|
||||
result.addAll(EroShareRipper.getURLs(url));
|
||||
} 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]+)\\?.*");
|
||||
Matcher m = p.matcher(url.toExternalForm());
|
||||
|
Loading…
Reference in New Issue
Block a user